You are here

function hosting_client_validate_suggest in Hostmaster (Aegir) 6

Helper for hosting_client_validate to suggest a new client title.

Parameters

$node: The node being validated

See also

hosting_client_validate()

1 call to hosting_client_validate_suggest()
hosting_client_validate in modules/hosting/client/hosting_client.module
Implementation of hook_validate() .

File

modules/hosting/client/hosting_client.module, line 287

Code

function hosting_client_validate_suggest($node) {
  $suggestion = FALSE;
  for ($i = 0; $i < 10; $i++) {
    $nid = db_result(db_query("SELECT nid FROM {hosting_client} WHERE uname LIKE '%s%%'", addcslashes(hosting_client_sanitize($node->title) . $i, '\\%_')));
    if (!$nid) {
      $suggestion = $node->title . $i;
      break;
    }
  }
  return $suggestion;
}