function quotes_block_view in Quotes 7
Same name and namespace in other branches
- 6 quotes.module \quotes_block_view()
Implements hook_block_view().
File
- ./
quotes.module, line 988 - 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_block_view($delta) {
$quotes = '';
// TODO Rename block deltas (e.g., delta-0) to readable strings.
$block = db_select('quotes_blocks', 'qb')
->fields('qb')
->condition('qb.bid', $delta)
->execute()
->fetchAssoc();
if (!$block) {
return NULL;
}
if ($block['cron_interval'] > 0) {
if (!$block['vid'] || $block['cron_last'] + $block['cron_interval'] * $block['cron_step'] < REQUEST_TIME) {
$block['vid'] = quotes_get_quote($block, TRUE, 1);
db_update('quotes_blocks')
->fields(array(
'vid' => $block['vid'][0],
'cron_last' => REQUEST_TIME,
))
->condition('bid', $delta)
->execute();
cache_clear_all();
}
else {
$block['vid'] = array(
$block['vid'],
);
}
}
else {
$block['vid'] = quotes_get_quote($block, TRUE, $block['count']);
}
if (!$block['vid']) {
return NULL;
}
foreach ($block['vid'] as $nid) {
$nodes[] = node_load($nid);
}
$variables['block'] = $block;
$variables['nodes'] = $nodes;
theme_quotes_block($variables);
return $variables['block'];
}