Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / issues_rss.php
blob5598514e2090d213438bd3262129e7ad3fa0ff1a
1 <?php
2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
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.
9 # MantisBT is distributed in the hope that it will be useful,
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.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
17 /**
19 * GET PARAMETERS FOR THIS PAGE
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).
27 * @package MantisBT
28 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
29 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
30 * @link http://www.mantisbt.org
32 * @uses core.php
33 * @uses access_api.php
34 * @uses bug_api.php
35 * @uses category_api.php
36 * @uses config_api.php
37 * @uses constant_inc.php
38 * @uses filter_api.php
39 * @uses gpc_api.php
40 * @uses lang_api.php
41 * @uses project_api.php
42 * @uses rss_api.php
43 * @uses string_api.php
44 * @uses user_api.php
45 * @uses utility_api.php
48 require_once( 'core.php' );
49 require_api( 'access_api.php' );
50 require_api( 'bug_api.php' );
51 require_api( 'category_api.php' );
52 require_api( 'config_api.php' );
53 require_api( 'constant_inc.php' );
54 require_api( 'filter_api.php' );
55 require_api( 'gpc_api.php' );
56 require_api( 'lang_api.php' );
57 require_api( 'project_api.php' );
58 require_api( 'rss_api.php' );
59 require_api( 'string_api.php' );
60 require_api( 'user_api.php' );
61 require_api( 'utility_api.php' );
63 $f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS );
64 $f_filter_id = gpc_get_int( 'filter_id', 0 );
65 $f_sort = gpc_get_string( 'sort', 'submit' );
66 $f_username = gpc_get_string( 'username', null );
67 $f_key = gpc_get_string( 'key', null );
69 # make sure RSS syndication is enabled.
70 if ( OFF == config_get( 'rss_enabled' ) ) {
71 access_denied();
74 # authenticate the user
75 if ( $f_username !== null ) {
76 if ( !rss_login( $f_username, $f_key ) ) {
77 access_denied();
79 } else {
80 if ( OFF == config_get( 'allow_anonymous_login' ) ) {
81 access_denied();
85 # Make sure that the current user has access to the selected project (if not ALL PROJECTS).
86 if ( $f_project_id != ALL_PROJECTS ) {
87 access_ensure_project_level( VIEWER, $f_project_id );
90 if ( $f_sort === 'update' ) {
91 $c_sort_field = 'last_updated';
92 } else {
93 $c_sort_field = 'date_submitted';
96 $t_path = config_get( 'path' );
98 # construct rss file
100 $encoding = 'utf-8';
101 $about = $t_path;
102 $title = string_rss_links( config_get( 'window_title' ) );
103 $image_link = $t_path . 'images/mantis_logo_button.gif';
105 # only rss 2.0
106 $category = string_rss_links( project_get_name( $f_project_id ) );
107 if ( $f_project_id !== 0 ) {
108 $title .= ' - ' . $category;
111 $title .= ' - ' . lang_get( 'issues' );
113 if ( $f_username !== null ) {
114 $title .= " - ($f_username)";
117 if ( $f_filter_id !== 0 ) {
118 $title .= ' (' . filter_get_field( $f_filter_id, 'name' ) . ')';
121 $description = $title;
123 # in minutes (only rss 2.0)
124 $cache = '10';
126 $rssfile = new RSSBuilder( $encoding, $about, $title, $description,
127 $image_link, $category, $cache);
129 # person, an organization, or a service
130 $publisher = '';
132 # person, an organization, or a service
133 $creator = '';
135 $date = (string) date( 'r' );
136 $language = lang_get( 'phpmailer_language' );
137 $rights = '';
139 # spatial location , temporal period or jurisdiction
140 $coverage = (string) '';
142 # person, an organization, or a service
143 $contributor = (string) '';
145 $rssfile->addDCdata( $publisher, $creator, $date, $language, $rights, $coverage, $contributor );
147 # hourly / daily / weekly / ...
148 $period = (string) 'hourly';
150 # every X hours/days/...
151 $frequency = (int) 1;
153 $base = (string) date( 'Y-m-d\TH:i:sO' );
155 # add missing : in the O part of the date. PHP 5 supports a 'c' format which will output the format
156 # exactly as we want it.
157 # // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
158 $base = utf8_substr( $base, 0, 22 ) . ':' . utf8_substr( $base, -2 );
160 $rssfile->addSYdata( $period, $frequency, $base );
162 $t_page_number = 1;
163 $t_issues_per_page = 25;
164 $t_page_count = 0;
165 $t_issues_count = 0;
166 $t_project_id = $f_project_id;
167 if ( $f_username !== null ) {
168 $t_user_id = user_get_id_by_name( $f_username );
169 } else {
170 $t_user_id = user_get_id_by_name( config_get( 'anonymous_account' ) );
172 $t_show_sticky = null;
174 if ( $f_filter_id == 0 ) {
175 $t_custom_filter = filter_get_default();
176 $t_custom_filter['sort'] = $c_sort_field;
177 } else {
178 # null will be returned if the user doesn't have access right to access the filter.
179 $t_custom_filter = filter_db_get_filter( $f_filter_id, $t_user_id );
180 if ( null === $t_custom_filter ) {
181 access_denied();
184 $t_custom_filter = filter_deserialize( $t_custom_filter );
187 $t_issues = filter_get_bug_rows( $t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count,
188 $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky );
189 $t_issues_count = count( $t_issues );
191 # Loop through results
192 for ( $i = 0; $i < $t_issues_count; $i++ ) {
193 $t_bug = $t_issues[$i];
195 $about = $link = $t_path . "view.php?id=" . $t_bug->id;
196 $title = string_rss_links( bug_format_id( $t_bug->id ) . ': ' . $t_bug->summary );
198 if ( $t_bug->view_state == VS_PRIVATE ) {
199 $title .= ' [' . lang_get( 'private' ) . ']';
202 $description = string_rss_links( $t_bug->description );
204 # subject is category.
205 $subject = string_rss_links( category_full_name( $t_bug->category_id, false ) );
207 # optional DC value
208 $date = $t_bug->last_updated;
210 # author of item
211 $author = '';
212 if ( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) {
213 $t_author_name = string_rss_links( user_get_name( $t_bug->reporter_id ) );
214 $t_author_email = user_get_field( $t_bug->reporter_id, 'email' );
216 if ( !is_blank( $t_author_email ) ) {
217 if ( !is_blank( $t_author_name ) ) {
218 $author = $t_author_name . ' &lt;' . $t_author_email . '&gt;';
219 } else {
220 $author = $t_author_email;
225 # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1'; # url to comment page rss 2.0 value
226 $comments = $t_path . 'view.php?id=' . $t_bug->id . '#bugnotes';
228 # optional mod_im value for dispaying a different pic for every item
229 $image = '';
231 $rssfile->addRSSItem( $about, $title, $link, $description, $subject, $date,
232 $author, $comments, $image );
235 /** @todo consider making this a configuration option - 0.91 / 1.0 / 2.0 */
236 $version = '2.0';
238 $rssfile->outputRSS( $version );