function hosting_client_form_site_node_form_alter in Hosting 7.3
Same name and namespace in other branches
- 7.4 client/hosting_client.module \hosting_client_form_site_node_form_alter()
Implements hook_form_FORM_ID_alter().
File
- client/
hosting_client.module, line 382
Code
function hosting_client_form_site_node_form_alter(&$form, &$form_state, $form_id) {
global $user;
$node = $form['#node'];
$client_ids = hosting_get_client_from_user($user->uid);
if (empty($client_ids) && !user_access('administer clients') && variable_get('hosting_client_require_client_to_create_site', FALSE)) {
form_set_error('client', t('Your user is not associated with any clients so you are not allowed to create new sites'));
$form['#access'] = 0;
return $form;
}
$editable = (!isset($node->client) || !isset($node->nid) || user_access('administer sites')) && hosting_feature('client');
$add_client_text = '';
if (user_access('administer clients') || user_access('create client')) {
$add_client_text = t('Click !here to add a new client.', array(
'!here' => l(t('here'), 'node/add/client', array(
'attributes' => array(
'target' => '_blank',
),
)),
));
}
_hosting_site_field($form, $node, 'client', array(
'#type' => 'textfield',
'#required' => TRUE,
'#title' => t('Client'),
'#default_value' => _hosting_client_site_default($node),
'#description' => t('The client to whom this site belongs.') . ' ' . $add_client_text,
'#autocomplete_path' => 'hosting_client/autocomplete/client',
), 'filter_xss', $editable);
}