function masquerade_rules_is_being_masqueraded in Masquerade Extras 7.2
Same name and namespace in other branches
- 7 masquerade_rules/masquerade_rules.rules.inc \masquerade_rules_is_being_masqueraded()
Checks if the user supplied is being masqueraded by another user.
@returns TRUE if this account is located in the {masquerade} table. FALSE otherwise. @retval bool
Parameters
stdClass $account: A fully-loaded Drupal user object.
File
- masquerade_rules/
masquerade_rules.rules.inc, line 95 - Rules support for Masquerade.
Code
function masquerade_rules_is_being_masqueraded($account) {
// Anonymous users wont have a UID, but we store them as 0.
$uid = isset($account->uid) ? $account->uid : 0;
// You can override this database query with:
// hook_query_masquerade_rules_is_masquerading_alter().
// @see hook_query_TAG_alter()
$query = db_select('masquerade', 'm')
->addTag('masquerade_rules_is_being_masqueraded')
->fields('m', array(
'uid_from',
))
->condition('uid_as', $uid, '=')
->range(0, 1)
->execute();
$result = $query
->fetchCol();
return !empty($result);
}