You are here

class space_type in Spaces 6.3

Same name and namespace in other branches
  1. 7.3 plugins/space_type.inc \space_type
  2. 7 plugins/space_type.inc \space_type

Common functionality for space types that implement access, routing, delegated Views filtering and feature management concepts. Examples: spaces_og, spaces_user, spaces_taxonomy.

Hierarchy

Expanded class hierarchy of space_type

5 string references to 'space_type'
hook_spaces_plugins in ./spaces.api.php
CTools plugin API hook for Spaces. Note that a proper entry in hook_ctools_plugin_api() must exist for this hook to be called.
spaces_schema in ./spaces.install
Implementation of hook_schema()
spaces_spaces_plugins in ./spaces.module
Implementation of hook_spaces_plugins().
spaces_update_6301 in ./spaces.install
Update to version 3.
spaces_user_spaces_plugins in spaces_user/spaces_user.module
Implementation of hook_spaces_plugins().

File

plugins/space_type.inc, line 8

View source
class space_type extends space {

  /**
   * Get the title for this space.
   *
   * @return
   *   The string title for this space.
   */
  function title() {
    return '';
  }

  /**
   * Get the possible feature setting values for this space.
   *
   * @return
   *   A keyed array of options.
   */
  function feature_options() {
    return array(
      0 => t('Disabled'),
      1 => t('Enabled'),
    );
  }

  /**
   * Access & routing =================================================
   */

  /**
   * Route the user as necessary.
   *
   * @param $op
   *   The hook or Drupal implementation point where the router is being given
   *   a chance to intervene.
   * @param $object
   *   Optional: the menu object related to the current page request where
   *   routing may occur. For example, $object is the node object if routing
   *   occurs at node/5.
   */
  function router($op, $object = NULL) {
    switch ($op) {
      case 'init':
      case 'user':
      case 'node':
      default:
        return TRUE;
    }
  }

  /**
   * 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.
   *
   * @param $account
   *   Optional: user account object to check against. If omitted, the global
   *   $user object (current user) will be used.
   *
   * @return
   *   TRUE if access should be granted. FALSE if not.
   */
  function access_space($account = NULL) {
    return TRUE;
  }

  /**
   * Grant a user administrative access to this space.
   *
   * @param $account
   *   Optional: user account object to check against. If omitted, the global
   *   $user object (current user) will be used.
   *
   * @return
   *   TRUE if access should be granted. FALSE if not.
   */
  function access_admin($account = NULL) {
    global $user;
    $account = isset($account) ? $account : $user;
    return user_access('administer site configuration', $account) || user_access('administer spaces', $account);
  }

  /**
   * Grant a user access to the specified feature in this space.
   *
   * @param $op
   *   May be 'view' or 'create'.
   * @param $feature
   *   The feature in question to check access for.
   * @param $account
   *   Optional: user account object to check against. If omitted, the global
   *   $user object (current user) will be used.
   *
   * @return
   *   TRUE if access should be granted. FALSE if not.
   */
  function access_feature($op = 'view', $feature, $account = NULL) {
    $usable = spaces_features($this->type);
    $features = $this->controllers->variable
      ->get('spaces_features');
    return user_access('access content', $account) && isset($usable[$feature]) && !empty($features[$feature]);
  }

  /**
   * Grant a user access to the given account in this space.
   *
   * @param $op
   *   May be 'view' or 'edit'.
   *
   * @return
   *   TRUE if access should be granted. FALSE if not.
   */
  function access_user($op = 'view', $account = NULL) {
    return TRUE;
  }

  /**
   * Views filter callback.
   *
   * @param $query
   *   A views query object, passed by reference.
   * @param $base_table
   *   The base table for this View, e.g. "node", "user"
   * @param $relationship
   *   The relationship being used by the views spaces filter.
   */
  function views_filter(&$query, $base_table = '', $relationship = '') {
    return;
  }

}

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::deactivate function Called when this space should be deactivated. If a space type uses a PURL modifier to be instantiated, this is the time to remove that condition. Other spaces may need to remove their custom conditions need to be at this point. 2
space::get_controllers protected function Instantiate controllers for this space.
space::init_overrides function Initialize any overrides as necessary.
space::load function Extending classes can use this method to load any associated data or objects. Return FALSE to abort the load process. 3
space::__construct function Constructor.
space_type::access_admin function Grant a user administrative access to this space. 2
space_type::access_feature function Grant a user access to the specified feature in this space. 2
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::title function Get the title for this space. 3
space_type::views_filter function Views filter callback. 2