You are here

function total_control_get_user_overview in Total Control Admin Dashboard 7.2

Same name and namespace in other branches
  1. 6.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 A structured array of items containing user data, in the following format: $items = array( 'all' => 16, 'active' => 9, 'blocked' => 2, 'roles' => array( 3 => array( 'name' => 'Administrator', 'count' => 4, ), ), );

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 418
Helper functions for total control.

Code

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

  // User Overview
  if (!$conf['user'] || $conf['user'] == 1) {
    $items['all'] = db_query("SELECT count(*) FROM {users}")
      ->fetchField();
    $items['active'] = db_query("SELECT count(*) FROM {users} WHERE status = 1 AND login <> 0")
      ->fetchField();
    $items['blocked'] = db_query("SELECT count(*) FROM {users} WHERE status = 0")
      ->fetchField();
  }

  // Roles Overview
  $roles = user_roles(TRUE);
  $items['roles'] = array();
  foreach ($roles as $rid => $role) {
    if ($rid != 2 && (array_key_exists($rid, $conf['roles']) && $conf['roles'][$rid])) {
      $user_role_count = db_query("SELECT count(*) FROM {users} u INNER JOIN {users_roles} r on u.uid = r.uid WHERE r.rid = :rid", array(
        ':rid' => $rid,
      ))
        ->fetchField();
      $items['roles'][$rid] = array();
      $items['roles'][$rid]['name'] = $role;
      $items['roles'][$rid]['count'] = $user_role_count;
    }
  }
  return $items;
}