function hosting_quota_form_alter in Hosting 7.3
Same name and namespace in other branches
- 6.2 quota/hosting_quota.module \hosting_quota_form_alter()
- 7.4 quota/hosting_quota.module \hosting_quota_form_alter()
Insert edit controls for the hosting quotas into the client edit form
File
- quota/
hosting_quota.module, line 360 - Implement quota's for the resource used by client.
Code
function hosting_quota_form_alter(&$form, &$form_state, $form_id) {
if (user_access('edit all quotas') && isset($form['type']) && isset($form['#node']) && 'client_node_form' == $form_id) {
$node = $form['#node'];
if (!isset($node->quota)) {
$quota_info = module_invoke_all('hosting_quota_resource');
}
else {
$quota_info = $node->quota;
}
$form['quota'] = array(
'#type' => 'fieldset',
'#title' => t('Client quota settings'),
'#access' => user_access('edit all quotas'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($quota_info as $resource => $quota) {
if (!isset($quota['limit'])) {
$quota['limit'] = variable_get("hosting_quota_default_{$resource}", 0);
}
$form['quota']['quota-' . $resource] = array(
'#title' => check_plain($quota['title']),
'#description' => check_plain($quota['description']),
'#type' => 'textfield',
'#default_value' => $quota ? $quota['limit'] : 0,
);
// Validate that a number was submitted for the quota
$form['#validate'][] = 'hosting_quota_numeric_value';
}
}
}