? aggregator-398556.patch Index: aggregator.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.admin.inc,v retrieving revision 1.54 diff -u -p -r1.54 aggregator.admin.inc --- aggregator.admin.inc 26 Jun 2010 19:55:47 -0000 1.54 +++ aggregator.admin.inc 7 Jan 2011 22:37:06 -0000 @@ -84,11 +84,11 @@ function aggregator_form_feed($form, &$f '#options' => $period, '#description' => t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', array('@cron' => url('admin/reports/status'))), ); - $form['block'] = array('#type' => 'select', - '#title' => t('News items in block'), - '#default_value' => isset($feed->block) ? $feed->block : 5, - '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)), - '#description' => t("Drupal can make a block with the most recent news items of this feed. You can configure blocks to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in this feed's block. If you choose '0' this feed's block will be disabled.", array('@block-admin' => url('admin/structure/block'))), + + $form['block'] = array('#type' => 'checkbox', + '#title' => t('Create block of feed items'), + '#default_value' => isset($feed->block) ? $feed->block : '1', + '#description' => t("Drupal can make a block with the most recent news items of this feed. You can configure blocks to be displayed in the sidebar of your page.", array('@block-admin' => url('admin/structure/block'))), ); // Handling of categories. Index: aggregator.install =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v retrieving revision 1.31 diff -u -p -r1.31 aggregator.install --- aggregator.install 22 Aug 2010 13:55:53 -0000 1.31 +++ aggregator.install 7 Jan 2011 22:37:06 -0000 @@ -50,7 +50,7 @@ function aggregator_schema() { 'not null' => TRUE, 'default' => 0, 'size' => 'tiny', - 'description' => 'The number of recent items to show within the category block.', + 'description' => 'Whether a block has been created for this feed.', ) ), 'primary key' => array('cid'), Index: aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v retrieving revision 1.444 diff -u -p -r1.444 aggregator.module --- aggregator.module 24 Sep 2010 00:37:41 -0000 1.444 +++ aggregator.module 7 Jan 2011 22:37:06 -0000 @@ -371,6 +371,15 @@ function aggregator_block_configure($del ); return $form; } + if ($type == 'feed') { + $form['aggregator_block_items'] = array( + '#type' => 'select', + '#title' => t('Number of news items in block'), + '#default_value' => variable_get('aggregator_block_items' . $id , 5), + '#options' => drupal_map_assoc(range(1,20)), + ); + return $form; + } } /** @@ -384,6 +393,9 @@ function aggregator_block_save($delta = ->condition('cid', $id) ->execute(); } + if ($type == 'feed') { + variable_set('aggregator_block_items' . $id, $edit['aggregator_block_items']); + } } /** @@ -397,9 +409,9 @@ function aggregator_block_view($delta = list($type, $id) = explode('-', $delta); switch ($type) { case 'feed': - if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) { + if ($feed = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) { $block['subject'] = check_plain($feed->title); - $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $feed->block, array(':fid' => $id)); + $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, variable_get('aggregator_block_items' . $id), array(':fid' => $id)); $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news."))); } break; @@ -497,6 +509,13 @@ function aggregator_save_feed($edit) { 'block' => $edit['block'], )) ->execute(); + if ($edit['block'] == '0') { + // Make sure there is no active block for this feed. + db_delete('block') + ->condition('module', 'aggregator') + ->condition('delta', 'feed-' . $edit['fid']) + ->execute(); + } } elseif (!empty($edit['fid'])) { $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $edit['fid']))->fetchCol();