function masquerade_context_condition::execute_is_being_masqueraded in Masquerade Extras 7.2
Same name and namespace in other branches
- 6.2 masquerade_context/plugins/condition/masquerade_context.inc \masquerade_context_condition::execute_is_being_masqueraded()
- 7 masquerade_context/plugins/condition/masquerade_context.inc \masquerade_context_condition::execute_is_being_masqueraded()
Evaluates if someone is posing as the account.
Parameters
stdClass $account: The user account to evaluate.
1 call to masquerade_context_condition::execute_is_being_masqueraded()
- masquerade_context_condition::execute in masquerade_context/
plugins/ condition/ masquerade_context.inc - Evalutes this context condition.
File
- masquerade_context/
plugins/ condition/ masquerade_context.inc, line 107 - Expose masquerade as a customizable context condition.
Class
- masquerade_context_condition
- @file Expose masquerade as a customizable context condition.
Code
function execute_is_being_masqueraded($account) {
global $user;
// Evaluate if the current user is being masqueraded.
$i_am_being_masqueraded = $this
->is_being_masqueraded($user);
// Evaluate if the account provided is masquerading.
$you_are_being_masqueraded = $this
->is_being_masqueraded($account);
// Iterate through each context that uses this plugin.
foreach ($this
->get_contexts($account) as $context) {
// Get the context's settings.
$values = $this
->fetch_from_context($context, 'values');
$options = $this
->fetch_from_context($context, 'options');
// Skip processing if the context is not checking 'is being masqueraded'.
if (empty($options['mode']['is_being_masqueraded'])) {
continue;
}
// Evaluate if we wanted to check against our own account.
if ($i_am_being_masqueraded && $account->uid == $user->uid && !empty($values['myself'])) {
$this
->condition_met($context, 'is_being_masqueraded');
}
// Evaluate if we wanted to check against the viewed account.
if ($you_are_being_masqueraded && $account->uid != $user->uid && !empty($values['other'])) {
$this
->condition_met($context, 'is_being_masqueraded');
}
}
}