function masquerade_context_condition::execute_is_masquerading in Masquerade Extras 6.2
Same name and namespace in other branches
- 7.2 masquerade_context/plugins/condition/masquerade_context.inc \masquerade_context_condition::execute_is_masquerading()
- 7 masquerade_context/plugins/condition/masquerade_context.inc \masquerade_context_condition::execute_is_masquerading()
Evaluates if the account is masquerading.
Parameters
stdClass $account: The user account to evaluate.
1 call to masquerade_context_condition::execute_is_masquerading()
- 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 68 - Expose masquerade as a customizable context condition.
Class
- masquerade_context_condition
- @file Expose masquerade as a customizable context condition.
Code
function execute_is_masquerading($account) {
global $user;
// Evaluate if the current user is masquerading.
$i_am_masquerading = $this
->is_masquerading($user);
// Evaluate if the account provided is masquerading.
$you_are_masquerading = $this
->is_masquerading($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 masquerading'.
if (empty($options['mode']['is_masquerading'])) {
continue;
}
// Evaluate if we wanted to check against our own account.
if ($i_am_masquerading && $account->uid == $user->uid && !empty($values['myself'])) {
$this
->condition_met($context, 'is_masquerading');
}
// Evaluate if we wanted to check against the viewed account.
if ($you_are_masquerading && $account->uid != $user->uid && !empty($values['other'])) {
$this
->condition_met($context, 'is_masquerading');
}
}
}