context_error_context_conditions.inc in Context error 6
File
plugins/context_error_context_conditions.inc
View source
<?php
class context_error_context_condition_error extends context_condition {
function condition_values() {
$values = array();
$values['403'] = t('403 error');
$values['404'] = t('404 error');
return $values;
}
function execute() {
if ($this
->condition_used()) {
$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 (in_array(variable_get("site_{$error}", ''), $current_path)) {
$this
->condition_met($context);
continue;
}
$current_response = context_error_get_response_from_headers();
if ((int) $current_response === (int) $error) {
$this
->condition_met($context);
continue;
}
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);
}
}
}
}
}
}
}