You are here

function _masquerade_rules_get_masquerading_user in Masquerade Extras 7.2

Same name and namespace in other branches
  1. 7 masquerade_rules/masquerade_rules.module \_masquerade_rules_get_masquerading_user()

Internal - Returns user's masquerading user object.

1 string reference to '_masquerade_rules_get_masquerading_user'
masquerade_rules_entity_property_info_alter in masquerade_rules/masquerade_rules.module
Implements hook_entity_property_info_alter.

File

masquerade_rules/masquerade_rules.module, line 24
This file is required for Drupal to recognize the module.

Code

function _masquerade_rules_get_masquerading_user($account, array $options, $name, $entity_type) {

  // Anonymous users wont have a UID, but we store it as 0.
  $uid = isset($account->uid) ? $account->uid : 0;
  $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) ? $result[0] : '';
}