You are here

function purl_save in Persistent URL 7

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

Code

function purl_save($modifier) {
  if (purl_validate($modifier)) {
    $id = db_query("SELECT id FROM {purl} WHERE id = :id AND provider = :provider", array(
      ':id' => $modifier['id'],
      ':provider' => $modifier['provider'],
    ))
      ->fetchField();
    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;
}