You are here

function hosting_client_form in Hosting 5

Same name and namespace in other branches
  1. 6.2 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
Remote form definition

File

client/hosting_client.module, line 97

Code

function hosting_client_form(&$node) {
  $type = node_get_types('type', $node);
  $form['title'] = array(
    '#type' => 'hidden',
    '#value' => $node->title,
  );
  $form['email'] = array(
    '#type' => 'textfield',
    '#title' => t('Email address'),
    '#required' => TRUE,
    '#size' => 40,
    '#default_value' => $node->email,
    '#maxlength' => 100,
  );
  if (!$node->nid) {
    $form['email_confirm'] = array(
      '#type' => 'textfield',
      '#title' => t('Confirm Email address'),
      '#required' => TRUE,
      '#size' => 40,
      '#maxlength' => 100,
    );
  }
  $form['client_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Contact name'),
    '#size' => 40,
    '#default_value' => $node->client_name,
    '#maxlength' => 50,
  );
  $form['organization'] = array(
    '#type' => 'textfield',
    '#title' => t('Organization'),
    '#size' => 40,
    '#default_value' => $node->organization,
    '#maxlength' => 100,
  );
  if ($node->nid) {

    // this should probably be factored out in a common function
    $q = db_query("SELECT u.uid, u.name FROM {hosting_client_user} h INNER JOIN {users} u ON u.uid = h.user WHERE h.client = %d", $node->nid);
    while ($result = db_fetch_array($q)) {
      $form['user_edit']['name'][$result['uid']] = array(
        '#type' => 'markup',
        '#value' => l($result['name'], 'user/' . $result['uid']),
      );
      $users[$result['uid']] = '';
    }
    if (user_access('edit client users')) {
      $form['user_edit']['users'] = array(
        '#type' => 'checkboxes',
        '#options' => $users,
      );
    }
    $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('Add new user'),
        '#weigth' => 2,
        '#autocomplete_path' => 'user/autocomplete',
      );
    }
    $form['user_edit']['#theme'] = 'hosting_client_form';
  }
  else {
    global $user;
    $form['new_user'] = array(
      '#type' => 'value',
      '#value' => $user->name,
    );
  }
  return $form;
}