SOAP API: do not try to unserialize an invalid filter
[mantis.git] / news_rss.php
bloba7fec5e15ab1a1d26830389eb53f102f6fb1df82
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 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses core.php
24 * @uses access_api.php
25 * @uses config_api.php
26 * @uses constant_inc.php
27 * @uses gpc_api.php
28 * @uses lang_api.php
29 * @uses news_api.php
30 * @uses project_api.php
31 * @uses rss_api.php
32 * @uses string_api.php
33 * @uses user_api.php
34 * @uses utility_api.php
35 * @uses rssbuilder/class.RSSBuilder.inc.php
38 /**
39 * MantisBT Core API's
41 require_once( 'core.php' );
42 require_api( 'access_api.php' );
43 require_api( 'config_api.php' );
44 require_api( 'constant_inc.php' );
45 require_api( 'gpc_api.php' );
46 require_api( 'lang_api.php' );
47 require_api( 'news_api.php' );
48 require_api( 'project_api.php' );
49 require_api( 'rss_api.php' );
50 require_api( 'string_api.php' );
51 require_api( 'user_api.php' );
52 require_api( 'utility_api.php' );
53 require_lib( 'rssbuilder' . DIRECTORY_SEPARATOR . 'class.RSSBuilder.inc.php' );
55 $f_username = gpc_get_string( 'username', null );
56 $f_key = gpc_get_string( 'key', null );
57 $f_project_id = gpc_get_int( 'project_id', ALL_PROJECTS );
59 news_ensure_enabled();
61 # make sure RSS syndication is enabled.
62 if ( OFF == config_get( 'rss_enabled' ) ) {
63 access_denied();
66 # authenticate the user
67 if ( $f_username !== null ) {
68 if ( !rss_login( $f_username, $f_key ) ) {
69 access_denied();
71 } else {
72 if ( OFF == config_get( 'allow_anonymous_login' ) ) {
73 access_denied();
77 # Make sure that the current user has access to the selected project (if not ALL PROJECTS).
78 if ( $f_project_id != ALL_PROJECTS ) {
79 access_ensure_project_level( VIEWER, $f_project_id );
82 # construct rss file
84 $encoding = 'utf-8';
85 $about = config_get( 'path' );
86 $title = string_rss_links( config_get( 'window_title' ) . ' - ' . lang_get( 'news' ) );
88 if ( $f_username !== null ) {
89 $title .= " - ($f_username)";
92 $description = $title;
93 $image_link = config_get( 'path' ) . 'images/mantis_logo_button.gif';
95 # only rss 2.0
96 $category = string_rss_links( project_get_name( $f_project_id ) );
98 # in minutes (only rss 2.0)
99 $cache = '60';
101 $rssfile = new RSSBuilder( $encoding, $about, $title, $description,
102 $image_link, $category, $cache);
104 # person, an organization, or a service
105 $publisher = '';
107 # person, an organization, or a service
108 $creator = '';
110 $date = (string) date( 'r' );
111 $language = lang_get( 'phpmailer_language' );
112 $rights = '';
114 # spatial location , temporal period or jurisdiction
115 $coverage = (string) '';
117 # person, an organization, or a service
118 $contributor = (string) '';
120 $rssfile->addDCdata( $publisher, $creator, $date, $language, $rights, $coverage, $contributor );
122 # hourly / daily / weekly / ...
123 $period = (string) 'daily';
125 # every X hours/days/...
126 $frequency = (int) 1;
128 $base = (string) date('Y-m-d\TH:i:sO');
130 # add missing : in the O part of the date. PHP 5 supports a 'c' format which will output the format
131 # exactly as we want it.
132 # // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
133 $base = utf8_substr( $base, 0, 22 ) . ':' . utf8_substr( $base, -2 );
135 $rssfile->addSYdata( $period, $frequency, $base );
137 $news_rows = news_get_limited_rows( 0 /* offset */, $f_project_id );
138 $t_news_count = count( $news_rows );
140 # Loop through results
141 for ( $i = 0; $i < $t_news_count; $i++ ) {
142 $row = $news_rows[$i];
143 extract( $row, EXTR_PREFIX_ALL, 'v' );
145 # skip news item if private, or
146 # belongs to a private project (will only happen
147 if ( VS_PRIVATE == $v_view_state ) {
148 continue;
151 $v_headline = string_rss_links( $v_headline );
152 $v_body = string_rss_links( $v_body );
154 $about = $link = config_get( 'path' ) . "news_view_page.php?news_id=$v_id";
155 $title = $v_headline;
156 $description = $v_body;
158 # optional DC value
159 $subject = $title;
161 # optional DC value
162 $date = $v_date_posted;
164 # author of item
165 $author = '';
166 if ( access_has_global_level( config_get( 'show_user_email_threshold' ) ) ) {
167 $t_author_name = string_rss_links( user_get_name( $v_poster_id ) );
168 $t_author_email = user_get_field( $v_poster_id, 'email' );
170 if ( !is_blank( $t_author_email ) ) {
171 if ( !is_blank( $t_author_name ) ) {
172 $author = $t_author_name . ' &lt;' . $t_author_email . '&gt;';
173 } else {
174 $author = $t_author_email;
179 # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1'; # url to comment page rss 2.0 value
180 $comments = '';
182 # optional mod_im value for dispaying a different pic for every item
183 $image = '';
185 $rssfile->addRSSItem( $about, $title, $link, $description, $subject, $date,
186 $author, $comments, $image);
189 /** @todo consider making this a configuration option - 0.91 / 1.0 / 2.0 */
190 $version = '2.0';
192 $rssfile->outputRSS( $version );