You are here

class space_user in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces_user/plugins/space_user.inc \space_user
  2. 7 spaces_user/plugins/space_user.inc \space_user

User integration for Spaces.

Hierarchy

Expanded class hierarchy of space_user

2 string references to 'space_user'
spaces_user_spaces_plugins in spaces_user/spaces_user.module
Implements hook_spaces_plugins().
spaces_user_spaces_registry in spaces_user/spaces_user.module
Implements hook_spaces_registry().

File

spaces_user/plugins/space_user.inc, line 6

View source
class space_user extends space_type {

  /**
   * Override of load().
   * Load the user account object for this space and bail if it can't be loaded.
   */
  function load() {
    parent::load();
    $account = user_load($this->id);
    if ($account) {
      $this->user = $account;
      return TRUE;
    }
    return FALSE;
  }

  /**
   * Override of deactivate().
   * We don't have too many good options here except to leave the user/x path.
   * If the site frontpage has also been set to a user/x path, we just need
   * to fail miserably.
   */
  function deactivate() {
    if (strpos(variable_get('site_frontpage', 'node'), 'user') !== 0) {
      drupal_goto('<front>');
    }
    return;
  }

  /**
   * Override of title().
   */
  function title() {
    return $this->user->name;
  }

  /**
   * Override of access_admin().
   */
  function access_admin($account = NULL) {
    global $user;
    $account = isset($account) ? $account : $user;
    $access = $account->uid == $this->id && user_access('configure own user space');
    return $access || parent::access_admin($account);
  }

  /**
   * Override of access_feature().
   */
  function access_feature($op = 'view', $feature, $account = NULL) {
    $site_features = spaces_features('site');
    $user_features = spaces_features('user');

    // If feature can be used in "site space" but not user space, ensure we
    // still allow access since user spaces are only active "locally" under
    // user/x.
    //
    // Features that can be used in both user and site spaces should implement
    // their own access callbacks (rather than using spaces_access_feature())
    // to manage access control rules when in a user space.
    if (isset($site_features[$feature]) && !isset($user_features[$feature])) {
      $enabled = $this->controllers->variable
        ->get('spaces_features', 'original');
      return user_access('access content') && !empty($enabled[$feature]);
    }
    return parent::access_feature($op, $feature, $account);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
space::$active property
space::$controllers property
space::$id property
space::$type property
space::activate function Called from spaces_init_space(). Determine whether this space can be set as the current active space. Override to provide custom logic for bailing the spaces bootstrap. 1
space::get_controllers protected function Instantiate controllers for this space.
space::init_overrides function Initialize any overrides as necessary.
space::__construct function Constructor. 1
space_type::access_space function Grant a user access to anything in this space. This method can be used to deny access to any page where this space is active. 1
space_type::access_user function Grant a user access to the given account in this space. 1
space_type::feature_options function Get the possible feature setting values for this space.
space_type::router function Route the user as necessary. 2
space_type::views_filter function Views filter callback. 2
space_user::access_admin function Override of access_admin(). Overrides space_type::access_admin
space_user::access_feature function Override of access_feature(). Overrides space_type::access_feature
space_user::deactivate function Override of deactivate(). We don't have too many good options here except to leave the user/x path. If the site frontpage has also been set to a user/x path, we just need to fail miserably. Overrides space::deactivate
space_user::load function Override of load(). Load the user account object for this space and bail if it can't be loaded. Overrides space::load
space_user::title function Override of title(). Overrides space_type::title