hosting_clone.module

Allow sites to be cloned.

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.

File

clone/hosting_clone.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Allow sites to be cloned.
  5. */
  6. /**
  7. * Implements hook_hosting_tasks().
  8. */
  9. function hosting_clone_hosting_tasks() {
  10. $options = array();
  11. $options['site']['clone'] = array(
  12. 'title' => t('Clone'),
  13. 'description' => t('Make a copy of a site.'),
  14. 'weight' => 5,
  15. 'dialog' => TRUE,
  16. );
  17. return $options;
  18. }
  19. /**
  20. * Implements hook_permission().
  21. */
  22. function hosting_clone_permission() {
  23. return array(
  24. 'create clone task' => array(
  25. 'title' => t('create clone task'),
  26. ),
  27. );
  28. }
  29. /**
  30. * Implements hook_hosting_task_TASK_TYPE_form_validate().
  31. */
  32. function hosting_task_clone_form_validate($form, &$form_state) {
  33. $site = $form['parameters']['#node'];
  34. $url = strtolower(trim($form_state['values']['parameters']['new_uri'])); // domain names are case-insensitive
  35. if ($url == strtolower(trim($site->title))) {
  36. form_set_error('new_uri', t("To clone a site you need to specify a new Domain name to clone it to."));
  37. }
  38. else {
  39. hosting_task_migrate_form_validate($form, $form_state);
  40. }
  41. }
  42. /**
  43. * Implements hook_theme().
  44. */
  45. function hosting_clone_theme($existing, $type, $theme, $path) {
  46. return array('hosting_task_clone_form' => array('render element' => 'form'));
  47. }
  48. /**
  49. * Implements hook_hosting_task_TASK_TYPE_form().
  50. */
  51. function hosting_task_clone_form($node) {
  52. $form = hosting_task_migrate_form($node);
  53. $form['new_uri']['#description'] = t('The new domain name of the clone site.');
  54. return $form;
  55. }
  56. /**
  57. * Render the clone task form.
  58. */
  59. function theme_hosting_task_clone_form($variables) {
  60. $form = $variables['form'];
  61. return theme_hosting_task_migrate_form($form);
  62. }