1<?php 2# MantisBT - A PHP based bugtracking system 3 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. 8# 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. 13# 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/>. 16 17/** 18 * GET PARAMETERS FOR THIS PAGE 19 * 20 * project_id: 0 - all projects, otherwise project id. 21 * filter_id: The filter id to use for generating the rss. 22 * sort: This parameter is ignore if filter_id is supplied and is not equal to 0. 23 * "update": issues ordered descending by last updated date. 24 * "submit": issues ordered descending by submit date (default). 25 * 26 * @package MantisBT 27 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 28 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 29 * @link http://www.mantisbt.org 30 * 31 * @uses core.php 32 * @uses access_api.php 33 * @uses bug_api.php 34 * @uses category_api.php 35 * @uses config_api.php 36 * @uses constant_inc.php 37 * @uses filter_api.php 38 * @uses gpc_api.php 39 * @uses lang_api.php 40 * @uses project_api.php 41 * @uses rss_api.php 42 * @uses string_api.php 43 * @uses user_api.php 44 * @uses utility_api.php 45 */ 46 47# Prevent output of HTML in the content if errors occur 48define( 'DISABLE_INLINE_ERROR_REPORTING', true ); 49 50require_once( 'core.php' ); 51require_api( 'access_api.php' ); 52require_api( 'bug_api.php' ); 53require_api( 'category_api.php' ); 54require_api( 'config_api.php' ); 55require_api( 'constant_inc.php' ); 56require_api( 'filter_api.php' ); 57require_api( 'gpc_api.php' ); 58require_api( 'lang_api.php' ); 59require_api( 'project_api.php' ); 60require_api( 'rss_api.php' ); 61require_api( 'string_api.php' ); 62require_api( 'user_api.php' ); 63require_api( 'utility_api.php' ); 64 65$f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS ); 66$f_filter_id = gpc_get_int( 'filter_id', 0 ); 67$f_sort = gpc_get_string( 'sort', 'submit' ); 68$f_username = gpc_get_string( 'username', null ); 69$f_key = gpc_get_string( 'key', null ); 70 71# make sure RSS syndication is enabled. 72if( OFF == config_get( 'rss_enabled' ) ) { 73 access_denied(); 74} 75 76# authenticate the user 77if( $f_username !== null ) { 78 if( !rss_login( $f_username, $f_key ) ) { 79 access_denied(); 80 } 81} else { 82 if( !auth_anonymous_enabled() ) { 83 access_denied(); 84 } 85} 86 87# Make sure that the current user has access to the selected project (if not ALL PROJECTS). 88if( $f_project_id != ALL_PROJECTS ) { 89 access_ensure_project_level( config_get( 'view_bug_threshold', null, null, $f_project_id ), $f_project_id ); 90} 91 92if( $f_sort === 'update' ) { 93 $c_sort_field = 'last_updated'; 94} else { 95 $c_sort_field = 'date_submitted'; 96} 97 98$t_path = config_get_global( 'path' ); 99 100# construct rss file 101 102$t_encoding = 'utf-8'; 103$t_about = $t_path; 104$t_title = config_get( 'window_title' ); 105$t_image_link = $t_path . config_get_global( 'logo_image' ); 106 107# only rss 2.0 108$t_category = project_get_name( $f_project_id ); 109if( $f_project_id !== 0 ) { 110 $t_title .= ' - ' . $t_category; 111} 112 113$t_title .= ' - ' . lang_get( 'issues' ); 114 115if( $f_username !== null ) { 116 $t_title .= ' - (' . $f_username . ')'; 117} 118 119if( $f_filter_id !== 0 ) { 120 $t_title .= ' (' . filter_get_field( $f_filter_id, 'name' ) . ')'; 121} 122 123$t_description = $t_title; 124 125# in minutes (only rss 2.0) 126$t_cache = '10'; 127 128$t_rssfile = new RSSBuilder( $t_encoding, $t_about, $t_title, $t_description, $t_image_link, $t_category, $t_cache ); 129 130# person, an organization, or a service 131$t_publisher = ''; 132 133# person, an organization, or a service 134$t_creator = ''; 135 136$t_date = date( 'r' ); 137$t_language = lang_get( 'phpmailer_language' ); 138$t_rights = ''; 139 140# spatial location , temporal period or jurisdiction 141$t_coverage = ''; 142 143# person, an organization, or a service 144$t_contributor = ''; 145 146$t_rssfile->addDCdata( $t_publisher, $t_creator, $t_date, $t_language, $t_rights, $t_coverage, $t_contributor ); 147 148# hourly / daily / weekly / ... 149$t_period = 'hourly'; 150 151# every X hours/days/... 152$t_frequency = 1; 153 154$t_base = date( 'Y-m-d\TH:i:sO' ); 155 156# add missing : in the O part of the date. PHP 5 supports a 'c' format which will output the format 157# exactly as we want it. 158# 2002-10-02T10:00:00-0500 -> 2002-10-02T10:00:00-05:00 159$t_base = mb_substr( $t_base, 0, 22 ) . ':' . mb_substr( $t_base, -2 ); 160 161$t_rssfile->addSYdata( $t_period, $t_frequency, $t_base ); 162 163$t_page_number = 1; 164$t_issues_per_page = 25; 165$t_page_count = 0; 166$t_issues_count = 0; 167$t_project_id = $f_project_id; 168if( $f_username !== null ) { 169 $t_user_id = user_get_id_by_name( $f_username ); 170} else { 171 $t_user_id = user_get_id_by_name( auth_anonymous_account() ); 172} 173$t_show_sticky = null; 174 175# Override current user 176current_user_set( $t_user_id ); 177 178if( $f_filter_id == 0 ) { 179 $t_custom_filter = filter_get_default(); 180 $t_custom_filter['sort'] = $c_sort_field; 181} else { 182 # null will be returned if the user doesn't have access right to access the filter. 183 $t_custom_filter = filter_get( $f_filter_id, null ); 184 if( null === $t_custom_filter ) { 185 access_denied(); 186 } 187} 188 189$t_issues = filter_get_bug_rows( $t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count, 190 $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky ); 191$t_issues_count = count( $t_issues ); 192 193# Loop through results 194for( $i = 0; $i < $t_issues_count; $i++ ) { 195 $t_bug = $t_issues[$i]; 196 197 $t_about = $t_link = $t_path . 'view.php?id=' . $t_bug->id; 198 $t_title = bug_format_id( $t_bug->id ) . ': ' . $t_bug->summary; 199 200 if( $t_bug->view_state == VS_PRIVATE ) { 201 $t_title .= ' [' . lang_get( 'private' ) . ']'; 202 } 203 204 $t_description = string_rss_links( $t_bug->description ); 205 206 # subject is category. 207 $t_subject = category_full_name( $t_bug->category_id, false ); 208 209 # optional DC value 210 $t_date = $t_bug->last_updated; 211 212 # author of item 213 $t_author = ''; 214 if( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) { 215 $t_author_name = user_get_name( $t_bug->reporter_id ); 216 $t_author_email = user_get_field( $t_bug->reporter_id, 'email' ); 217 218 if( !is_blank( $t_author_email ) ) { 219 if( !is_blank( $t_author_name ) ) { 220 $t_author = $t_author_name . ' <' . $t_author_email . '>'; 221 } else { 222 $t_author = $t_author_email; 223 } 224 } 225 } 226 227 # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1'; # url to comment page rss 2.0 value 228 $t_comments = $t_path . 'view.php?id=' . $t_bug->id . '#bugnotes'; 229 230 # optional mod_im value for dispaying a different pic for every item 231 $t_image = ''; 232 233 $t_rssfile->addRSSItem( $t_about, $t_title, $t_link, $t_description, $t_subject, $t_date, 234 $t_author, $t_comments, $t_image ); 235} 236 237# @todo consider making this a configuration option - 0.91 / 1.0 / 2.0 238$t_version = '2.0'; 239 240$t_rssfile->outputRSS( $t_version ); 241 242