You are here

function quotes_delete in Quotes 7

Same name and namespace in other branches
  1. 5 quotes.module \quotes_delete()
  2. 6 quotes.module \quotes_delete()

Implements hook_delete().

File

./quotes.module, line 645
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_delete($node) {

  // Check if author is present, if so continue.
  if (isset($node->quotes_author)) {
    $aid = _quotes_handle_author();

    // If this is the last quote using this author, then delete the author too.
    $aid_count = db_query("SELECT COUNT(q.nid) FROM {quotes} q WHERE q.aid=:q_aid", array(
      ":q_aid" => $aid,
    ))
      ->fetchField();
    if ($aid_count === 1) {
      db_query("DELETE FROM {quotes_authors} WHERE aid= :q_aid", array(
        ":q_aid" => $aid,
      ));
    }
  }

  // Now delete the quote from the quotes table.
  db_query('DELETE FROM {quotes} WHERE nid = :q_nid', array(
    ':q_nid' => $node->nid,
  ));
}