You are here

hosting_clone.module in Hosting 7.4

Same filename and directory in other branches
  1. 6.2 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.
 */

/**
 * Implements 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;
}

/**
 * Implements hook_permission().
 */
function hosting_clone_permission() {
  return array(
    'create clone task' => array(
      'title' => t('create clone task'),
    ),
  );
}

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

  // domain names are case-insensitive
  if ($url == hosting_site_get_domain($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);
  }
}

/**
 * Implements hook_theme().
 */
function hosting_clone_theme($existing, $type, $theme, $path) {
  return array(
    'hosting_task_clone_form' => array(
      'render element' => 'form',
    ),
  );
}

/**
 * Implements 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($variables) {
  $form = $variables['form'];
  return theme_hosting_task_migrate_form($form);
}

Functions

Namesort descending Description
hosting_clone_hosting_tasks Implements hook_hosting_tasks().
hosting_clone_permission Implements hook_permission().
hosting_clone_theme Implements hook_theme().
hosting_task_clone_form Implements hook_hosting_task_TASK_TYPE_form().
hosting_task_clone_form_validate Implements hook_hosting_task_TASK_TYPE_form_validate().
theme_hosting_task_clone_form Render the clone task form.