function biblio_block in Bibliography Module 6
Same name and namespace in other branches
- 5 biblio.module \biblio_block()
- 6.2 biblio.module \biblio_block()
Implementation of hook_block().
Generates a block containing the latest poll.
File
- ./
biblio.module, line 1812
Code
function biblio_block($op = 'list', $delta = 0) {
global $user;
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');
if (variable_get('biblio_view_only_own', 0)) {
$limit .= " AND n.uid = {$user->uid} ";
}
// $query = "SELECT COUNT(n.nid)
// FROM {node} n
// WHERE n.type = 'biblio' AND n.status=1 " . $limit;
// $num_rows = db_result(db_query_range(db_rewrite_sql($query), 0, $num_in_block));
// if ($num_rows) {
$query = "SELECT n.nid, n.title\n FROM {node} n\n LEFT JOIN {biblio} b on n.vid=b.vid\n WHERE n.type = 'biblio' AND n.status=1 " . $limit . "ORDER BY {$block_order} DESC";
$result = db_query_range(db_rewrite_sql($query), 0, $num_in_block);
$base = variable_get('biblio_base', 'biblio');
$block['subject'] = t('Recent Publications');
$block['content'] = '<div class="item-list"><ul>';
$options['html'] = TRUE;
while ($pub = db_fetch_object($result)) {
if (variable_get('biblio_hide_bibtex_braces', 0)) {
$pub->title = biblio_remove_brace($pub->title);
}
$block['content'] .= '<li >' . l(filter_xss($pub->title, biblio_get_allowed_tags()), "node/{$pub->nid}", $options) . '</li>';
}
$block['content'] .= '</ul>';
if (variable_get('biblio_rss', 0)) {
$block['content'] .= theme('feed_icon', url("{$base}/recent/rss.xml", array(
'absolute' => TRUE,
)), t('Recently Added Publications'));
}
$block['content'] .= l(t('More...'), $base);
$block['content'] .= '</div>';
// }
return $block;
}
}
}
}