/[drupal]/contributions/modules/revisions_rss/revisions_rss.module
ViewVC logotype

Contents of /contributions/modules/revisions_rss/revisions_rss.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Wed Jan 21 21:29:18 2009 UTC (10 months ago) by alexj
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, HEAD
Changes since 1.3: +35 -177 lines
File MIME type: text/x-php
6.x-1.0 release
1 <?php
2 // $Id: revisions_rss.module,v 1.3 2009/01/21 02:49:43 alexj Exp $
3
4 /**
5 * @file
6 * Revision RSS, written by Alex Jarvis
7 */
8
9 define('REV_RSS_PERM', 'view revision rss');
10
11 /*
12 * Adds a permission for viewing RSS revisions.
13 */
14 function revisions_rss_perm() {
15 return array(REV_RSS_PERM);
16 }
17
18 /**
19 * Implementation of hook_menu().
20 */
21 function revisions_rss_menu() {
22 $items = array();
23
24 $items['admin/content/rss-publishing/default'] = array(
25 'title' => 'General settings',
26 'type' => MENU_DEFAULT_LOCAL_TASK,
27 );
28 $items['admin/content/rss-publishing/revision-rss'] = array(
29 'title' => 'Revision RSS publishing',
30 'description' => 'Configure RSS feeds for revisions.',
31 'page callback' => 'drupal_get_form',
32 'page arguments' => array('revision_rss_admin_settings'),
33 'access arguments' => array('administer site configuration'),
34 'type' => MENU_LOCAL_TASK,
35 'weight' => 10,
36 'file' => 'revisions_rss.admin.inc',
37 );
38 $items['node/%node/revisions/rss'] = array(
39 'title' => '',
40 'page callback' => 'revisions_rss_handler',
41 'page arguments' => array(1),
42 'access arguments' => array(REV_RSS_PERM),
43 'type' => MENU_CALLBACK,
44 'file' => 'revisions_rss.pages.inc',
45 );
46
47 return $items;
48 }
49
50 /**
51 * Implementation of hook_init().
52 */
53 function revisions_rss_init() {
54 // Expose node feed on node view page.
55 if ((arg(0) == 'node') && is_numeric($nid = arg(1)) && is_null(arg(2)) &&
56 ($node = node_load($nid)) && revision_rss_check_type($node) &&
57 user_access(REV_RSS_PERM)) {
58
59 drupal_add_feed(url("node/{$node->nid}/revisions/rss"),
60 t('Updates to "@title"', array('@title' => $node->title))
61 );
62 }
63 }
64
65 /**
66 * Check if RSS should be available for the given node.
67 *
68 * @param $node The node object to check against.
69 *
70 * @return bool True if RSS should be available for this node type, false otherwise.
71 */
72 function revision_rss_check_type($node) {
73 return $node->nid && in_array($node->type, variable_get('revision_rss_nodetypes', array('page')));
74 }

  ViewVC Help
Powered by ViewVC 1.1.2