You are here

function epub_read_page_callback in Epub 6

Determine whether the user has to create the ePub or can download it.

Parameters

$nid: An integer containing node id.

Return value

If the ePub exists, it send the corresponding file to the user else it redirects to the 'add ePub' page.

1 string reference to 'epub_read_page_callback'
epub_menu in ./epub.module
Implementation of hook_menu().

File

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

Code

function epub_read_page_callback($nid) {
  $node = node_load($nid);
  if ($node->type === 'book') {
    _epub_links_book($nid) ? epub_create_file($nid) : drupal_goto('node/add/epub');
  }
  elseif ($node->type === 'epub') {
    if (_epub_links_book($node->bid)) {
      epub_create_file($node->bid);
    }
    else {
      drupal_set_message(t('You have to link a book outline before you can download its ePub'), 'warning');
      drupal_goto("node/{$nid}/epub");
    }
  }
}