class space_type in Spaces 7
Same name and namespace in other branches
- 6.3 plugins/space_type.inc \space_type
- 7.3 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
- class \space
- class \space_type
Expanded class hierarchy of space_type
4 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 - Implements hook_schema().
- spaces_spaces_plugins in ./
spaces.module - Implements hook_spaces_plugins().
- spaces_user_spaces_plugins in spaces_user/
spaces_user.module - Implements 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) {
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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
space:: |
property | |||
space:: |
property | |||
space:: |
property | |||
space:: |
property | |||
space:: |
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:: |
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:: |
protected | function | Instantiate controllers for this space. | |
space:: |
function | Initialize any overrides as necessary. | ||
space:: |
function | Extending classes can use this method to load any associated data or objects. Return FALSE to abort the load process. | 3 | |
space:: |
function | Constructor. | ||
space_type:: |
function | Grant a user administrative access to this space. | 2 | |
space_type:: |
function | Grant a user access to the specified feature in this space. | 2 | |
space_type:: |
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:: |
function | Grant a user access to the given account in this space. | 1 | |
space_type:: |
function | Get the possible feature setting values for this space. | ||
space_type:: |
function | Route the user as necessary. | 2 | |
space_type:: |
function | Get the title for this space. | 3 | |
space_type:: |
function | Views filter callback. | 2 |