You are here

function hosting_client_form in Hosting 7.3

Same name and namespace in other branches
  1. 5 client/hosting_client.module \hosting_client_form()
  2. 6.2 client/hosting_client.module \hosting_client_form()
  3. 7.4 client/hosting_client.module \hosting_client_form()

Implements hook_form().

1 call to hosting_client_form()
hosting_signup_form in signup/hosting_signup.module
Form definition

File

client/hosting_client.module, line 188

Code

function hosting_client_form(&$node, &$form_state) {
  $type = node_type_get_type('client');
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#required' => TRUE,
    '#size' => 40,
    '#default_value' => isset($node->title) ? $node->title : '',
    '#maxlength' => 100,
    '#description' => t('The name of this client, generally the organization name or the contact name for individuals.'),
  );
  $form['uname'] = array(
    '#type' => 'machine_name',
    '#title' => t('Internal name'),
    '#size' => HOSTING_CLIENT_MAX_GROUP_LENGTH,
    '#maxlength' => HOSTING_CLIENT_MAX_GROUP_LENGTH,
    '#default_value' => isset($node->uname) ? $node->uname : '',
    '#access' => user_access('edit client uname'),
    '#description' => t('A machine-usable name that can be used internally, for example to map to a UNIX group in the backend. It is unique accross the system. If no value is provided, it is deduced from the client name, by stripping spaces and metacharacters and adding a prefix (%prefix).', array(
      '%prefix' => variable_get('hosting_client_prefix', 'no prefix define'),
    )),
    '#machine_name' => array(
      'exists' => 'hosting_get_client_by_uname',
      'source' => array(
        'title',
      ),
      'label' => t('Internal name'),
      'replace_pattern' => '[^a-z0-9_-]+',
      'replace' => '_',
    ),
  );
  if (!isset($node->nid) && variable_get('hosting_client_register_user', FALSE)) {
    $form['email'] = array(
      '#type' => 'textfield',
      '#title' => t('Email address'),
      '#description' => t('Email address of the contact created with this client. Optional - if none is provided, no user will be created with this client.'),
      '#required' => FALSE,
      '#size' => 40,
      '#default_value' => isset($node->email) ? $node->email : '',
      '#maxlength' => 100,
    );
    $form['email_confirm'] = array(
      '#type' => 'textfield',
      '#title' => t('Confirm Email address'),
      '#required' => FALSE,
      '#size' => 40,
      '#maxlength' => 100,
    );
  }
  if (isset($node->nid)) {
    $users = hosting_client_users($node);
    $user_list = array();
    foreach ($users as $uid => $uname) {
      $form['user_edit']['name'][$uid] = array(
        '#type' => 'markup',
        '#value' => l($uname, 'user/' . $uid),
      );
      $user_list[$uid] = '';
    }
    if (user_access('edit client users')) {
      $form['user_edit']['users'] = array(
        '#type' => 'checkboxes',
        '#options' => $user_list,
      );
    }
    $form['user_edit']['header'] = array(
      '#type' => 'value',
      '#value' => array(
        array(
          'data' => t('Allowed users'),
        ),
        array(
          'data' => t('Remove'),
        ),
      ),
    );
    if (user_access('edit client users')) {
      $form['user_edit']['new_user'] = array(
        '#type' => 'textfield',
        '#title' => t('Associate a user to this Client'),
        '#weight' => 2,
        '#autocomplete_path' => 'user/autocomplete',
        '#description' => t('This field allows you to associate an existing system user to this Client.
                             It does not create a new system user, but allows an existing user
                             to manage sites belonging to the Client.'),
      );
    }
    $form['user_edit']['#theme'] = 'hosting_client_form';
  }
  else {
    global $user;
    $form['new_user'] = array(
      '#type' => 'value',
      '#value' => isset($user->name) ? $user->name : '',
    );
  }
  return $form;

  // @ignore security_fapi_markup
}