function masquerade_ctools_is_masquerading in Masquerade Extras 7.2
Same name and namespace in other branches
- 6.2 masquerade_ctools/masquerade_ctools.module \masquerade_ctools_is_masquerading()
Evaluate if the account provided is posing as another user.
@returns TRUE if the account provided is masquerading. FALSE otherwise. @retval bool
Parameters
int|stdClass $account: The user account (or id) to evaluate.
2 calls to masquerade_ctools_is_masquerading()
- masquerade_ctools_masquerade_access_check in masquerade_ctools/
plugins/ access/ masquerade.inc - Checks masquerade conditions. If no context is provided, this will automatically return FALSE.
- masquerade_ctools_user_from_masquerade_context in masquerade_ctools/
plugins/ relationships/ user_from_masquerade.inc - Retrieves the user info from the context.
File
- masquerade_ctools/
masquerade_ctools.module, line 31 - Allows Ctools to look for masquerade plugins.
Code
function masquerade_ctools_is_masquerading($account) {
global $user;
if (is_object($account)) {
$account = $account->uid;
}
// Check if the account provided is the current user.
if ($user->uid == $account) {
return isset($_SESSION['masquerading']) && is_numeric($_SESSION['masquerading']);
}
// You can override this database query with:
// hook_query_masquerade_ctools_is_masquerading_alter().
// @see hook_query_TAG_alter()
$query = db_select('masquerade', 'm')
->addTag('masquerade_ctools_is_masquerading')
->fields('m', array(
'uid_as',
))
->condition('uid_from', $account, '=')
->range(0, 1)
->execute();
$result = $query
->fetchCol();
return !empty($result);
}