You are here

function hosting_alias_form_data in Hostmaster (Aegir) 6

Alter the node form for a site to add the aliases and redirection items.

Parameters

$form: The form to alter, should come from hook_form_alter().

1 call to hosting_alias_form_data()
hosting_alias_form_alter in modules/hosting/alias/hosting_alias.module
Implementation of hook_form_alter().

File

modules/hosting/alias/hosting_alias.module, line 67
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_form_data(&$form) {
  if (user_access('create site aliases')) {

    // List the automatic aliasses first.
    $aliases = hosting_alias_get_aliases($form['#node'], HOSTING_ALIAS_AUTOMATIC);
    if (sizeof($aliases)) {
      foreach ($aliases as $link) {
        $links[] = l($link, "http://{$link}");
      }
      $form['aliases_automatic'] = array(
        '#type' => 'item',
        '#title' => t('Automatic domain aliases'),
        '#value' => implode(', ', $links),
        '#weight' => 10,
      );
    }
    $form['aliases'] = array(
      '#type' => 'textarea',
      '#title' => t('Domain aliases'),
      '#description' => t('The site can also be accessed through these domain names, one per line.'),
      '#default_value' => implode("\n", (array) $form['#node']->aliases),
      '#weight' => 10,
    );
    $form['redirection'] = array(
      '#type' => 'checkbox',
      '#title' => t('Redirect domain aliases to main domain'),
      '#default_value' => isset($form['#node']->redirection) ? $form['#node']->redirection : variable_get('hosting_alias_redirection', FALSE),
      '#weight' => 11,
    );
    return $form;
  }
}