You are here

function user_admin_account in Drupal 5

Same name and namespace in other branches
  1. 4 modules/user.module \user_admin_account()
  2. 6 modules/user/user.admin.inc \user_admin_account()
  3. 7 modules/user/user.admin.inc \user_admin_account()
1 string reference to 'user_admin_account'
user_admin in modules/user/user.module

File

modules/user/user.module, line 2034
Enables the user registration and login system.

Code

function user_admin_account() {
  $filter = user_build_filter_query();
  $header = array(
    array(),
    array(
      'data' => t('Username'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Status'),
      'field' => 'u.status',
    ),
    t('Roles'),
    array(
      'data' => t('Member for'),
      'field' => 'u.created',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Last access'),
      'field' => 'u.access',
    ),
    t('Operations'),
  );
  $sql = 'SELECT DISTINCT u.uid, u.name, u.status, u.created, u.access FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where'];
  $sql .= tablesort_sql($header);
  $query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where'];
  $result = pager_query($sql, 50, 0, $query_count, $filter['args']);
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $options = array();
  foreach (module_invoke_all('user_operations') as $operation => $array) {
    $options[$operation] = $array['label'];
  }
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'unblock',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  $destination = drupal_get_destination();
  $status = array(
    t('blocked'),
    t('active'),
  );
  $roles = user_roles(1);
  while ($account = db_fetch_object($result)) {
    $accounts[$account->uid] = '';
    $form['name'][$account->uid] = array(
      '#value' => theme('username', $account),
    );
    $form['status'][$account->uid] = array(
      '#value' => $status[$account->status],
    );
    $users_roles = array();
    $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid);
    while ($user_role = db_fetch_object($roles_result)) {
      $users_roles[] = $roles[$user_role->rid];
    }
    asort($users_roles);
    $form['roles'][$account->uid][0] = array(
      '#value' => theme('item_list', $users_roles),
    );
    $form['member_for'][$account->uid] = array(
      '#value' => format_interval(time() - $account->created),
    );
    $form['last_access'][$account->uid] = array(
      '#value' => $account->access ? t('@time ago', array(
        '@time' => format_interval(time() - $account->access),
      )) : t('never'),
    );
    $form['operations'][$account->uid] = array(
      '#value' => l(t('edit'), "user/{$account->uid}/edit", array(), $destination),
    );
  }
  $form['accounts'] = array(
    '#type' => 'checkboxes',
    '#options' => $accounts,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}