function hosting_quota_get_all_info in Hosting 7.3
Same name and namespace in other branches
- 6.2 quota/hosting_quota.module \hosting_quota_get_all_info()
- 7.4 quota/hosting_quota.module \hosting_quota_get_all_info()
@todo Please document this function.
See also
1 call to hosting_quota_get_all_info()
- hosting_quota_node_load in quota/
hosting_quota.module - Implements hook_node_load().
File
- quota/
hosting_quota.module, line 261 - Implement quota's for the resource used by client.
Code
function hosting_quota_get_all_info($client, $start = NULL, $end = NULL) {
static $quota_info;
if (!isset($quota_info)) {
$quota_info = array();
// Set up some default dates for the last month if necessary
if (!$start || !$end) {
$end = date('Y-m-d', mktime(0, 0, 0, date("m"), 1, date("Y")));
$start = date('Y-m-d', mktime(0, 0, 0, date("m") - 1, 1, date("Y")));
}
$all_resources = module_invoke_all('hosting_quota_resource');
foreach ($all_resources as $resource_name => $resource_data) {
// First read in the info from the resource
$quota_info[$resource_name] = $resource_data;
// We have to format this way to to dependencies in quota imps
$resource = array(
$resource_name => $resource_data,
);
// Get usage info
$quota_info[$resource_name]['usage'] = hosting_quota_get_usage($client, $resource, $start, $end);
// Fetch info about the quota limit directly from the db
$quota_info[$resource_name]['limit'] = db_query('SELECT value FROM {hosting_client_quota} WHERE client = :client AND resource = :resource', array(
':client' => $client,
':resource' => $resource_name,
))
->fetchField();
// Render both limits and usage
$quota_info[$resource_name]['rendered usage'] = hosting_quota_resource_render($resource, $quota_info[$resource_name]['usage']);
$quota_info[$resource_name]['rendered limit'] = hosting_quota_resource_render($resource, $quota_info[$resource_name]['limit']);
}
}
return $quota_info;
}