You are here

function hosting_task_migrate_form_validate in Hosting 7.3

Same name and namespace in other branches
  1. 5 migrate/hosting_migrate.module \hosting_task_migrate_form_validate()
  2. 6.2 migrate/hosting_migrate.module \hosting_task_migrate_form_validate()
  3. 7.4 migrate/hosting_migrate.module \hosting_task_migrate_form_validate()

Implements hook_validate().

A site may be migrated if it's URL, Platform or DB server has changed. Only one of these needs to change for a valid migration to be possible.

2 calls to hosting_task_migrate_form_validate()
hosting_task_clone_form_validate in clone/hosting_clone.module
Implements hook_hosting_task_TASK_TYPE_form_validate().
hosting_task_TASK_TYPE_form_validate in task/hosting_task.api.php
Validate the form data defined in hosting_task_TASK_TYPE_form().

File

migrate/hosting_migrate.module, line 72

Code

function hosting_task_migrate_form_validate($form, &$form_state) {
  $migrate_possible = FALSE;
  $site = $form['parameters']['#node'];
  $url = hosting_site_get_domain($form_state['values']['parameters']['new_uri']);
  if ($url != hosting_site_get_domain($site->title)) {
    $migrate_possible = TRUE;
    if (!_hosting_valid_fqdn($url)) {
      form_set_error('title', t("You have not specified a valid url for this site."));
    }
    if (!hosting_domain_allowed($url)) {
      form_set_error('title', t("The domain name you have specified is not unique or not allowed."));
    }
  }
  if (!isset($form_state['values']['parameters']['target_platform'])) {
    form_set_error('parameters][target_platform', t("You have no target platform specified."));
  }
  if ($form_state['values']['parameters']['target_platform'] != $site->platform) {
    $migrate_possible = TRUE;
  }
  if ($form_state['values']['parameters']['new_db_server'] != $site->db_server) {
    $migrate_possible = TRUE;
  }
  if (!$migrate_possible) {
    form_set_error('parameters][target_platform', t("To migrate a site you need to modify at least one of the following fields: Domain name, Platform or Database server"));
  }
}