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

Diff of /contributions/modules/devel/devel.module

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

revision 1.258.2.48, Mon Mar 16 19:44:34 2009 UTC revision 1.258.2.49, Wed Apr 1 02:03:10 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: devel.module,v 1.258.2.47 2009/02/11 04:11:46 weitzman Exp $  // $Id: devel.module,v 1.258.2.48 2009/03/16 19:44:34 weitzman Exp $
3    
4  // This module holds functions useful for Drupal development.  // This module holds functions useful for Drupal development.
5  // Please contribute!  // Please contribute!
# Line 524  function devel_block($op = 'list', $delt Line 524  function devel_block($op = 'list', $delt
524  }  }
525    
526  function devel_block_switch_user() {  function devel_block_switch_user() {
   $block['subject'] = t('Switch user');  
527    $links = devel_switch_user_list();    $links = devel_switch_user_list();
528    if (!empty($links)) {    if (!empty($links)) {
529      $block['content'] = theme('item_list', $links);      $block['subject'] = t('Switch user');
530        $block['content'] = theme('links', $links);
531      $block['content'] .= drupal_get_form('devel_switch_user_form');      $block['content'] .= drupal_get_form('devel_switch_user_form');
532      return $block;      return $block;
533    }    }
# Line 555  function devel_switch_user_list() { Line 555  function devel_switch_user_list() {
555        $users = db_query_range("SELECT DISTINCT u.uid, u.name, u.access FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE $where_sql ORDER BY u.access DESC", 0, $list_size);        $users = db_query_range("SELECT DISTINCT u.uid, u.name, u.access FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE $where_sql ORDER BY u.access DESC", 0, $list_size);
556      }      }
557      while ($user = db_fetch_object($users)) {      while ($user = db_fetch_object($users)) {
558        $links[$user->uid] = l(theme('placeholder', $user->name), 'devel/switch/'. $user->name, array('attributes' => array('title' => t('This user can switch back.')), 'query' => $dest, 'html' => TRUE));        $links[$user->uid] = array(
559            'title' => theme('placeholder', $user->name),
560            'href' => 'devel/switch/' . $user->name,
561            'query' => $dest,
562            'attributes' => array('title' => t('This user can switch back.')),
563            'html' => TRUE,
564          );
565      }      }
566      $num_links = count($links);      $num_links = count($links);
567      if ($num_links < $list_size) {      if ($num_links < $list_size) {
568        // If we don't have enough, add distinct uids until we hit $list_size.        // If we don't have enough, add distinct uids until we hit $list_size.
569        $users = db_query_range('SELECT uid, name, access FROM {users} WHERE uid > 0 AND uid NOT IN ('. implode(',', array_keys($links)) .') ORDER BY access DESC', 0, $list_size - $num_links);        $users = db_query_range('SELECT uid, name, access FROM {users} WHERE uid > 0 AND uid NOT IN ('. implode(',', array_keys($links)) .') ORDER BY access DESC', 0, $list_size - $num_links);
570        while (($user = db_fetch_object($users)) && count($links) < $list_size) {        while (($user = db_fetch_object($users)) && count($links) < $list_size) {
571          $links[$user->uid] = l($user->name ? $user->name : 'anon', 'devel/switch/'. $user->name, array('attributes' => array('title' => t('Caution: this user will be unable switch back.')), 'query' => $dest));          $links[$user->uid] = array(
572              'title' => $user->name ? $user->name : 'anon',
573              'href' => 'devel/switch/' . $user->name,
574              'query' => $dest,
575              'attributes' => array('title' => t('Caution: this user will be unable switch back.')),
576            );
577        }        }
578      }      }
579    }    }

Legend:
Removed from v.1.258.2.48  
changed lines
  Added in v.1.258.2.49

  ViewVC Help
Powered by ViewVC 1.1.2