Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 218 lines (171 sloc) 6.695 kb
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
1 <?php
4d63b482 » siebrand
2009-02-14 Mantis -> MantisBT in file headers, comments, and elsewhere.
2 # MantisBT - a php based bugtracking system
2669909b » giallu
2007-10-24 Merge back to HEAD the changes between tags:
3
4d63b482 » siebrand
2009-02-14 Mantis -> MantisBT in file headers, comments, and elsewhere.
4 # MantisBT is free software: you can redistribute it and/or modify
2669909b » giallu
2007-10-24 Merge back to HEAD the changes between tags:
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
8 #
4d63b482 » siebrand
2009-02-14 Mantis -> MantisBT in file headers, comments, and elsewhere.
9 # MantisBT is distributed in the hope that it will be useful,
2669909b » giallu
2007-10-24 Merge back to HEAD the changes between tags:
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
4d63b482 » siebrand
2009-02-14 Mantis -> MantisBT in file headers, comments, and elsewhere.
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
16
526bbaac » grangeway
2008-09-25 Comment updates for phpdoc ( http://www.mantisforge.org/dev/phpdoc/ )…
17 /**
18 *
19 * GET PARAMETERS FOR THIS PAGE
20 *
21 * project_id: 0 - all projects, otherwise project id.
22 * filter_id: The filter id to use for generating the rss.
23 * sort: This parameter is ignore if filter_id is supplied and is not equal to 0.
24 * "update": issues ordered descending by last updated date.
25 * "submit": issues ordered descending by submit date (default).
26 *
27 * @package MantisBT
28 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
4d63b482 » siebrand
2009-02-14 Mantis -> MantisBT in file headers, comments, and elsewhere.
29 * @copyright Copyright (C) 2002 - 2009 MantisBT Team - mantisbt-dev@lists.sourceforge.net
526bbaac » grangeway
2008-09-25 Comment updates for phpdoc ( http://www.mantisforge.org/dev/phpdoc/ )…
30 * @link http://www.mantisbt.org
31 */
32 /**
4d63b482 » siebrand
2009-02-14 Mantis -> MantisBT in file headers, comments, and elsewhere.
33 * MantisBT Core API's
526bbaac » grangeway
2008-09-25 Comment updates for phpdoc ( http://www.mantisforge.org/dev/phpdoc/ )…
34 */
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
35 require_once( 'core.php' );
36
37 $t_core_path = config_get( 'core_path' );
38
b70c4da7 » giallu
2008-12-30 Fix feeds broken by the recent RSSbuilder update
39 require_once( $t_core_path . 'rssbuilder/class.RSSBuilder.inc.php' );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
40 require_once( $t_core_path . 'user_api.php' );
41 require_once( $t_core_path . 'filter_api.php' );
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
42 require_once( $t_core_path . 'rss_api.php' );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
43
811b3508 » vboctor
2005-05-23 Implemented #5635: Support for feeds for filters
44 $f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS );
45 $f_filter_id = gpc_get_int( 'filter_id', 0 );
46 $f_sort = gpc_get_string( 'sort', 'submit' );
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
47 $f_username = gpc_get_string( 'username', null );
48 $f_key = gpc_get_string( 'key', null );
49
a9a46fd3 » vboctor
2006-04-25 Fixed #6987: Add $g_rss_enabled configuration option
50 # make sure RSS syndication is enabled.
51 if ( OFF == config_get( 'rss_enabled' ) ) {
52 access_denied();
53 }
54
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
55 # authenticate the user
56 if ( $f_username !== null ) {
57 if ( !rss_login( $f_username, $f_key ) ) {
58 access_denied();
59 }
60 } else {
61 if ( OFF == config_get( 'allow_anonymous_login' ) ) {
62 access_denied();
63 }
64 }
65
66 # Make sure that the current user has access to the selected project (if not ALL PROJECTS).
67 if ( $f_project_id != ALL_PROJECTS ) {
68 access_ensure_project_level( VIEWER, $f_project_id );
69 }
811b3508 » vboctor
2005-05-23 Implemented #5635: Support for feeds for filters
70
71 if ( $f_sort === 'update' ) {
72 $c_sort_field = 'last_updated';
73 } else {
74 $c_sort_field = 'date_submitted';
75 }
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
76
77 $t_path = config_get( 'path' );
78
79 # construct rss file
80
a3cee1b8 » grangeway
2009-04-29 Following siebrands commit to remove non-utf8 language files, we can …
81 $encoding = 'utf-8';
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
82 $about = $t_path;
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
83 $title = string_rss_links( config_get( 'window_title' ) );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
84 $image_link = $t_path . 'images/mantis_logo_button.gif';
85
86 # only rss 2.0
37dde2ef » vboctor
2005-07-18 Fixed #5934: Rss fails when XML has '&' in it.
87 $category = string_rss_links( project_get_name( $f_project_id ) );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
88 if ( $f_project_id !== 0 ) {
89 $title .= ' - ' . $category;
90 }
91
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
92 $title .= ' - ' . lang_get( 'issues' );
93
94 if ( $f_username !== null ) {
95 $title .= " - ($f_username)";
96 }
97
811b3508 » vboctor
2005-05-23 Implemented #5635: Support for feeds for filters
98 if ( $f_filter_id !== 0 ) {
99 $title .= ' (' . filter_get_field( $f_filter_id, 'name' ) . ')';
100 }
101
d312f893 » vboctor
2005-06-20 Fixed #5754: RSS Feed does not validate.
102 $description = $title;
103
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
104 # in minutes (only rss 2.0)
105 $cache = '10';
106
107 $rssfile = new RSSBuilder( $encoding, $about, $title, $description,
108 $image_link, $category, $cache);
109
110 # person, an organization, or a service
111 $publisher = '';
112
113 # person, an organization, or a service
114 $creator = '';
115
d312f893 » vboctor
2005-06-20 Fixed #5754: RSS Feed does not validate.
116 $date = (string) date( 'r' );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
117 $language = lang_get( 'phpmailer_language' );
118 $rights = '';
119
120 # spatial location , temporal period or jurisdiction
121 $coverage = (string) '';
122
123 # person, an organization, or a service
124 $contributor = (string) '';
125
1b5bd2cf » grangeway
2008-07-28 0009100: RSS Feeds do no include date posted
126 $rssfile->addDCdata( $publisher, $creator, $date, $language, $rights, $coverage, $contributor );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
127
128 # hourly / daily / weekly / ...
129 $period = (string) 'hourly';
130
131 # every X hours/days/...
132 $frequency = (int) 1;
133
d312f893 » vboctor
2005-06-20 Fixed #5754: RSS Feed does not validate.
134 $base = (string) date( 'Y-m-d\TH:i:sO' );
135
136 # add missing : in the O part of the date. PHP 5 supports a 'c' format which will output the format
137 # exactly as we want it.
138 # // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
139 $base = substr( $base, 0, 22 ) . ':' . substr( $base, -2 );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
140
141 $rssfile->addSYdata( $period, $frequency, $base );
142
143 $t_page_number = 1;
144 $t_issues_per_page = 25;
145 $t_page_count = 0;
146 $t_issues_count = 0;
147 $t_project_id = $f_project_id;
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
148 if ( $f_username !== null ) {
149 $t_user_id = user_get_id_by_name( $f_username );
150 } else {
151 $t_user_id = user_get_id_by_name( config_get( 'anonymous_account' ) );
152 }
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
153 $t_show_sticky = null;
154
811b3508 » vboctor
2005-05-23 Implemented #5635: Support for feeds for filters
155 if ( $f_filter_id == 0 ) {
156 $t_custom_filter = filter_get_default();
157 $t_custom_filter['sort'] = $c_sort_field;
158 } else {
159 # null will be returned if the user doesn't have access right to access the filter.
160 $t_custom_filter = filter_db_get_filter( $f_filter_id, $t_user_id );
94694ab8 » thraxisp
2005-07-13 fix for 0005927: null checking failure in user_get_accessible_subproj…
161 if ( null === $t_custom_filter ) {
811b3508 » vboctor
2005-05-23 Implemented #5635: Support for feeds for filters
162 access_denied();
163 }
164
165 $t_custom_filter = filter_deserialize( $t_custom_filter );
166 }
167
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
168 $t_issues = filter_get_bug_rows( $t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count,
169 $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky );
5cf7970f » grangeway
2009-04-07 Consistency update
170 $t_issues_count = count( $t_issues );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
171
172 # Loop through results
5cf7970f » grangeway
2009-04-07 Consistency update
173 for ( $i = 0; $i < $t_issues_count; $i++ ) {
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
174 $row = $t_issues[$i];
175
176 $t_bug = bug_get( $row['id'], true );
177
178 $about = $link = $t_path . "view.php?id=" . $row['id'];
f94bb58f » vboctor
2005-04-27 Fixed #3907: Bad RSS link on http://bugs.mantisbt.org/
179 $title = string_rss_links( bug_format_id( $row['id'] ) . ': ' . $t_bug->summary );
5cf7970f » grangeway
2009-04-07 Consistency update
180
0dae1ce9 » vboctor
2006-04-23 Fixed #6757: Allow RSS syndication without allowing anonymous login..
181 if ( $row['view_state'] == VS_PRIVATE ) {
182 $title .= ' [' . lang_get( 'private' ) . ']';
183 }
5cf7970f » grangeway
2009-04-07 Consistency update
184
f94bb58f » vboctor
2005-04-27 Fixed #3907: Bad RSS link on http://bugs.mantisbt.org/
185 $description = string_rss_links( $t_bug->description );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
186
f94bb58f » vboctor
2005-04-27 Fixed #3907: Bad RSS link on http://bugs.mantisbt.org/
187 # subject is category.
6a7d7ee3 » grangeway
2008-07-28 Fix: category is replaced by cat_id now
188 $subject = string_rss_links( category_full_name( $t_bug->category_id, false ) );
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
189
190 # optional DC value
17b4e549 » giallu
2008-12-30 Fix dates shown on feed
191 $date = $t_bug->last_updated;
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
192
193 # author of item
37dde2ef » vboctor
2005-07-18 Fixed #5934: Rss fails when XML has '&' in it.
194 $author = string_rss_links( user_get_name( $t_bug->reporter_id ) );
d312f893 » vboctor
2005-06-20 Fixed #5754: RSS Feed does not validate.
195 if ( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) {
196 $t_author_email = user_get_field( $t_bug->reporter_id, 'email' );
197 if ( is_blank( $t_author_email ) ) {
198 $t_author_email = $author . '@example.com';
199 }
200 } else {
201 $t_author_email = $author . '@example.com';
202 }
203 $author .= ' &lt;' . $t_author_email . '&gt;';
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
204
205 # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1'; # url to comment page rss 2.0 value
206 $comments = $t_path . 'view.php?id=' . $row['id'] . '#bugnotes';
207
208 # optional mod_im value for dispaying a different pic for every item
209 $image = '';
210
b70c4da7 » giallu
2008-12-30 Fix feeds broken by the recent RSSbuilder update
211 $rssfile->addRSSItem( $about, $title, $link, $description, $subject, $date,
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
212 $author, $comments, $image );
213 }
214
b62a51cc » grangeway
2008-12-15 PHPDoc
215 /** @todo consider making this a configuration option - 0.91 / 1.0 / 2.0 */
4c199b94 » vboctor
2005-04-24 - Implemented #5502: Implement an RSS feed for issues.
216 $version = '2.0';
217
218 $rssfile->outputRSS( $version );
5cf7970f » grangeway
2009-04-07 Consistency update
219
Something went wrong with that request. Please try again.