diff --git a/sites/all/modules/masquerade/masquerade.module b/sites/all/modules/masquerade/masquerade.module index 6f4d2ac..2a95dce 100644 --- a/sites/all/modules/masquerade/masquerade.module +++ b/sites/all/modules/masquerade/masquerade.module @@ -27,7 +27,6 @@ function masquerade_permission() { // Load and build permissions for all roles in our site foreach (user_roles() as $rid => $role) { $title = 'masquerade as '. $role; - $key = drupal_strtolower($title); $description = t('Masquerade as a member of the @role role.', array('@role' => $role)); if ($rid == DRUPAL_AUTHENTICATED_RID) { $description = t('Grant this permission with caution. Any user signed in is given this role.'); @@ -355,13 +354,15 @@ function masquerade_user_logout($account) { */ function masquerade_user_view($account, $view_mode, $langcode) { global $user; - // Make sure the account viewed isn't our own and that we have adequate permissions to masquerade as it + // Make sure the account viewed isn't our own and that we have adequate + // permissions to masquerade as it if ($user->uid == $account->uid || !masquerade_check_user_roles($account)) { return; } // Ensure we have access to: the user page, that we are not presently masquerading, - // that the current account isn't our own, and that the user we're looking at only has roles we can become. + // that the current account isn't our own, and that the user we're looking at + // only has roles we can become. if (empty($account->masquerading)) { $account->content['masquerade'] = array( '#markup' => l(t('Masquerade as !user', array('!user' => $account->name)), @@ -775,7 +776,8 @@ function masquerade_switch_user($uid) { return FALSE; } - // Ensure the account we're switching to isn't our own and that we have permission to masquerade with these roles + // Ensure the account we're switching to isn't our own and that we have + // permission to masquerade with these roles if ($user->uid !== $new_user->uid && !masquerade_check_user_roles($new_user)) { watchdog('masquerade', 'The user %user has roles %user2 does not have permission to obtain.', array('%user' => $new_user->name, '%user2' => $user->name), WATCHDOG_ERROR); return FALSE; @@ -860,7 +862,8 @@ function masquerade_switch_back() { /** * Checks if the user has access to masquerade as a specific role. - * + * @param string $role + * The name of the role to check. Also accepts a machine name permission. * @return bool * Whether or not the current user is allowed to masquerade as someone with this role. */ @@ -894,10 +897,10 @@ function masquerade_check_roles($roles = array()) { * Checks all roles of the user we're trying to become. * * @param mixed - * The user object to check roles. + * The user object to check roles. Also accepts uids and user names. * @return bool - * Return FALSE if any role exists that the current user isn't permitted to become. - * Return TRUE otherwise. + * Return FALSE if any role exists that the current user isn't permitted to become. + * Return TRUE otherwise. */ function masquerade_check_user_roles($user) { if (is_numeric($user)) { @@ -913,7 +916,7 @@ function masquerade_check_user_roles($user) { } /** - * Check if the user has ANY masquerade permission. + * Check if the current user has ANY masquerade permission. * * @return bool * Return TRUE if user has access to masquerade at all.