You are here

function hosting_quota_set_limit in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 quota/hosting_quota.module \hosting_quota_set_limit()
  2. 7.3 quota/hosting_quota.module \hosting_quota_set_limit()

Set the hosting quota for a given resource.

Parameters

$client: The nid of the client node.

$resource: The machine name of the resource.

$value: The new value for the resource.

2 calls to hosting_quota_set_limit()
hosting_quota_admin_defaults_form_submit in quota/hosting_quota.admin.inc
Submit function for hosting_quota_admin_defaults_form
hosting_quota_node_update in quota/hosting_quota.module
Implements hook_node_update().

File

quota/hosting_quota.module, line 175
Implement quota's for the resource used by client.

Code

function hosting_quota_set_limit($client, $resource, $value) {
  if (db_query("SELECT COUNT(*) FROM {hosting_client_quota} WHERE client = :client AND resource = :resource", array(
    ':client' => $client,
    ':resource' => $resource,
  ))
    ->fetchField()) {
    $id = db_update('hosting_client_quota')
      ->fields(array(
      'value' => $value,
    ))
      ->condition('client', $client)
      ->condition('resource', $resource)
      ->execute();
  }
  else {
    $id = db_insert('hosting_client_quota')
      ->fields(array(
      'client' => $client,
      'resource' => $resource,
      'value' => $value,
    ))
      ->execute();
  }
}