You are here

function purl_validate in Persistent URL 6

Same name and namespace in other branches
  1. 7 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 565

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_result(db_query("SELECT id FROM {purl} WHERE value = '%s'", $modifier['value']));
    if (!$id) {
      return true;
    }
    else {
      if (isset($modifier['id']) && $id == $modifier['id']) {
        return true;
      }
    }
  }
  return false;
}