You are here

function hosting_client_form in Hosting 6.2

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

Implementation of hook_form().

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

File

client/hosting_client.module, line 148

Code

function hosting_client_form(&$node) {
  $type = node_get_types('type', 'client');
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => $type->title_label,
    '#required' => TRUE,
    '#size' => 40,
    '#default_value' => $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' => 'textfield',
    '#title' => t('Internal name'),
    '#size' => MAX_GROUP_LENGTH,
    '#maxlength' => MAX_GROUP_LENGTH,
    '#default_value' => $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'),
    )),
  );
  if (!$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' => $node->email,
      '#maxlength' => 100,
    );
    $form['email_confirm'] = array(
      '#type' => 'textfield',
      '#title' => t('Confirm Email address'),
      '#required' => FALSE,
      '#size' => 40,
      '#maxlength' => 100,
    );
  }
  if ($node->nid) {
    $users = hosting_client_users($node);
    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' => $user->name,
    );
  }
  return $form;
}