Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 193 lines (152 sloc) 5.461 kb
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
1 <?php
77f2e2a @davidhicks Fix capitalisation in header license comment
davidhicks authored
2 # MantisBT - A PHP based bugtracking system
2669909 @giallu Merge back to HEAD the changes between tags:
giallu authored
3
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
4 # MantisBT is free software: you can redistribute it and/or modify
2669909 @giallu Merge back to HEAD the changes between tags:
giallu authored
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 #
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
9 # MantisBT is distributed in the hope that it will be useful,
2669909 @giallu Merge back to HEAD the changes between tags:
giallu authored
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
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
16
2d5455c @davidhicks Use require_api/require_lib to pull in dependencies
davidhicks authored
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
22 *
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
36 */
638dcd0 Fixed inconsistencies in line-endings
Jeroen Latour authored
37
cd2325c @grangeway Try to fix PHPDoc errors
grangeway authored
38 /**
39 * MantisBT Core API's
40 */
2d5455c @davidhicks Use require_api/require_lib to pull in dependencies
davidhicks authored
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' );
0dae1ce @vboctor Fixed #6757: Allow RSS syndication without allowing anonymous login..
vboctor authored
54
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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 );
0dae1ce @vboctor Fixed #6757: Allow RSS syndication without allowing anonymous login..
vboctor authored
58
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
59 news_ensure_enabled();
fe66a36 @vboctor Fixes #10506: Provide the ability to disable the News feature.
vboctor authored
60
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
61 # make sure RSS syndication is enabled.
62 if ( OFF == config_get( 'rss_enabled' ) ) {
63 access_denied();
64 }
65
66 # authenticate the user
67 if ( $f_username !== null ) {
68 if ( !rss_login( $f_username, $f_key ) ) {
a9a46fd @vboctor Fixed #6987: Add $g_rss_enabled configuration option
vboctor authored
69 access_denied();
70 }
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
71 } else {
72 if ( OFF == config_get( 'allow_anonymous_login' ) ) {
73 access_denied();
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
74 }
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
75 }
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
76
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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 );
80 }
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
81
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
82 # construct rss file
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
83
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
84 $encoding = 'utf-8';
85 $about = config_get( 'path' );
86 $title = string_rss_links( config_get( 'window_title' ) . ' - ' . lang_get( 'news' ) );
0dae1ce @vboctor Fixed #6757: Allow RSS syndication without allowing anonymous login..
vboctor authored
87
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
88 if ( $f_username !== null ) {
89 $title .= " - ($f_username)";
90 }
0dae1ce @vboctor Fixed #6757: Allow RSS syndication without allowing anonymous login..
vboctor authored
91
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
92 $description = $title;
93 $image_link = config_get( 'path' ) . 'images/mantis_logo_button.gif';
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
94
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
95 # only rss 2.0
96 $category = string_rss_links( project_get_name( $f_project_id ) );
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
97
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
98 # in minutes (only rss 2.0)
99 $cache = '60';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
100
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
101 $rssfile = new RSSBuilder( $encoding, $about, $title, $description,
102 $image_link, $category, $cache);
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
103
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
104 # person, an organization, or a service
105 $publisher = '';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
106
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
107 # person, an organization, or a service
108 $creator = '';
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
109
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
110 $date = (string) date( 'r' );
111 $language = lang_get( 'phpmailer_language' );
112 $rights = '';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
113
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
114 # spatial location , temporal period or jurisdiction
115 $coverage = (string) '';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
116
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
117 # person, an organization, or a service
118 $contributor = (string) '';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
119
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
120 $rssfile->addDCdata( $publisher, $creator, $date, $language, $rights, $coverage, $contributor );
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
121
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
122 # hourly / daily / weekly / ...
123 $period = (string) 'daily';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
124
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
125 # every X hours/days/...
126 $frequency = (int) 1;
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
127
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
128 $base = (string) date('Y-m-d\TH:i:sO');
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
129
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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 );
d312f89 @vboctor Fixed #5754: RSS Feed does not validate.
vboctor authored
134
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
135 $rssfile->addSYdata( $period, $frequency, $base );
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
136
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
137 $news_rows = news_get_limited_rows( 0 /* offset */, $f_project_id );
138 $t_news_count = count( $news_rows );
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
139
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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' );
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
144
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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;
149 }
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
150
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
151 $v_headline = string_rss_links( $v_headline );
152 $v_body = string_rss_links( $v_body );
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
153
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
154 $about = $link = config_get( 'path' ) . "news_view_page.php?news_id=$v_id";
155 $title = $v_headline;
156 $description = $v_body;
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
157
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
158 # optional DC value
159 $subject = $title;
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
160
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
161 # optional DC value
162 $date = $v_date_posted;
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
163
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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' );
9fc04be @vboctor Fixes #10947: Entries in RSS feed show theusername@example.com + a PH…
vboctor authored
169
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
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;
d312f89 @vboctor Fixed #5754: RSS Feed does not validate.
vboctor authored
175 }
176 }
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
177 }
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
178
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
179 # $comments = 'http://www.example.com/sometext.php?somevariable=somevalue&comments=1'; # url to comment page rss 2.0 value
180 $comments = '';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
181
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
182 # optional mod_im value for dispaying a different pic for every item
183 $image = '';
61b0441 @vboctor Some minor issues relating to news syndication.
vboctor authored
184
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
185 $rssfile->addRSSItem( $about, $title, $link, $description, $subject, $date,
186 $author, $comments, $image);
187 }
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
188
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
189 /** @todo consider making this a configuration option - 0.91 / 1.0 / 2.0 */
190 $version = '2.0';
a9becc6 @vboctor Fixed #3548: Support RSS for news syndication.
vboctor authored
191
a472727 Improve indentation - left inconsistent by previous recent commits.
unknown authored
192 $rssfile->outputRSS( $version );
Something went wrong with that request. Please try again.