You are here

function hosting_platform_validate in Hosting 6.2

Same name and namespace in other branches
  1. 5 platform/hosting_platform.module \hosting_platform_validate()
  2. 7.4 platform/hosting_platform.module \hosting_platform_validate()
  3. 7.3 platform/hosting_platform.module \hosting_platform_validate()

Implementation of hook_validate().

File

platform/hosting_platform.module, line 448
Platform node type definition.

Code

function hosting_platform_validate($node, &$form) {

  // Make sure the platform name is unique, to avoid context clashes.
  if ($node->op != t('Delete') && ($result = db_fetch_object(db_query("SELECT n.title AS name FROM {hosting_platform} AS h INNER JOIN {node} AS n ON n.nid = h.nid WHERE n.title = '%s' AND n.nid <> %d AND h.status >= %d", $node->title, $node->nid, HOSTING_PLATFORM_QUEUED)))) {
    form_set_error('title', t('Platform name %name is already defined. Platform names must be unique across all servers.', array(
      '%name' => $result->name,
    )));
  }

  // Make sure the path is unique. Remote servers can't have the same path to a platform that is in use by another server.
  if ($node->op != t('Delete') && ($result = db_fetch_object(db_query("SELECT n.title AS name FROM {hosting_platform} AS h INNER JOIN {node} AS n ON n.nid = h.nid WHERE publish_path = '%s' AND n.nid <> %d AND h.status >= %d", hosting_path_normalize($node->publish_path), $node->nid, HOSTING_PLATFORM_QUEUED)))) {
    form_set_error('publish_path', t('Path is already in use by platform %name. Platform paths must be unique across all servers.', array(
      '%name' => $result->name,
    )));
  }
  if (is_null($node->web_server)) {
    form_set_error('web_server', t('Platform needs to be associated with a webserver. Make sure you have a verified webserver on this Aegir install!'));
  }
}