class space_type_purl in Spaces 6.3
Same name and namespace in other branches
- 7.3 plugins/space_type_purl.inc \space_type_purl
- 7 plugins/space_type_purl.inc \space_type_purl
Common functionality for space types that use a PURL modifier to trigger their activation. Examples: space_og, space_taxonomy.
Hierarchy
- class \space
- class \space_type
- class \space_type_purl
- class \space_type
Expanded class hierarchy of space_type_purl
3 string references to 'space_type_purl'
- spaces_og_spaces_plugins in spaces_og/
spaces_og.module - Implementation of hook_spaces_plugins().
- spaces_spaces_plugins in ./
spaces.module - Implementation of hook_spaces_plugins().
- spaces_taxonomy_spaces_plugins in spaces_taxonomy/
spaces_taxonomy.module - Implementation of hook_spaces_plugins().
File
- plugins/
space_type_purl.inc, line 7
View source
class space_type_purl extends space_type {
/**
* Verify that this space's PURL modifier is present for the current
* page request.
*/
protected function verify_purl() {
$method = variable_get("purl_method_spaces_{$this->type}", 'path');
$elements = purl_active()
->get($method);
foreach ($elements as $element) {
if ($element->provider == "spaces_{$this->type}" && $element->id == $this->id) {
return TRUE;
}
}
return FALSE;
}
/**
* Return an array of paths from which the space should never be active.
*/
protected function excluded_paths() {
return array(
'features',
'features/*',
'admin',
'admin/*',
);
}
/**
* Override of activate(). Ensure that the PURL modifier is present when the
* space is active.
*/
function activate() {
if (!$this
->verify_purl()) {
$this
->purge_request_destination();
// @TODO: This will drop other PURL providers. Probably not the desired behavior!
purl_goto($_GET['q'], array(
'query' => drupal_query_string_encode($_GET, array(
'q',
)),
'purl' => array(
'provider' => "spaces_{$this->type}",
'id' => $this->id,
),
));
}
// Activate the space before checking for excluded paths. This prevents
// certain corner case badness, e.g. a stale $_GET['q'] set for the site
// space triggering an excluded path check.
$activated = parent::activate();
$paths = implode("\n", $this
->excluded_paths());
if (drupal_match_path($_GET['q'], $paths)) {
$this
->deactivate();
return FALSE;
}
return TRUE;
}
/**
* Override of deactivate(). Ensure that the PURL modifier is not present
* when the space is not active.
*/
function deactivate() {
$this
->purge_request_destination();
purl_goto($_GET['q'], array(
'query' => drupal_query_string_encode($_GET, array(
'q',
)),
'purl' => array(
'remove' => array(
"spaces_{$this->type}",
),
),
));
}
/**
* Pull the destination out of the $_REQUEST to prevent a redirect directly to
* it within purl_goto. This function should be used immediately before a call
* to purl_goto.
*/
function purge_request_destination() {
if (isset($_REQUEST['destination'])) {
unset($_REQUEST['destination']);
}
if (isset($_REQUEST['edit']['destination'])) {
unset($_REQUEST['edit']['destination']);
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
space:: |
property | |||
space:: |
property | |||
space:: |
property | |||
space:: |
property | |||
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 | |
space_type_purl:: |
function |
Override of activate(). Ensure that the PURL modifier is present when the
space is active. Overrides space:: |
1 | |
space_type_purl:: |
function |
Override of deactivate(). Ensure that the PURL modifier is not present
when the space is not active. Overrides space:: |
||
space_type_purl:: |
protected | function | Return an array of paths from which the space should never be active. | 1 |
space_type_purl:: |
function | Pull the destination out of the $_REQUEST to prevent a redirect directly to it within purl_goto. This function should be used immediately before a call to purl_goto. | ||
space_type_purl:: |
protected | function | Verify that this space's PURL modifier is present for the current page request. |