function masquerade_ctools_masquerade_access_check in Masquerade Extras 6.2
Same name and namespace in other branches
- 7.2 masquerade_ctools/plugins/access/masquerade.inc \masquerade_ctools_masquerade_access_check()
Checks masquerade conditions. If no context is provided, this will automatically return FALSE.
@returns TRUE if the current user is masquerading. FALSE otherwise. @retval bool
Parameters
array $conf: The plugin configuration.
array $context: Contexts to evaluate against.
1 string reference to 'masquerade_ctools_masquerade_access_check'
- masquerade.inc in masquerade_ctools/
plugins/ access/ masquerade.inc
File
- masquerade_ctools/
plugins/ access/ masquerade.inc, line 65
Code
function masquerade_ctools_masquerade_access_check($conf, $context) {
// If no account was supplied, exit.
if (empty($context)) {
return FALSE;
}
// The user account will aready be loaded.
$account = $context[0]->data;
if (isset($_SESSION['masquerading']) && is_numeric($_SESSION['masquerading'])) {
ctools_context_create('masquerade', $_SESSION['masquerading']);
}
// Check if the user is masquerading.
if ('is_masquerading' == $conf['mode']) {
return masquerade_ctools_is_masquerading($account);
}
// Check if the user is being masqueraded.
if ('is_being_masqueraded' == $conf['mode']) {
return masquerade_ctools_is_being_masqueraded($account);
}
// Fallback value if no configuration exists.
return FALSE;
}