You are here

function hosting_task_migrate_form_validate in Hosting 6.2

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

Implementation of 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
Implementation of 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 70

Code

function hosting_task_migrate_form_validate($form, &$form_state) {
  $migrate_possible = false;
  $site = $form['parameters']['#node'];
  $url = strtolower(trim($form_state['values']['parameters']['new_uri']));

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