You are here

function biblio_block in Bibliography Module 5

Same name and namespace in other branches
  1. 6.2 biblio.module \biblio_block()
  2. 6 biblio.module \biblio_block()

Implementation of hook_block().

Generates a block containing the latest poll.

File

./biblio.module, line 1919

Code

function biblio_block($op = 'list', $delta = 0) {
  if (user_access('access content')) {
    if ($op == 'list') {
      $blocks[0]['info'] = t('Most recent publications');
      return $blocks;
    }
    else {
      if ($op == 'view') {

        // Retrieve the latest pubs
        $num_in_block = variable_get('biblio_rowsperblock', 4);
        $block_order = variable_get('biblio_block_order', 'n.created');
        $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.status, b.biblio_year FROM {node} n left join {biblio} b  on n.vid=b.vid WHERE n.type = 'biblio' AND n.status=1 ORDER BY {$block_order} DESC"), 0, $num_in_block);
        if (db_num_rows($result)) {
          $base = variable_get('biblio_base', 'biblio');
          $block['subject'] = t('New Publications');
          $block['content'] .= '<div class="item-list"><ul>';
          while ($pub = db_fetch_object($result)) {
            $block['content'] .= '<li >' . l("{$pub->title}", "node/{$pub->nid}") . '</li>';
          }
          $block['content'] .= '</ul>';
          if (variable_get('biblio_rss', 0)) {
            $block['content'] .= theme('feed_icon', url("{$base}/rss.xml"));
          }
          $block['content'] .= '</div>';
        }
        return $block;
      }
    }
  }
}