You are here

function total_control_get_user_overview in Total Control Admin Dashboard 6.2

Same name and namespace in other branches
  1. 7.2 includes/total_control.inc \total_control_get_user_overview()

Retrieves overview data for all users on the site.

Parameters

$conf: Panel content pane config data.

Return value

$items An array of items for a bulleted list.

2 calls to total_control_get_user_overview()
total_control_overview_content_type_render in plugins/content_types/overview.inc
Run-time rendering of the body of the block.
total_control_overview_user_content_type_render in plugins/content_types/overview_user.inc
Run-time rendering of the body of the block.

File

includes/total_control.inc, line 464
total_control.inc

Code

function total_control_get_user_overview($conf = array()) {
  $items = array();

  // Compare against user option on pane config.
  if (!$conf['user'] || $conf['user'] == 1) {
    $user_query = db_query("SELECT count(*) FROM {users}");
    $total['users_all'] = format_plural(db_result($user_query), '1 total user', '@count total users');
    $user_active_query = db_query("SELECT count(*) FROM {users} WHERE status = 1 AND login <> 0");
    $total['users_active'] = format_plural(db_result($user_active_query), '1 active user', '@count active users');
    $user_block_query = db_query("SELECT count(*) FROM {users} WHERE status = 0");
    $total['users_block'] = format_plural(db_result($user_block_query), '1 blocked user', '@count blocked users');
    $items[] = $total['users_all'];
    $items[] = $total['users_active'];
    $items[] = $total['users_block'];
  }

  // Roles Overview
  $roles = user_roles(TRUE);
  $total['users_roles'] = '';
  foreach ($roles as $rid => $role) {

    // Compare against roles option on pane config.
    if ((!$conf['roles'] || $conf['roles'][$rid]) && $rid != 2) {
      $user_role_query = db_query("SELECT count(*) FROM {users} u INNER JOIN {users_roles} r on u.uid = r.uid WHERE r.rid = %d", $rid);
      $total['users_role_' . $rid] .= format_plural(db_result($user_role_query), '1 user', '@count users');
      $total['users_role_' . $rid] .= ' in role: ' . $role;
      $items[] = $total['users_role_' . $rid];
    }

    // if not auth
  }

  // foreach
  return $items;
}