You are here

hosting_clone.module in Hosting 6.2

Same filename and directory in other branches
  1. 7.4 clone/hosting_clone.module
  2. 7.3 clone/hosting_clone.module

Allow sites to be cloned.

File

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;
}

/**
 * Render 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 Render the clone task form.