You are here

function hosting_quota_admin_client_list in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 quota/hosting_quota.admin.inc \hosting_quota_admin_client_list()
  2. 7.3 quota/hosting_quota.admin.inc \hosting_quota_admin_client_list()

Page callback for admin/hosting/quotas

1 string reference to 'hosting_quota_admin_client_list'
hosting_quota_menu in quota/hosting_quota.module
Implements hook_menu().

File

quota/hosting_quota.admin.inc, line 11
hosting_quota.admin.inc Admin forms for the quota module.

Code

function hosting_quota_admin_client_list() {
  $items_per_page = 25;
  $all_resources = module_invoke_all('hosting_quota_resource');
  $result = db_select('hosting_client_quota', 'q');
  $result
    ->join('node', 'n', 'q.client = n.nid');
  $result
    ->fields('q')
    ->fields('n');
  $result = $result
    ->extend('PagerDefault')
    ->limit($items_per_page)
    ->execute();
  $output = array();
  while ($row = $result
    ->fetchObject()) {
    $resource = array(
      $row->resource => $all_resources[$row->resource],
    );

    // Pass in raw limit and usage
    $output[$row->client][$row->resource]['limit'] = $row->value;
    $output[$row->client][$row->resource]['usage'] = hosting_quota_get_usage($row->client, $resource);

    // Render limit and usage
    $output[$row->client][$row->resource]['rendered usage'] = hosting_quota_resource_render($resource, $output[$row->client][$row->resource]['usage']);
    $output[$row->client][$row->resource]['rendered limit'] = hosting_quota_resource_render($resource, $row->value);

    // Set client identifier
    $output[$row->client]['name'] = $row->title;
  }
  return theme('hosting_quota_admin_list', array(
    'client_quotas' => $output,
    'resources' => $all_resources,
    'items_per_page' => $items_per_page,
  ));
}