space_type_purl.inc in Spaces 6.3
File
plugins/space_type_purl.inc
View source
<?php
class space_type_purl extends space_type {
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;
}
protected function excluded_paths() {
return array(
'features',
'features/*',
'admin',
'admin/*',
);
}
function activate() {
if (!$this
->verify_purl()) {
$this
->purge_request_destination();
purl_goto($_GET['q'], array(
'query' => drupal_query_string_encode($_GET, array(
'q',
)),
'purl' => array(
'provider' => "spaces_{$this->type}",
'id' => $this->id,
),
));
}
$activated = parent::activate();
$paths = implode("\n", $this
->excluded_paths());
if (drupal_match_path($_GET['q'], $paths)) {
$this
->deactivate();
return FALSE;
}
return TRUE;
}
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}",
),
),
));
}
function purge_request_destination() {
if (isset($_REQUEST['destination'])) {
unset($_REQUEST['destination']);
}
if (isset($_REQUEST['edit']['destination'])) {
unset($_REQUEST['edit']['destination']);
}
}
}
Classes
Name |
Description |
space_type_purl |
Common functionality for space types that use a PURL modifier to trigger
their activation. Examples: space_og, space_taxonomy. |