/[drupal]/contributions/modules/masquerade/masquerade.module
ViewVC logotype

Diff of /contributions/modules/masquerade/masquerade.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5.2.4 by Gurpartap, Tue Oct 31 05:22:51 2006 UTC revision 1.5.2.5 by deekayen, Tue Feb 10 16:33:52 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: masquerade.module,v 1.5.2.3 2006/03/14 23:05:23 merlinofchaos Exp $  // $Id: masquerade.module,v 1.5.2.4 2006/10/31 05:22:51 Gurpartap Exp $
3    
4  /**  /**
5   * @file masquerade.module   * @file masquerade.module
# Line 25  function masquerade_help($section) { Line 25  function masquerade_help($section) {
25  function masquerade_menu($may_cache) {  function masquerade_menu($may_cache) {
26    $items = array();    $items = array();
27    if ($may_cache) {    if ($may_cache) {
28      $items[] = array('path' => 'masquerade/switch',      $items[] = array('path' => 'masquerade/switch',
29        'title' => t('switch user'),        'title' => t('switch user'),
30        'callback' => 'masquerade_switch_user',        'callback' => 'masquerade_switch_user',
31        'access' => !$user->masquerading && (user_access('masquerade as user') || user_access('masquerade as admin')),        'access' => !$user->masquerading && (user_access('masquerade as user') || user_access('masquerade as admin')),
32        'type' => MENU_CALLBACK);        'type' => MENU_CALLBACK);
33    
34      global $user;      global $user;
35      $items[] = array('path' => 'masquerade/unswitch',      $items[] = array('path' => 'masquerade/unswitch',
36        'title' => t('switch back'),        'title' => t('switch back'),
37        'callback' => 'masquerade_switch_back',        'callback' => 'masquerade_switch_back',
38        'access' => $user->masquerading,        'access' => $user->masquerading,
# Line 61  function masquerade_init() { Line 61  function masquerade_init() {
61   */   */
62  function masquerade_user($op, &$edit, &$edit_user, $category = NULL) {  function masquerade_user($op, &$edit, &$edit_user, $category = NULL) {
63    switch ($op) {    switch ($op) {
64    
65      case 'logout':      case 'logout':
66        if ($edit_user->masquerading) {        if (!empty($edit_user->masquerading)) {
67          global $user;          global $user;
68          $real_user = user_load(array('uid' => $user->masquerading));          $real_user = user_load(array('uid' => $user->masquerading));
69          watchdog('masquerade', "User '$real_user->name' no longer masquerading as '$user->name'");          watchdog('masquerade', "User '$real_user->name' no longer masquerading as '$user->name'");
# Line 74  function masquerade_user($op, &$edit, &$ Line 74  function masquerade_user($op, &$edit, &$
74      case 'view':      case 'view':
75        // check if user qualifies as admin        // check if user qualifies as admin
76        $roles = variable_get('masquerade_admin_roles', array());        $roles = variable_get('masquerade_admin_roles', array());
77        $perm = $edit_user->uid == 1 || array_intersect(array_keys($edit_user->roles), $roles) ?        $perm = $edit_user->uid == 1 || array_intersect(array_keys($edit_user->roles), $roles) ?
78          'masquerade as admin' :          'masquerade as admin' :
79          'masquerade as user';          'masquerade as user';
80    
# Line 123  function masquerade_switch_user($uid) { Line 123  function masquerade_switch_user($uid) {
123    
124    $roles = variable_get('masquerade_admin_roles', array());    $roles = variable_get('masquerade_admin_roles', array());
125    
126    $perm = $uid == 1 || array_intersect(array_keys($new_user->roles), $roles) ?    $perm = $uid == 1 || array_intersect(array_keys($new_user->roles), $roles) ?
127      'masquerade as admin' :      'masquerade as admin' :
128      'masquerade as user';      'masquerade as user';
129    // check to see if we need admin permission    // check to see if we need admin permission

Legend:
Removed from v.1.5.2.4  
changed lines
  Added in v.1.5.2.5

  ViewVC Help
Powered by ViewVC 1.1.3