function context_error_context_condition_error::execute in Context error 6
Same name and namespace in other branches
- 7 plugins/context_error_context_conditions.inc \context_error_context_condition_error::execute()
Execute.
File
- plugins/
context_error_context_conditions.inc, line 17
Class
- context_error_context_condition_error
- Expose the 404 error page as the context condition.
Code
function execute() {
if ($this
->condition_used()) {
// Include both the path alias and normal path for matching.
$current_path = array(
drupal_get_path_alias($_GET['q']),
);
if ($current_path != $_GET['q']) {
$current_path[] = $_GET['q'];
}
foreach ($this
->get_contexts() as $context) {
$errors = $this
->fetch_from_context($context, 'values');
foreach ($errors as $error) {
// If the site_403 or site_404 variable is set we can match it against
// the current path.
if (in_array(variable_get("site_{$error}", ''), $current_path)) {
$this
->condition_met($context);
continue;
}
// If the response headers have already been set, we can match those.
$current_response = context_error_get_response_from_headers();
if ((int) $current_response === (int) $error) {
$this
->condition_met($context);
continue;
}
// If logintoboggan is handling the 403 page and we're currently
// attempting to detect 403 errors, we can check the global variable.
if ((int) $error === 403) {
global $logintoboggan_denied;
$logintoboggan_is_handling_403 = variable_get('site_403', '') === 'toboggan/denied';
if ($logintoboggan_is_handling_403 && !empty($logintoboggan_denied)) {
$this
->condition_met($context);
}
}
}
}
}
}