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;
      }
    }
  }
}

Comments

derekwebb1’s picture

Changing 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

mstef’s picture

StatusFileSize
new1.11 KB

Patch

rootwork’s picture

This works for me. Can we get it into a new version, or (if only one review isn't sufficient) at least a new dev?

Taz’s picture

If anyone wants to rollup these few bugs into one single patch i'll commit it tonight to a new release.

mstef’s picture

Updated patch so that the block doesn't return if there aren't any aggregator items either.

rootwork’s picture

Version: 6.x-1.4 » 6.x-1.x-dev

Love it! Please let's get some more reviews so we can move this into dev and/or a new version.

ezra-g’s picture

Status: Needs review » Fixed

Looking 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.