You are here

function epub_update in Epub 6

Implementation of hook_update().

File

./epub.module, line 186
Provide ePub content type and enable the creation of ePub files from book contents.

Code

function epub_update($node) {
  if ($node->revision) {
    epub_insert($node);
  }
  else {
    $result = db_query_range(db_rewrite_sql("SELECT b.nid FROM {node} AS n\n        INNER JOIN {book} AS b ON b.nid = n.nid\n        WHERE b.nid = b.bid AND n.title = '%s'"), $node->book_outline, 0, 1);
    $book = db_fetch_object($result);
    $result = db_query(db_rewrite_sql("UPDATE {epub} SET\n          bid = %d,\n          author_name = '%s',\n          language_code = '%s',\n          identifier = '%s',\n          identifier_type = '%s',\n          publisher_name = '%s',\n          publisher_site = '%s',\n          creation_date = '%s',\n          rights = '%s',\n          source_url = '%s'\n        WHERE vid = %d"), $book->nid, $node->author_name, $node->language_code, $node->identifier, $node->identifier_type, $node->publisher_name, $node->publisher_site, $node->creation_date, $node->rights, $node->source_url, $node->vid);
    if (!$result) {
      drupal_set_message(t('Error occurred while updating the ePub.'), 'error');

      //drupal_goto("node/$node->vid/epub");
    }
  }
}