You are here

function theme_advuser_admin_account in Advanced User 6.3

Same name and namespace in other branches
  1. 5.2 advuser.module \theme_advuser_admin_account()
  2. 6.2 advuser.module \theme_advuser_admin_account()

Theme user administration overview.

File

forms/advuser_admin_account.inc, line 231
This is the part of the form that provides the actions and the list based on the selected filters.

Code

function theme_advuser_admin_account($form) {
  static $profile_fields = array();
  $advuser =& $_SESSION['advuser'];
  $accounts =& $advuser['accounts'];
  $selectall =& $advuser['selectall'];
  $deselected =& $advuser['deselected'];

  // Overview table:
  $header = array(
    theme('table_select_header_cell'),
    array(
      'data' => t('Username'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Mail'),
      'field' => 'u.mail',
    ),
    array(
      'data' => t('Status'),
      'field' => 'u.status',
    ),
  );
  $roles = advuser_user_roles();
  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',
    ),
  ));
  $ff = array();
  foreach (advuser_profile_fields() as $field) {
    $ff[] = array(
      'data' => t($field->title),
      'field' => $field->name,
    );
  }
  $header = array_merge($header, $ff);
  $header[] = t('Operations');
  if (!count($accounts) && !$selectall) {
    $form['options']['noselectedusers'] = array(
      '#value' => t('No selected users have been saved.'),
      '#prefix' => '<span class="error">',
      '#suffix' => '</span>',
    );
  }
  $output = drupal_render($form['options']);
  if (isset($form['name']) && is_array($form['name'])) {
    foreach (element_children($form['name']) as $key) {
      if (($selectall || in_array($key, $accounts)) && !in_array($key, $deselected)) {
        $form['accounts'][$key]['#value'] = TRUE;
      }
      $row = array(
        drupal_render($form['accounts'][$key]),
        drupal_render($form['name'][$key]),
        drupal_render($form['mail'][$key]),
        drupal_render($form['status'][$key]),
      );
      $roles = advuser_user_roles();
      if (count($roles)) {
        $row[] = drupal_render($form['roles'][$key]);
      }
      $row = array_merge($row, array(
        drupal_render($form['member_for'][$key]),
        drupal_render($form['last_access'][$key]),
      ));
      if (module_exists('profile')) {
        $fields = variable_get('advuser_profile_fields', NULL);
        if (is_array($fields)) {
          foreach ($fields as $fid => $value) {
            if ($value) {
              if (empty($profile_fields[$fid])) {
                $field = db_fetch_object(db_query('SELECT * FROM {profile_fields} WHERE fid = %d', $fid));
                $profile_fields[$fid] = $field;
              }
              else {
                $field = $profile_fields[$fid];
              }
              $row[] = drupal_render($form[$field->name][$key]);
            }
          }
        }
      }
      $row[] = drupal_render($form['operations'][$key]);
      $rows[] = $row;
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('No users available.'),
        'colspan' => '8',
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $form['caution'] = array(
    '#value' => t('Caution, you must "Save selection criteria" to apply other actions to the selected users or before changing pages.'),
    '#prefix' => '<div class="warning">',
    '#suffix' => '</div>',
  );
  $output .= drupal_render($form['caution']);
  if ($form['pager']['#value']) {
    $output .= drupal_render($form['pager']);
  }
  $output .= drupal_render($form);
  return $output;
}