You are here

hosting_clone.module in Hostmaster (Aegir) 6

Allow sites to be cloned.

File

modules/hosting/clone/hosting_clone.module
View source
<?php

/**
 * @file
 *   Allow sites to be cloned.
 */

/**
 * Implementation of hook_hosting_tasks().
 */
function hosting_clone_hosting_tasks() {
  $options = array();
  $options['site']['clone'] = array(
    'title' => t('Clone'),
    'description' => t('Make a copy of a site.'),
    'weight' => 5,
    'dialog' => TRUE,
  );
  return $options;
}

/**
 * Implementation of hook_perm().
 */
function hosting_clone_perm() {
  return array(
    'create clone task',
  );
}

/**
 * Implementation of hook_hosting_task_TASK_TYPE_form_validate().
 */
function hosting_task_clone_form_validate($form, &$form_state) {
  $site = $form['parameters']['#node'];
  $url = strtolower(trim($form_state['values']['parameters']['new_uri']));

  // domain names are case-insensitive
  if ($url == strtolower(trim($site->title))) {
    form_set_error('new_uri', t("To clone a site you need to specify a new Domain name to clone it to."));
  }
  else {
    hosting_task_migrate_form_validate($form, $form_state);
  }
}

/**
 * Implementation of hook_theme().
 */
function hosting_clone_theme($existing, $type, $theme, $path) {
  return array(
    'hosting_task_clone_form' => array(
      'arguments' => array(
        'form' => NULL,
      ),
    ),
  );
}

/**
 * Implementation of hook_hosting_task_TASK_TYPE_form().
 */
function hosting_task_clone_form($node) {
  $form = hosting_task_migrate_form($node);
  $form['new_uri']['#description'] = t('The new domain name of the clone site.');
  return $form;
}

/**
 * Redner the clone task form.
 */
function theme_hosting_task_clone_form(&$form) {
  return theme_hosting_task_migrate_form($form);
}

Functions

Namesort descending Description
hosting_clone_hosting_tasks Implementation of hook_hosting_tasks().
hosting_clone_perm Implementation of hook_perm().
hosting_clone_theme Implementation of hook_theme().
hosting_task_clone_form Implementation of hook_hosting_task_TASK_TYPE_form().
hosting_task_clone_form_validate Implementation of hook_hosting_task_TASK_TYPE_form_validate().
theme_hosting_task_clone_form Redner the clone task form.