You are here

function hosting_form_alter in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 hosting.module \hosting_form_alter()
  2. 7.3 hosting.module \hosting_form_alter()

Implementation of hook_form_alter().

File

./hosting.module, line 772
Hosting module.

Code

function hosting_form_alter(&$form, &$form_state, $form_id) {

  // Do not allow package or task nodes to be edited through the interface.
  if ($form_id == 'package_node_form' || $form_id == 'task_node_form') {
    drupal_access_denied();
    exit;
  }

  // Alter the 'Add User' form to remind users that this is not the New Client form
  if ($form_id == 'user_register') {
    $form[user_registration_help] = array(
      '#type' => 'item',
      '#description' => t('<strong>Adding a system user account does not make the user a Client that can add sites.</strong><br />
                     To add a Client, enable the Client feature and then add a new Client node.<br />
                     If you wish, you may then assign this system user to the Client as an \'Allowed user\' to inherit the permissions to add sites.'),
      '#weight' => '-10',
    );
  }

  // Remove additional UI added by core modules, that conflict with the hosting UI.
  $node_types = array(
    'site',
    'platform',
    'server',
    'client',
  );
  foreach ($node_types as $type) {
    if ($form_id == $type . '_node_form') {
      $form['options']['#access'] = FALSE;
      $form['menu']['#access'] = FALSE;
      $form['revision_information']['#access'] = FALSE;
      $form['author']['#access'] = FALSE;
      $form['comment_settings']['#access'] = FALSE;

      // because these aren't really posts, 'preview' doesnt make sense in this context.
      $form['buttons']['preview']['#access'] = FALSE;

      // Add message that verify is required for changes to take effect.
      if (in_array($type, array(
        'site',
        'platform',
        'server',
      ))) {
        $form['#submit'][] = 'hosting_form_verify_reqd_submit';
      }
    }
  }
}