There's a simple code mistake inside og_aggregator_block(). You check for a group context, but still return data if that returns false, because the IF ends early.
Below is how it should be.
function og_aggregator_block($op, $delta = 0, $edit = array()) {
/* TODO
Please manually fix the parameters on the l() or url() function on the next line.
Typically, this was not changed because of a function call inside an array call like
array('title' => t('View user profile.')).*/
if (user_access('access og_aggregator')) {
if ($op == 'list') {
$blocks[0]['info'] = t('Group aggregator');
return $blocks;
}
else if ($op == 'configure') {
$form['og_aggregator_block_items_number'] = array('#type' => 'select', '#title' => t('Number of news items in block'), '#default_value' => variable_get('og_aggregator_block_items_number',10), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
return $form;
}
else if ($op == 'save') {
variable_set('og_aggregator_block_items_number', $edit['og_aggregator_block_items_number']);
}
else if ($op == 'view') {
if ($groupnode = og_get_group_context()) {
$block['subject'] = t('Aggregator');
$result = db_query_range("SELECT i.* FROM {og_aggregator_item} i JOIN {og_aggregator_feed} f ON i.fid = f.fid WHERE f.nid = %d ORDER BY i.timestamp desc", $groupnode->nid, 0, variable_get('og_aggregator_block_items_number',10));
$block['content'] = '<div class="more-link">'.
l(t('more'), "node/$groupnode->nid/aggregator/feed", array('title' => t('View this feed\'s recent news.'))) .'</div>';
$items = array();
while ($item = db_fetch_object($result)) {
$items[] = theme('og_aggregator_block_item', $item);
}
$block['content'] = theme('item_list', $items) . $block['content'];
return $block;
}
}
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | og_aggregator-fix-context-check-768958.patch | 1.29 KB | mstef |
| #2 | og_aggregator-fix-context-check.patch | 1.11 KB | mstef |
Comments
Comment #1
derekwebb1 commentedChanging this line:
$block['content'] = theme('item_list', $items) . $block['content'];To this:
$block['content'] = ($items) ? theme('item_list', $items) . $block['content'] : false;Also fixes the issue...
Cheers, Derek
Comment #2
mstef commentedPatch
Comment #3
rootworkThis works for me. Can we get it into a new version, or (if only one review isn't sufficient) at least a new dev?
Comment #4
Taz commentedIf anyone wants to rollup these few bugs into one single patch i'll commit it tonight to a new release.
Comment #5
mstef commentedUpdated patch so that the block doesn't return if there aren't any aggregator items either.
Comment #6
rootworkLove it! Please let's get some more reviews so we can move this into dev and/or a new version.
Comment #7
ezra-g commentedLooking at http://drupalcode.org/project/og_aggregator.git/blob/refs/heads/6.x-1.x:... it seems like the patch from #5 has been committed.