user_admin_account

Definition

user_admin_account()
modules/user.module, line 1648

Code

<?php
function user_admin_account() {
  $header = array(
    array('data' => t('ID'), 'field' => 'u.uid'),
    array('data' => t('Username'), 'field' => 'u.name'),
    array('data' => t('Status'), 'field' => 'u.status'),
    array('data' => t('Roles')),
    array('data' => t('Last access'), 'field' => 'u.changed', 'sort' => 'desc'),
    t('Operations')
  );
  $sql = 'SELECT u.uid, u.name, u.status, u.changed FROM {users} u WHERE uid != 0';
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, 50);

  $status = array(t('blocked'), t('active'));
  $destination = drupal_get_destination();
  while ($account = db_fetch_object($result)) {
    $rolesresult = db_query('SELECT r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $account->uid);
    $roles = array();

    while ($role = db_fetch_object($rolesresult)) {
      $roles[] = $role->name;
    }

    $rows[] = array($account->uid, format_name($account), $status[$account->status], implode(',<br />', $roles), format_date($account->changed, 'small'), l(t('edit'), "user/$account->uid/edit", array(), $destination));
  }

  $pager = theme('pager', NULL, 50, 0, tablesort_pager());
  if (!empty($pager)) {
    $rows[] = array(array('data' => $pager, 'colspan' => '6'));
  }
  return theme('table', $header, $rows);
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.