You are here

function masquerade_context_condition::is_masquerading in Masquerade Extras 6.2

Same name and namespace in other branches
  1. 7.2 masquerade_context/plugins/condition/masquerade_context.inc \masquerade_context_condition::is_masquerading()
  2. 7 masquerade_context/plugins/condition/masquerade_context.inc \masquerade_context_condition::is_masquerading()

Evaluates if the account is masquerading as someone else.

@returns TRUE if the account is posing as someone else. FALSE otherwise. @retval bool

Parameters

stdClass $account: The user account to evaluate.

1 call to masquerade_context_condition::is_masquerading()
masquerade_context_condition::execute_is_masquerading in masquerade_context/plugins/condition/masquerade_context.inc
Evaluates if the account is masquerading.

File

masquerade_context/plugins/condition/masquerade_context.inc, line 150
Expose masquerade as a customizable context condition.

Class

masquerade_context_condition
@file Expose masquerade as a customizable context condition.

Code

function is_masquerading($account) {
  global $user;

  // If the account is our own, check the user session.
  if ($account->uid == $user->uid) {
    return isset($_SESSION['masquerading']) && is_numeric($_SESSION['masquerading']);
  }
  $query_is_masquerading = db_query("SELECT `uid_as`\n         FROM {masquerade}\n        WHERE `uid_from` = %d\n        LIMIT 1;", $account->uid);
  return (bool) db_result($query_is_masquerading);
}