function user_admin_account
Form builder; User administration page.
See also
Related topics
1 string reference to 'user_admin_account'
- user_admin in modules/
user/ user.admin.inc - Page callback: Generates the appropriate user administration form.
File
-
modules/
user/ user.admin.inc, line 163
Code
function user_admin_account() {
$header = array(
'username' => array(
'data' => t('Username'),
'field' => 'u.name',
),
'status' => array(
'data' => t('Status'),
'field' => 'u.status',
),
'roles' => array(
'data' => t('Roles'),
),
'member_for' => array(
'data' => t('Member for'),
'field' => 'u.created',
'sort' => 'desc',
),
'changed' => array(
'data' => t('Last changed'),
'field' => 'u.changed',
'sort' => 'desc',
),
'access' => array(
'data' => t('Last access'),
'field' => 'u.access',
),
'operations' => array(
'data' => t('Operations'),
),
);
$query = db_select('users', 'u');
$query->condition('u.uid', 0, '<>');
user_build_filter_query($query);
$count_query = clone $query;
$count_query->addExpression('COUNT(u.uid)');
$query = $query->extend('PagerDefault')
->extend('TableSort');
$query->fields('u', array(
'uid',
'name',
'status',
'created',
'changed',
'access',
))
->limit(50)
->orderByHeader($header)
->setCountQuery($count_query);
$result = $query->execute();
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#attributes' => array(
'class' => array(
'container-inline',
),
),
);
$options = array();
foreach (module_invoke_all('user_operations') as $operation => $array) {
$options[$operation] = $array['label'];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#title' => t('Operation'),
'#title_display' => 'invisible',
'#options' => $options,
'#default_value' => 'unblock',
);
$options = array();
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
$destination = drupal_get_destination();
$status = array(
t('blocked'),
t('active'),
);
$roles = array_map('check_plain', user_roles(TRUE));
$accounts = array();
foreach ($result as $account) {
$users_roles = array();
$roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(
':uid' => $account->uid,
));
foreach ($roles_result as $user_role) {
$users_roles[] = $roles[$user_role->rid];
}
asort($users_roles);
$options[$account->uid] = array(
'username' => theme('username', array(
'account' => $account,
)),
'status' => $status[$account->status],
'roles' => theme('item_list', array(
'items' => $users_roles,
)),
'member_for' => format_interval(REQUEST_TIME - $account->created),
'changed' => t('@time ago', array(
'@time' => format_interval(REQUEST_TIME - $account->changed),
)),
'access' => $account->access ? t('@time ago', array(
'@time' => format_interval(REQUEST_TIME - $account->access),
)) : t('never'),
'operations' => array(
'data' => array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => "user/{$account->uid}/edit",
'#options' => array(
'query' => $destination,
),
),
),
);
}
$form['accounts'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No people available.'),
);
$form['pager'] = array(
'#markup' => theme('pager'),
);
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.