You are here

function theme_advuser_admin_account in Advanced User 6.2

Same name and namespace in other branches
  1. 5.2 advuser.module \theme_advuser_admin_account()
  2. 6.3 forms/advuser_admin_account.inc \theme_advuser_admin_account()

Theme user administration overview.

File

./advuser.module, line 206
Advanced user module allows you to select users based on an advanced set of filtering and apply actions to block, unblock, delete or email the selected users.

Code

function theme_advuser_admin_account($form) {
  static $profile_fields = array();

  // Overview table:
  $header = array(
    theme('table_select_header_cell'),
    array(
      'data' => t('Username'),
      'field' => 'u.name',
    ),
    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');
  $output = drupal_render($form['options']);
  if (isset($form['name']) && is_array($form['name'])) {
    foreach (element_children($form['name']) as $key) {
      $row = array(
        drupal_render($form['accounts'][$key]),
        drupal_render($form['name'][$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' => '7',
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  if ($form['pager']['#value']) {
    $output .= drupal_render($form['pager']);
  }
  $output .= drupal_render($form);
  return $output;
}