You are here

function purl_validate in Persistent URL 7

Same name and namespace in other branches
  1. 6 purl.module \purl_validate()

Validation for modifiers.

2 calls to purl_validate()
purl_form_validate in ./purl.module
Validation handler for purl_form().
purl_save in ./purl.module
Save modifier to database. Will insert new entry if no ID is provided and update an existing one otherwise.

File

./purl.module, line 543

Code

function purl_validate($modifier) {

  // Check that the value is valid
  if (check_plain($modifier['provider']) && !empty($modifier['value']) && preg_match('!^[\\.a-z0-9_-]+$!', $modifier['value']) && !menu_get_item($modifier['value'])) {
    $id = db_query("SELECT id FROM {purl} WHERE value = :value", array(
      ':value' => $modifier['value'],
    ))
      ->fetchField();
    if (!$id) {
      return TRUE;
    }
    else {
      if (isset($modifier['id']) && $id == $modifier['id']) {
        return TRUE;
      }
    }
  }
  return FALSE;
}