Index: adminrss/README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adminrss/README.txt,v retrieving revision 1.1 diff -u -r1.1 README.txt --- adminrss/README.txt 1 Feb 2006 07:11:27 -0000 1.1 +++ adminrss/README.txt 31 Oct 2007 06:14:36 -0000 @@ -3,29 +3,22 @@ Description ----------- -The AdminRSS module creates RSS feeds for the administrative information for drupal website. -These are protected with a key that can be set in admin/settings/adminrss page. +The AdminRSS module creates RSS feeds for the administrative information +of a drupal website. These are protected with a key string that can be set at +the "admin/settings/adminrss" page. -The resulting pages can then be read at: +The resulting pages can then be fetchrd at: adminrss/node/keystring - RSS feed for unapproved nodes adminrss/comment/keystring - RSS feed for unapproved comments - - - Installation ------------ -1) copy the adminrss directory into the modules directory - -2) enable the 'gmap module' in drupal - -3) edit admin/settings/adminrss to set a keystring - +1) copy the adminrss directory into the sites/all/modules directory +2) enable the 'adminrss module' in drupal +3) go to admin/settings/adminrss to set a keystring 4) configure your rss reader to read the appropriate page - - To do ----- @@ -39,11 +32,13 @@ http://www.webgeer.com/James Thanks to Fredrik Jonsson and Gabor Hojtsy for their modules adminblock and -commentrss which were heavily used to +commentrss which were heavily used to. History ------- -2005-01-30 - - initial development - +2007-01-16 Port for Drupal 5 (osinet), + New format for the comment feed. + Direct links to feeds added in settings. +2006-01-30 Port for Drupal 4.7 +2005-01-30 Initial development for Drupal 4.6 Index: adminrss/adminrss.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adminrss/adminrss.info,v retrieving revision 1.2 diff -u -r1.2 adminrss.info --- adminrss/adminrss.info 18 Jun 2007 23:50:47 -0000 1.2 +++ adminrss/adminrss.info 31 Oct 2007 06:14:33 -0000 @@ -1,4 +1,5 @@ -; $Id: adminrss.info,v 1.2 2007/06/18 23:50:47 dww Exp $ +; $Id$ name = Admin RSS description = Moderation/approval queue feeds. - +version = "$Name$" +package = Contrib - Admin Index: adminrss/adminrss.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/adminrss/adminrss.module,v retrieving revision 1.4 diff -u -r1.4 adminrss.module --- adminrss/adminrss.module 22 Apr 2007 12:32:46 -0000 1.4 +++ adminrss/adminrss.module 31 Oct 2007 06:14:35 -0000 @@ -1,236 +1,219 @@ - - * Enables one to view unapproved nodes or comments using an RSS reader. - * - * This module was made a lot easier for me by both adminblock.module and commentrss.module. - * Thanks to both Fredrik Jonsson and Gabor Hojtsy. - */ - -define('ADMINRSS_KEY', variable_get('adminrss_key',NULL)); - -/** - * Implementation of hook_help(). - */ -function adminrss_help($section) { - switch ($section) { - case 'admin/modules#description': - return t('Provide an RSS feed for unapproved nodes and comments'); - } -} - -/** - * 5.0 equivalent of hook_settings(). - * - */ -function adminrss_admin_settings() { - -$key = variable_get('adminrss_key', ''); -if ($key == ''){ - $key = md5(uniqid(rand(), true)); - variable_set('adminrss_key', $key); -} - -$form = array(); -$form['adminrss_key'] = array( - '#type' => 'textfield', - '#title' => t('Admin RSS Key'), - '#required' => TRUE, - '#description' => t('This is the key that will be required in order to get access to the admin RSS feeds.'), - '#default_value' => $key, - '#weight' => -5); - -if (!empty($key)) { - $form['feeds'] = array( - '#type' => 'markup', - '#value' => t('', - array( - '!nodefeed' => l(t('Nodes feed'), "adminrss/node/$key"), - '!commentfeed' => l(t('Comments feed'), "adminrss/comment/$key") - ) - ), - ); -} - return system_settings_form($form); -} - -/** - * Implementation of hook_menu(). - * - */ - -function adminrss_menu($may_cache) { - $items = array(); - - if ($may_cache) { - $items[] = array( - 'path' => 'adminrss', - 'title' => 'Admin RSS Feed', - 'callback' => 'adminrss_handler', - 'access' => TRUE, - 'type' => MENU_CALLBACK - ); - $items[] = array( - 'path' => 'adminrss/publish', - 'title' => 'Publish', - 'callback' => 'adminrss_publish', - 'access' => user_access('administer nodes'), - 'type' => MENU_CALLBACK - ); - $items[] = array( - 'path' => 'adminrss/publish_promote', - 'title' => 'Publish and promote', - 'callback' => 'adminrss_publish_and_promote', - 'access' => user_access('administer nodes'), - 'type' => MENU_CALLBACK - ); - $items[] = array( - 'path' => 'admin/settings/adminrss', - 'title' => 'Admin RSS Feed', - 'description' => t('Configure access to the Admin RSS feeds.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('adminrss_admin_settings'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_NORMAL_ITEM, - ); - } - - return $items; -} - -/** - * The handler for admin RSS - * - * If the $type is not set to either 'node' or 'comment' or the key is not set, - * the function returns 401 - */ -function adminrss_handler($type = NULL, $key = NULL) { - if (isset($type) && isset($key) && ($key == ADMINRSS_KEY)) { - if (in_array($type, array('node', 'comment'))) { - if (call_user_func('adminrss_feed_' . $type)) { - return; - } - } - } - else { - //error must specify both a type and provide a key - drupal_access_denied(); - } -} - -/** - * Publish the comment/node and then redirect to the node. Uses Drupal auth. - */ -function adminrss_publish($type, $nid){ - if (isset($type) && isset($nid) && in_array($type, array('node', 'comment'))){ - if ($type=='node'){ - node_operations_publish(array($nid)); - drupal_goto('node/'.$nid); - } else { - $comment = _comment_load($nid); - db_query('UPDATE {comments} SET status=0 WHERE cid='.$nid); - drupal_goto("node/$comment->nid",NULL,"comment-$comment->cid"); - } - } else { - drupal_access_denied(); - } -} - -/** - * Publish and promote the node to the front page. - */ -function adminrss_publish_and_promote($nid){ - if (isset($nid)){ - node_operations_publish(array($nid)); - node_operations_promote(array($nid)); - drupal_goto('node/'.$nid); - } else { - drupal_access_denied(); - } -} - -/** - * Output a node feed for nodes under moderation - */ -function adminrss_feed_node() { - $result = db_query_range('SELECT n.nid, n.title, n.changed, u.name, u.uid - FROM {node} n - INNER JOIN {users} u ON n.uid = u.uid - WHERE n.status = 0 AND n.moderate = 1 - ORDER BY n.changed DESC', 0, 15); - $items = ''; - while ($results = db_fetch_object($result)) { - $node = node_load($results->nid); - $link = url('node/edit/'. $node->nid, NULL,NULL,TRUE); - $content = '

'.t($node->type.': !node', array('!node' => l($node->title, "node/$node->nid", NULL, NULL, NULL))).'

'; - // Insert actions - $content .= '

'.l(t('publish'),'adminrss/publish/node/'.$node->nid, NULL, NULL, NULL).'|'.l(t('publish and promote'),'adminrss/publish_promote/'.$node->nid, NULL, NULL, NULL).'

'; - if (!empty($node->body)) { - $content .= " : \n" . filter_xss($node->body); - } - $items .= format_rss_item($comment->subject, $link, $content, array('pubDate' => date('r', $node->timestamp))); - } - adminrss_format_feed($items, array( - 'description' => t('Unapproved Nodes for Administration'), - 'title' => variable_get('site_name', 'drupal') . ' - ' . t('Nodes'), - )); -} - -/** - * Output a comment feed for comments under moderation - * Items include a link to the comment on the node page and the node title, - * to make it easier to check whether the comment is on topic. - */ -function adminrss_feed_comment() { - $result = db_query_range('SELECT c.timestamp, c.subject, c.cid, c.nid, n.title, c.comment - FROM {comments} c - INNER JOIN {node} n ON c.nid = n.nid - WHERE c.status = 1 - ORDER BY c.timestamp DESC ', 0, 15); - $items = ''; - while ($comment = db_fetch_object($result)) { - $link = url('comment/edit/'. $comment->cid, NULL,NULL,TRUE); // url("node/{$comment->nid}", NULL, "comment-{$comment->cid}", TRUE); - $content = t('Comment on node !node', array('!node' => l($comment->title, "node/$comment->nid", NULL, NULL, "comment-$comment->cid"))); - $content .= '

'.l(t('publish'),'adminrss/publish/comment/'.$comment->cid, NULL, NULL, NULL).'

'; - if (!empty($comment->comment)) { - $content .= "\n" . filter_xss($comment->comment); - } - $items .= format_rss_item($comment->subject, $link, $content, array('pubDate' => date('r', $comment->timestamp))); - } - adminrss_format_feed($items, array( - 'description' => t('Unapproved Comments for Administration'), - 'title' => variable_get('site_name', 'drupal') . ' - ' . t('Comments'), - )); -} - -/** - * Note this function was originally identical to the commentrss.module's - * function commentrss_format_feed() - */ -function adminrss_format_feed($items, $channel = array()) { - global $base_url; - - $languages = (function_exists('locale') - ? locale_supported_languages() - : array('name' => array('en' => 'English'))); - $channel_defaults = array( - 'version' => '0.92', - 'title' => variable_get('site_name', 'drupal') . ' - ' . t('AdminRSS'), - 'link' => $base_url, - 'description' => t('AdminRSS'), - 'language' => (($key = reset(array_keys($languages['name']))) ? $key : 'en') - ); - $channel = array_merge($channel_defaults, $channel); - - $output = "\n" - . "]>\n" - . "\n" - . format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']) - . "\n"; - - drupal_set_header('Content-Type: text/xml; charset=utf-8'); - print $output; -} + + * Enables one to view unapproved nodes or comments using an RSS reader. + * + * This module was made a lot easier for me by both adminblock.module and commentrss.module. + * Thanks to both Fredrik Jonsson and Gabor Hojtsy. + */ + +define('ADMINRSS_KEY', variable_get('adminrss_key', NULL)); +define('ADMINRSS_LINK_TYPE', 'adminrss_link_type'); + +/** + * Implementation of hook_help(). + * + * @return string + */ +function adminrss_help($section) { + switch ($section) { + case 'admin/modules#description': + return t('Provide an RSS feed for unapproved nodes and comments'); + } +} + +/** + * 5.0 equivalent of hook_settings(). + * + * @return array + */ +function adminrss_admin_settings() { + + $key = variable_get('adminrss_key', ''); + + $form = array(); + $form['adminrss_key'] = array( + '#type' => 'textfield', + '#title' => t('Admin RSS Key'), + '#required' => TRUE, + '#description' => t('This is the key that will be required in order to get access to the admin RSS feeds.'), + '#size' => 50, + '#maxlength' => 255, + '#default_value' => $key, + '#weight' => -5 + ); + + if (!empty($key)) { + $form['feeds'] = array( + '#type' => 'fieldset', + '#title' => t('Admin RSS Feeds locations'), + '#description' => t('Copy and paste these links to your RSS aggregator.'), + ); + $form['feeds']['links'] = array( + '#type' => 'markup', + '#value' => t('', + array( + '!nodefeed' => l(t('Nodes feed'), "adminrss/node/$key"), + '!commentfeed' => l(t('Comments feed'), "adminrss/comment/$key") + ) + ), + ); + } + + $form[ADMINRSS_LINK_TYPE] = array( + '#type' => 'select', + '#title' => t('Comment feed links back to'), + '#options' => array( + 0 => t('Comment approval queue'), + 1 => t('Individual comment edit'), + ), + '#default_value' => variable_get(ADMINRSS_LINK_TYPE, 0), + ); + + return system_settings_form($form); +} + +/** + * Implementation of hook_menu(). + * + * @param boolean $may_cache + * @return array + */ +function adminrss_menu($may_cache) { + $items = array(); + + if ($may_cache) { + $items[] = array( + 'path' => 'adminrss', + 'title' => t('Admin RSS Feed'), + 'callback' => 'adminrss_handler', + 'access' => TRUE, + 'type' => MENU_CALLBACK + ); + $items[] = array( + 'path' => 'admin/settings/adminrss', + 'title' => t('Admin RSS Feed'), + 'description' => t('Configure access to the Admin RSS feeds.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('adminrss_admin_settings'), + 'access' => user_access('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + ); + } + + return $items; +} + +/** + * The handler for admin RSS + * + * If the $type is not set to either 'node' or 'comment' or the key is not set, + * the function returns 401. + * + * @param string $type + * @param string $key + * @return void + */ +function adminrss_handler($type = NULL, $key = NULL) { + if (isset($type) && isset($key) && ($key == ADMINRSS_KEY)) { + if (in_array($type, array('node', 'comment'))) { + if (call_user_func('adminrss_feed_'. $type)) { + return; + } + } + } + else { + //error must specify both a type and provide a key + drupal_access_denied(); + } +} + +/** + * Output a node feed for nodes under moderation + * + * @return string + */ +function adminrss_feed_node() { + $result = db_query_range('SELECT n.nid, n.title, n.changed, u.name, u.uid + FROM {node} n + INNER JOIN {users} u ON n.uid = u.uid + WHERE n.status = 0 AND n.moderate = 1 + ORDER BY n.changed DESC', 0, 15); + node_feed($result, array('description' => t('Unapproved Nodes for Administration'))); +} + +/** + * Output a comment feed for comments under moderation + * + * Items include a link to the comment on the node page and the node title, + * to make it easier to check whether the comment is on topic. + * + * @return string + */ +function adminrss_feed_comment() { + $result = db_query_range('SELECT c.timestamp, c.subject, c.cid, c.nid, n.title, c.comment + FROM {comments} c + INNER JOIN {node} n ON c.nid = n.nid + WHERE c.status = 1 + ORDER BY c.timestamp DESC ', 0, 15); + $items = ''; + $link_type = variable_get(ADMINRSS_LINK_TYPE, 0); + while ($comment = db_fetch_object($result)) { + switch ($link_type) { + case 0: // approval queue + $link = url('admin/content/comment/list/approval', NULL, NULL, TRUE); + break; + case 1: // individual edit link + $link = url("comment/edit/$comment->cid", NULL, NULL, TRUE); + // Old-style links below: + // url("node/{$comment->nid}", NULL, "comment-{$comment->cid}", TRUE); + break; + default: // site home + $link = base_path(); + } + $content = t('Comment on node !node', array('!node' => l($comment->title, "node/$comment->nid", NULL, NULL, "comment-$comment->cid"))); + if (!empty($comment->comment)) { + $content .= " : \n" . filter_xss($comment->comment); + } + $items .= format_rss_item($comment->subject, $link, $content, array('pubDate' => date('r', $comment->timestamp))); +// $comment = db_fetch_object($result)) { +// $items[] = $comment->subject .' - '. format_date($comment->timestamp, 'medium') .'
['. l(t('node'), 'node/'. $comment->nid, array('title' => $comment->title)) .']|['. l(t('edit'), 'comment/edit/'. $comment->cid) .']|['. l(t('delete'), 'admin/comment/delete/'. $comment->cid) .']'; + } + adminrss_format_feed($items, array('description' => t('Unapproved Comments for Administration'))); +} + +/** + * Note this function was originally identical to the commentrss.module's + * function commentrss_format_feed() + * + * @param array $items + * @param array $channel + * @return void + */ +function adminrss_format_feed($items, $channel = array()) { + global $base_url; + + $languages = (function_exists('locale') + ? locale_supported_languages() + : array('name' => array('en' => 'English'))); + $channel_defaults = array( + 'version' => '0.92', + 'title' => variable_get('site_name', 'drupal') .' - '. t('Comments'), + 'link' => $base_url, + 'description' => t('Comments'), + 'language' => (($key = reset(array_keys($languages['name']))) ? $key : 'en') + ); + $channel = array_merge($channel_defaults, $channel); + + $output = "\n" + ."]>\n" + ."\n" + . format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']) + ."\n"; + + drupal_set_header('Content-Type: text/xml; charset=utf-8'); + print $output; +} \ No newline at end of file