--- old\modules\aggregator.module Sat Dec 31 18:27:37 2005 +++ new\modules\aggregator.module Wed Jan 04 06:52:13 2006 @@ -65,6 +65,12 @@ '#options' => array('check' => t('checkboxes'), 'select' => t('multiple selector')), '#description' => t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.') ); + + $form['aggregator_block_generation'] = array( + '#type' => 'radios', '#title' => t('Block generation'), '#default_value' => variable_get('aggregator_block_generation', 1), + '#options' => array(t('Never, I do not wish to generate aggregator blocks.'), t('Always, please. I wish to generate blocks for all categories and feeds.'), t('Let me choose which categories and/or feeds I wish to generate blocks.')), + '#description' => t('This option allows you to choose how do you wish to generate blocks for aggregator categories/feeds.') + ); return $form; } @@ -190,13 +196,15 @@ function aggregator_block($op, $delta = 0, $edit = array()) { if (user_access('access news feeds')) { if ($op == 'list') { - $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title'); - while ($category = db_fetch_object($result)) { - $block['category-'. $category->cid]['info'] = t('%title category latest items', array('%title' => theme('placeholder', $category->title))); - } - $result = db_query('SELECT fid, title FROM {aggregator_feed} ORDER BY fid'); - while ($feed = db_fetch_object($result)) { - $block['feed-'. $feed->fid]['info'] = t('%title feed latest items', array('%title' => theme('placeholder', $feed->title))); + if (variable_get('aggregator_block_generation', 1) > 0) { + $where_block = (variable_get('aggregator_block_generation', 1) == 1 ? -1 : 0); + $result = db_query('SELECT cid, title FROM {aggregator_category} WHERE block > %d ORDER BY title', $where_block); + while ($category = db_fetch_object($result)) { + $block['category-'. $category->cid]['info'] = t('%title category latest items', array('%title' => theme('placeholder', $category->title))); + } + $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block > %d ORDER BY fid', $where_block); + while ($feed = db_fetch_object($result)) { + $block['feed-'. $feed->fid]['info'] = t('%title feed latest items', array('%title' => theme('placeholder', $feed->title))); + } } } else if ($op == 'configure') { @@ -645,6 +653,15 @@ function aggregator_form_category($edit = array()) { $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $edit['title'], '#maxlength' => 64); $form['description'] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => $edit['description']); + if (variable_get('aggregator_block_generation', 1) == 2) { + if (!is_numeric($edit['block'])) { + $edit['block'] = 5; + } + $form['block'] = array( + '#type' => 'radios', '#title' => t('Generate a block for this category'), '#default_value' => $edit['block'], + '#options' => array(0 => t('Disabled'), ($edit['block'] == 0 ? 5 : $edit['block']) => t('Enabled')) + ); + } $form['submit'] = array('#type' => 'submit', '#value' =>t('Submit')); if ($edit['cid']) { @@ -657,7 +674,15 @@ function aggregator_save_category($edit) { if ($edit['cid'] && $edit['title']) { - db_query('UPDATE {aggregator_category} SET title = \'%s\', description = \'%s\' WHERE cid = %d', $edit['title'], $edit['description'], $edit['cid']); + if (variable_get('aggregator_block_generation', 1) == 2) { + if (!is_numeric($edit['block'])) { + $edit['block'] = 0; + } + db_query('UPDATE {aggregator_category} SET title = \'%s\', description = \'%s\', block = %d WHERE cid = %d', $edit['title'], $edit['description'], $edit['block'], $edit['cid']); + } + else { + db_query('UPDATE {aggregator_category} SET title = \'%s\', description = \'%s\' WHERE cid = %d', $edit['title'], $edit['description'], $edit['cid']); + } } else if ($edit['cid']) { db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']); @@ -665,7 +690,18 @@ else if ($edit['title']) { // a single unique id for bundles and feeds, to use in blocks $next_id = db_next_id('{aggregator_category}_cid'); - db_query('INSERT INTO {aggregator_category} (cid, title, description, block) VALUES (%d, \'%s\', \'%s\', 5)', $next_id, $edit['title'], $edit['description']); + if (variable_get('aggregator_block_generation', 1) == 2) { + if (!is_numeric($edit['block'])) { + $edit['block'] = 0; + } + } + else if (variable_get('aggregator_block_generation', 1) == 0) { + $edit['block'] = 0; + } + else { + $edit['block'] = 5; + } + db_query('INSERT INTO {aggregator_category} (cid, title, description, block) VALUES (%d, \'%s\', \'%s\', %d)', $next_id, $edit['title'], $edit['description'], $edit['block']); } } @@ -692,6 +728,15 @@ if ($options) { $form['category'] = array('#type' => 'checkboxes', '#title' => t('Categorize news items'), '#default_value' => $values, '#options' => $options, '#description' => t('New items in this feed will be automatically filed in the checked categories as they are received.')); } + if (variable_get('aggregator_block_generation', 1) == 2) { + if (!is_numeric($edit['block'])) { + $edit['block'] = 5; + } + $form['block'] = array( + '#type' => 'radios', '#title' => t('Generate a block for this feed'), '#default_value' => $edit['block'], + '#options' => array(0 => t('Disabled'), ($edit['block'] == 0 ? 5 : $edit['block']) => t('Enabled')) + ); + } $form['submit'] = array('#type' => 'submit', '#value' =>t('Submit')); if ($edit['fid']) { @@ -708,7 +753,15 @@ db_query('DELETE FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']); } if ($edit['fid'] && $edit['title']) { - db_query('UPDATE {aggregator_feed} SET title = \'%s\', url = \'%s\', refresh = %d WHERE fid = %d', $edit['title'], $edit['url'], $edit['refresh'], $edit['fid']); + if (variable_get('aggregator_block_generation', 1) == 2) { + if (!is_numeric($edit['block'])) { + $edit['block'] = 0; + } + db_query('UPDATE {aggregator_feed} SET title = \'%s\', url = \'%s\', refresh = %d, block = %d WHERE fid = %d', $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], $edit['fid']); + } + else { + db_query('UPDATE {aggregator_feed} SET title = \'%s\', url = \'%s\', refresh = %d WHERE fid = %d', $edit['title'], $edit['url'], $edit['refresh'], $edit['fid']); + } } else if ($edit['fid']) { $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']); @@ -724,7 +777,18 @@ else if ($edit['title']) { // a single unique id for bundles and feeds, to use in blocks $edit['fid'] = db_next_id('{aggregator_feed}_fid'); - db_query('INSERT INTO {aggregator_feed} (fid, title, url, refresh, block) VALUES (%d, \'%s\', \'%s\', %d, 5)', $edit['fid'], $edit['title'], $edit['url'], $edit['refresh']); + if (variable_get('aggregator_block_generation', 1) == 2) { + if (!is_numeric($edit['block'])) { + $edit['block'] = 0; + } + } + else if (variable_get('aggregator_block_generation', 1) == 0) { + $edit['block'] = 0; + } + else { + $edit['block'] = 5; + } + db_query('INSERT INTO {aggregator_feed} (fid, title, url, refresh, block) VALUES (%d, \'%s\', \'%s\', %d, %d)', $edit['fid'], $edit['title'], $edit['url'], $edit['refresh'], $edit['block']); } if ($edit['title']) { // the feed is being saved, save the categories as well