You are here

function purl_save in Persistent URL 6

Same name and namespace in other branches
  1. 7 purl.module \purl_save()

Save modifier to database. Will insert new entry if no ID is provided and update an existing one otherwise.

File

./purl.module, line 582

Code

function purl_save($modifier) {
  if (purl_validate($modifier)) {
    $id = db_result(db_query("SELECT id FROM {purl} WHERE id = '%s' AND provider = '%s'", $modifier['id'], $modifier['provider']));
    if (!empty($id)) {
      $status = drupal_write_record('purl', $modifier, array(
        'provider',
        'id',
      ));
    }
    else {
      $status = drupal_write_record('purl', $modifier);
    }
    purl_load(NULL, TRUE);
    purl_modifiers(NULL, TRUE);
    return $status;
  }
  return FALSE;
}