[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 20 # -------------------------------------------------------- 21 # $Id: issues_rss.php,v 1.8.2.1 2007-10-13 22:33:16 giallu Exp $ 22 # -------------------------------------------------------- 23 ?> 24 <?php 25 # 26 # GET PARAMETERS FOR THIS PAGE 27 # 28 # project_id: 0 - all projects, otherwise project id. 29 # filter_id: The filter id to use for generating the rss. 30 # sort: This parameter is ignore if filter_id is supplied and is not equal to 0. 31 # "update": issues ordered descending by last updated date. 32 # "submit": issues ordered descending by submit date (default). 33 34 require_once ( 'core.php' ); 35 36 $t_core_path = config_get( 'core_path' ); 37 38 require_once( $t_core_path . 'class.RSSBuilder.inc.php' ); 39 require_once( $t_core_path . 'user_api.php' ); 40 require_once( $t_core_path . 'filter_api.php' ); 41 require_once( $t_core_path . 'rss_api.php' ); 42 43 $f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS ); 44 $f_filter_id = gpc_get_int( 'filter_id', 0 ); 45 $f_sort = gpc_get_string( 'sort', 'submit' ); 46 $f_username = gpc_get_string( 'username', null ); 47 $f_key = gpc_get_string( 'key', null ); 48 49 # make sure RSS syndication is enabled. 50 if ( OFF == config_get( 'rss_enabled' ) ) { 51 access_denied(); 52 } 53 54 # authenticate the user 55 if ( $f_username !== null ) { 56 if ( !rss_login( $f_username, $f_key ) ) { 57 access_denied(); 58 } 59 } else { 60 if ( OFF == config_get( 'allow_anonymous_login' ) ) { 61 access_denied(); 62 } 63 } 64 65 # Make sure that the current user has access to the selected project (if not ALL PROJECTS). 66 if ( $f_project_id != ALL_PROJECTS ) { 67 access_ensure_project_level( VIEWER, $f_project_id ); 68 } 69 70 if ( $f_sort === 'update' ) { 71 $c_sort_field = 'last_updated'; 72 } else { 73 $c_sort_field = 'date_submitted'; 74 } 75 76 $t_path = config_get( 'path' ); 77 78 # construct rss file 79 80 $encoding = lang_get( 'charset' ); 81 $about = $t_path; 82 $title = string_rss_links( config_get( 'window_title' ) ); 83 $image_link = $t_path . 'images/mantis_logo_button.gif'; 84 85 # only rss 2.0 86 $category = string_rss_links( project_get_name( $f_project_id ) ); 87 if ( $f_project_id !== 0 ) { 88 $title .= ' - ' . $category; 89 } 90 91 $title .= ' - ' . lang_get( 'issues' ); 92 93 if ( $f_username !== null ) { 94 $title .= " - ($f_username)"; 95 } 96 97 if ( $f_filter_id !== 0 ) { 98 $title .= ' (' . filter_get_field( $f_filter_id, 'name' ) . ')'; 99 } 100 101 $description = $title; 102 103 # in minutes (only rss 2.0) 104 $cache = '10'; 105 106 $rssfile = new RSSBuilder( $encoding, $about, $title, $description, 107 $image_link, $category, $cache); 108 109 # person, an organization, or a service 110 $publisher = ''; 111 112 # person, an organization, or a service 113 $creator = ''; 114 115 $date = (string) date( 'r' ); 116 $language = lang_get( 'phpmailer_language' ); 117 $rights = ''; 118 119 # spatial location , temporal period or jurisdiction 120 $coverage = (string) ''; 121 122 # person, an organization, or a service 123 $contributor = (string) ''; 124 125 $rssfile->setPublisher( $publisher ); 126 $rssfile->setCreator( $creator ); 127 $rssfile->setRights( $rights ); 128 $rssfile->setCoverage( $coverage ); 129 $rssfile->setContributor( $contributor ); 130 131 # hourly / daily / weekly / ... 132 $period = (string) 'hourly'; 133 134 # every X hours/days/... 135 $frequency = (int) 1; 136 137 $base = (string) date( 'Y-m-d\TH:i:sO' ); 138 139 # add missing : in the O part of the date. PHP 5 supports a 'c' format which will output the format 140 # exactly as we want it. 141 # // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00 142 $base = substr( $base, 0, 22 ) . ':' . substr( $base, -2 ); 143 144 $rssfile->addSYdata( $period, $frequency, $base ); 145 146 $t_page_number = 1; 147 $t_issues_per_page = 25; 148 $t_page_count = 0; 149 $t_issues_count = 0; 150 $t_project_id = $f_project_id; 151 if ( $f_username !== null ) { 152 $t_user_id = user_get_id_by_name( $f_username ); 153 } else { 154 $t_user_id = user_get_id_by_name( config_get( 'anonymous_account' ) ); 155 } 156 $t_show_sticky = null; 157 158 if ( $f_filter_id == 0 ) { 159 $t_custom_filter = filter_get_default(); 160 $t_custom_filter['sort'] = $c_sort_field; 161 } else { 162 # null will be returned if the user doesn't have access right to access the filter. 163 $t_custom_filter = filter_db_get_filter( $f_filter_id, $t_user_id ); 164 if ( null === $t_custom_filter ) { 165 access_denied(); 166 } 167 168 $t_custom_filter = filter_deserialize( $t_custom_filter ); 169 } 170 171 $t_issues = filter_get_bug_rows( $t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count, 172 $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky ); 173 174 # Loop through results 175 for ( $i = 0; $i < count( $t_issues ); $i++ ) { 176 $row = $t_issues[$i]; 177 178 $t_bug = bug_get( $row['id'], true ); 179 180 $about = $link = $t_path . "view.php?id=" . $row['id']; 181 $title = string_rss_links( bug_format_id( $row['id'] ) . ': ' . $t_bug->summary ); 182 183 if ( $row['view_state'] == VS_PRIVATE ) { 184 $title .= ' [' . lang_get( 'private' ) . ']'; 185 } 186 187 $description = string_rss_links( $t_bug->description ); 188 189 # subject is category. 190 $subject = string_rss_links( $t_bug->category ); 191 192 # optional DC value 193 $date = date( 'Y-m-d\TH:i:sO', $t_bug->last_updated ); 194 195 # author of item 196 $author = string_rss_links( user_get_name( $t_bug->reporter_id ) ); 197 if ( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) { 198 $t_author_email = user_get_field( $t_bug->reporter_id, 'email' ); 199 if ( is_blank( $t_author_email ) ) { 200 $t_author_email = $author . '@example.com'; 201 } 202 } else { 203 $t_author_email = $author . '@example.com'; 204 } 205 $author .= ' <' . $t_author_email . '>'; 206 207 # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1'; # url to comment page rss 2.0 value 208 $comments = $t_path . 'view.php?id=' . $row['id'] . '#bugnotes'; 209 210 # optional mod_im value for dispaying a different pic for every item 211 $image = ''; 212 213 $rssfile->addItem( $about, $title, $link, $description, $subject, $date, 214 $author, $comments, $image ); 215 } 216 217 # @@@ consider making this a configuration option. 218 # 0.91 / 1.0 / 2.0 219 $version = '2.0'; 220 221 $rssfile->outputRSS( $version ); 222 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |