function advuser_admin_account in Advanced User 6.3
Same name and namespace in other branches
- 5.2 advuser.module \advuser_admin_account()
- 6.2 advuser.module \advuser_admin_account()
- 7.3 forms/advuser_admin_account.inc \advuser_admin_account()
Provide the list of filtered users.
1 string reference to 'advuser_admin_account'
- advuser_admin in forms/
advuser_admin.inc - Callback form controller.
File
- forms/
advuser_admin_account.inc, line 13 - This is the part of the form that provides the actions and the list based on the selected filters.
Code
function advuser_admin_account(&$form_state) {
// Get the filters for the user data.
$filter = advuser_build_filter_query();
// Get the list of user roles to be displayed.
$roles = advuser_user_roles();
// Array used for user profile title and value display in list.
$ff = array();
foreach (advuser_profile_fields() as $field) {
if (isset($field->name)) {
$ff[] = array(
'data' => t($field->title),
'field' => "{$field->name}.value",
);
}
}
$header = array(
array(),
array(
'data' => t('Username'),
'field' => 'u.name',
),
array(
'data' => t('Mail'),
'field' => 'u.mail',
),
array(
'data' => t('Status'),
'field' => 'u.status',
),
);
if (count($roles)) {
$header[] = t('Roles');
}
$header = array_merge($header, array(
array(
'data' => t('Member for'),
'field' => 'u.created',
'sort' => 'desc',
),
array(
'data' => t('Last access'),
'field' => 'u.access',
),
));
$header = array_merge($header, $ff);
$header[] = t('Operations');
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Action options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
'#collapsible' => FALSE,
);
$options = array();
// We don't want to call the user_operations here because we can't control
// the functioning of the callbacks to the saved accounts in the session.
// The callbacks only operate on the current screenfull of data and know
// nothing about the Select All Users mode.
$operations = module_invoke_all('advuser_operations');
foreach ($operations as $operation => $array) {
$options[$operation] = $array['label'];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'saveselect',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Apply action'),
);
$destination = drupal_get_destination();
list($junk, $go) = split('=', $destination);
$form['destination'] = array(
'#type' => 'value',
'#value' => urldecode($go),
);
$status = array(
t('blocked'),
t('active'),
);
$roles = advuser_user_roles();
$sql = advuser_build_query();
$sql .= tablesort_sql($header);
$query_count = advuser_build_query('count');
$result = pager_query($sql, variable_get('advuser_listno', 50), 0, $query_count, $filter['args']);
while ($account = db_fetch_object($result)) {
if ($account->uid && ($account->uid != 1 || variable_get('advuser_allow_list_uid1', FALSE))) {
$accounts[$account->uid] = '';
$form['name'][$account->uid] = array(
'#value' => theme('username', $account),
);
$form['mail'][$account->uid] = array(
'#value' => $account->mail,
);
$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'),
);
if (module_exists('profile')) {
profile_load_profile($account);
}
foreach (advuser_profile_fields() as $field) {
$form[$field->name][$account->uid] = array(
'#value' => profile_view_field($account, $field),
);
}
if ($account->uid) {
$fv = l(t('edit'), "user/{$account->uid}/edit", array(
'query' => $destination,
));
if ($account->uid != 1) {
$fv .= ' | ' . l(t('delete'), "user/{$account->uid}/delete", array(
'query' => $destination,
));
}
}
else {
$fv = NULL;
}
$form['operations'][$account->uid] = array(
'#value' => $fv,
);
}
}
$form['accounts'] = array(
'#type' => 'checkboxes',
'#options' => $accounts,
);
$form['pager'] = array(
'#value' => theme('pager', NULL, 50, 0),
);
return $form;
}