Skip to content
Newer
Older
100644 286 lines (228 sloc) 9.75 KB
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
1 <?php
2669909 @giallu Merge back to HEAD the changes between tags:
giallu authored
2 # Mantis - a php based bugtracking system
3
4 # Mantis 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 # Mantis 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 Mantis. If not, see <http://www.gnu.org/licenses/>.
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
16
526bbaa @grangeway Comment updates for phpdoc ( http://www.mantisforge.org/dev/phpdoc/ )…
grangeway authored
17 /**
18 * @package MantisBT
19 * @version $Id$
20 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
21 * @copyright Copyright (C) 2002 - 2008 Mantis Team - mantisbt-dev@lists.sourceforge.net
22 * @link http://www.mantisbt.org
23 */
24 /**
25 * Mantis Core API's
26 */
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
27 require_once( 'core.php' );
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
28
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
29 $t_core_path = config_get( 'core_path' );
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
30
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
31 require_once( $t_core_path.'bug_api.php' );
f62a011 @vboctor - 0004400: [feature] Changelog should view release notes (vboctor)
vboctor authored
32
33 # Print header for the specified project version.
34 function print_version_header( $p_version_id ) {
35 $t_project_id = version_get_field( $p_version_id, 'project_id' );
36 $t_version_name = version_get_field( $p_version_id, 'version' );
37 $t_project_name = project_get_field( $t_project_id, 'name' );
38
9fe7499 @jreese Fix changelog ===== lines to match appropriately.
jreese authored
39 $t_release_title_without_hyperlinks = string_display( $t_project_name ) . ' - ' . string_display( $t_version_name );
5806189 @vboctor Fixed #9708: Support linking to a changelog for a specific version
vboctor authored
40 $t_release_title = '<a href="changelog_page.php?project_id=' . $t_project_id . '">' . string_display( $t_project_name ) . '</a> - <a href="changelog_page.php?version_id=' . $p_version_id . '">' . string_display( $t_version_name ) . '</a>';
ef672f7 @jreese Resolved #8651: Display release date in changelog/roadmap for version…
jreese authored
41
42 if ( config_get( 'show_changelog_dates' ) ) {
43 $t_version_released = version_get_field( $p_version_id, 'released' );
44 $t_release_timestamp = version_get_field( $p_version_id, 'date_order' );
45
46 if ( (bool) $t_version_released ) {
47 $t_release_date = ' (' . strtolower( lang_get('released') ) . ' ' . date( config_get( 'short_date_format' ), $t_release_timestamp ) . ')';
48 } else {
49 $t_release_date = ' (' . strtolower( lang_get( 'not_released' ) ) . ')';
50 }
9fe7499 @jreese Fix changelog ===== lines to match appropriately.
jreese authored
51 } else {
52 $t_release_date = '';
ef672f7 @jreese Resolved #8651: Display release date in changelog/roadmap for version…
jreese authored
53 }
07c3712 @grangeway html tidy
grangeway authored
54
ef672f7 @jreese Resolved #8651: Display release date in changelog/roadmap for version…
jreese authored
55 echo '<br />', $t_release_title, $t_release_date, '<br />';
56
9fe7499 @jreese Fix changelog ===== lines to match appropriately.
jreese authored
57 $t_release_title_without_hyperlinks .= $t_scheduled_release_date;
58 echo str_pad( '', strlen( $t_release_title_without_hyperlinks ), '=' ), '<br />';
f62a011 @vboctor - 0004400: [feature] Changelog should view release notes (vboctor)
vboctor authored
59 }
aa6c71e @grangeway Fix: 0007131: Skip Blank Changelogs
grangeway authored
60
61 function print_project_header ( $p_project_name ) {
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
62 echo '<br /><span class="pagetitle">', string_display( $p_project_name ), ' - ', lang_get( 'changelog' ), '</span><br />';
07c3712 @grangeway html tidy
grangeway authored
63 echo '<tt>';
aa6c71e @grangeway Fix: 0007131: Skip Blank Changelogs
grangeway authored
64 }
f62a011 @vboctor - 0004400: [feature] Changelog should view release notes (vboctor)
vboctor authored
65
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
66 $t_user_id = auth_get_current_user_id();
5806189 @vboctor Fixed #9708: Support linking to a changelog for a specific version
vboctor authored
67 $f_version_id = gpc_get_int( 'version_id', -1 );
68 $f_project_id = gpc_get_int( 'project_id', -1 );
69
70 # If both version_id and project_id parameters are supplied, then version_id take precedence.
71 if ( $f_version_id == -1 ) {
72 if ( $f_project_id == -1 ) {
73 $t_project_id = helper_get_current_project();
74 } else {
75 $t_project_id = $f_project_id;
76 }
77 } else {
78 $t_project_id = version_get_field( $f_version_id, 'project_id' );
79 }
f62a011 @vboctor - 0004400: [feature] Changelog should view release notes (vboctor)
vboctor authored
80
5806189 @vboctor Fixed #9708: Support linking to a changelog for a specific version
vboctor authored
81 if ( ALL_PROJECTS == $t_project_id ) {
9221be9 Enh #5237: Support for subprojects that can be linked to several pare…
Jeroen Latour authored
82 $t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
83 foreach ( $t_topprojects as $t_project ) {
84 $t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
85 }
86
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
87 $t_project_ids_to_check = array_unique( $t_project_ids );
88 $t_project_ids = array();
89
90 foreach ( $t_project_ids_to_check as $t_project_id ) {
91 $t_changelog_view_access_level = config_get( 'view_changelog_threshold', null, null, $t_project_id );
92 if ( access_has_project_level( $t_changelog_view_access_level, $t_project_id ) ) {
93 $t_project_ids[] = $t_project_id;
94 }
95 }
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
96 } else {
5806189 @vboctor Fixed #9708: Support linking to a changelog for a specific version
vboctor authored
97 access_ensure_project_level( config_get( 'view_changelog_threshold' ), $t_project_id );
98 $t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $t_project_id );
99 array_unshift( $t_project_ids, $t_project_id );
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
100 }
101
102 html_page_top1( lang_get( 'changelog' ) ); // title
103 html_page_top2();
104
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
105 $t_project_index = 0;
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
106
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
107 foreach( $t_project_ids as $t_project_id ) {
108 $c_project_id = db_prepare_int( $t_project_id );
109 $t_project_name = project_get_field( $t_project_id, 'name' );
110 $t_can_view_private = access_has_project_level( config_get( 'private_bug_threshold' ), $t_project_id );
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
111
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
112 $t_limit_reporters = config_get( 'limit_reporters' );
71fffd1 @thraxisp fix for 005485: Change log only shows users reported issues, even if …
thraxisp authored
113 $t_user_access_level_is_reporter = ( REPORTER == access_get_project_level( $t_project_id ) );
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
114
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
115 $t_resolved = config_get( 'bug_resolved_status_threshold' );
1dcb585 @grangeway Add db_get_table / db_get_table_list functionality be reworking where…
grangeway authored
116 $t_bug_table = db_get_table( 'mantis_bug_table' );
117 $t_relation_table = db_get_table( 'mantis_bug_relationship_table' );
b47142e @vboctor Changed ChangeLog to text, added handler, added a custom function to …
vboctor authored
118
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
119 # grab version info for later use
de015b8 @vboctor Fixed #1910: Provide ability to make version obsolete.
vboctor authored
120 $t_version_rows = version_get_all_rows( $t_project_id, /* released */ null, /* obsolete */ false );
121
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
122 # cache category info, but ignore the results for now
123 category_get_all_rows( $t_project_id );
124
aa6c71e @grangeway Fix: 0007131: Skip Blank Changelogs
grangeway authored
125 $t_project_header_printed = false;
101bb15 @vboctor Enh #4066: Support "future" versions and a description field (vboctor)
vboctor authored
126
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
127 foreach( $t_version_rows as $t_version_row ) {
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
128 $t_issues_planned = 0;
129 $t_issues_resolved = 0;
130
131 $t_version_header_printed = false;
132
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
133 $t_version = $t_version_row['version'];
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
134
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
135 $t_version_id = $t_version_row['id'];
5806189 @vboctor Fixed #9708: Support linking to a changelog for a specific version
vboctor authored
136
137 # Skip all versions except the specified one (if any).
138 if ( $f_version_id != -1 && $f_version_id != $t_version_id ) {
139 continue;
140 }
f62a011 @vboctor - 0004400: [feature] Changelog should view release notes (vboctor)
vboctor authored
141
c50c321 @jreese Fix #8853: Issue appears more than once in the Roadmap for a release.
jreese authored
142 $query = "SELECT sbt.*, dbt.target_version AS parent_version, $t_relation_table.source_bug_id FROM $t_bug_table AS sbt
143 LEFT JOIN $t_relation_table ON sbt.id=$t_relation_table.destination_bug_id AND $t_relation_table.relationship_type=2
144 LEFT JOIN $t_bug_table AS dbt ON dbt.id=$t_relation_table.source_bug_id
9246296 @grangeway Simplify usage of db_param/db_aparam
grangeway authored
145 WHERE sbt.project_id=" . db_param() . " AND sbt.fixed_in_version=" . db_param() . " ORDER BY sbt.status ASC, sbt.last_updated DESC";
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
146
147 $t_description = version_get_field( $t_version_id, 'description' );
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
148
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
149 $t_first_entry = true;
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
150 $t_issue_ids = array();
151 $t_issue_parents = array();
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
152 $t_issue_handlers = array();
153
58a5e55 @grangeway Sync my db api changes with trunk. still working my way through code …
grangeway authored
154 $t_result = db_query_bound( $query, Array( $c_project_id, $t_version ) );
003e87e @vboctor Fixed #6888: Changelog doesn't work on MS SQL
vboctor authored
155
156 while ( $t_row = db_fetch_array( $t_result ) ) {
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
157 # hide private bugs if user doesn't have access to view them.
641e7a7 In config_inc.php set $g_limit_reporters = ON;
zakman authored
158 if ( !$t_can_view_private && ( $t_row['view_state'] == VS_PRIVATE ) ) {
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
159 continue;
160 }
b47142e @vboctor Changed ChangeLog to text, added handler, added a custom function to …
vboctor authored
161
003e87e @vboctor Fixed #6888: Changelog doesn't work on MS SQL
vboctor authored
162 bug_cache_database_result( $t_row );
e4d02d2 @grangeway Batch 3 of possible 'performance' commits - mainly based on simplifyi…
grangeway authored
163
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
164 # check limit_Reporter (Issue #4770)
165 # reporters can view just issues they reported
166 if ( ON === $t_limit_reporters && $t_user_access_level_is_reporter &&
641e7a7 In config_inc.php set $g_limit_reporters = ON;
zakman authored
167 !bug_is_user_reporter( $t_row['id'], $t_user_id )) {
003e87e @vboctor Fixed #6888: Changelog doesn't work on MS SQL
vboctor authored
168 continue;
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
169 }
1e88af2 @vboctor Enh #3870: Support for custom functions which provides hooks for cust…
vboctor authored
170
003e87e @vboctor Fixed #6888: Changelog doesn't work on MS SQL
vboctor authored
171 $t_issue_id = $t_row['id'];
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
172 $t_issue_parent = $t_row['source_bug_id'];
c50c321 @jreese Fix #8853: Issue appears more than once in the Roadmap for a release.
jreese authored
173 $t_parent_version = $t_row['parent_version'];
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
174
175 if ( !helper_call_custom_function( 'changelog_include_issue', array( $t_issue_id ) ) ) {
176 continue;
776353e @vboctor Enh #4036: [bugtracker] Changelog should not display versions with no…
vboctor authored
177 }
6e81d2a @grangeway *sigh*
grangeway authored
178
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
179 $t_issues_resolved++;
180
c50c321 @jreese Fix #8853: Issue appears more than once in the Roadmap for a release.
jreese authored
181 if ( 0 === strcasecmp( $t_parent_version, $t_version ) ) {
182 $t_issue_ids[] = $t_issue_id;
183 $t_issue_parents[] = $t_issue_parent;
184 } else if ( !in_array( $t_issue_id, $t_issue_ids ) ) {
185 $t_issue_ids[] = $t_issue_id;
186 $t_issue_parents[] = null;
187 }
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
188
189 $t_issue_handlers[] = $t_row['handler_id'];
3e76ef7 @grangeway 0008214: Change Log displays the version description as many times as…
grangeway authored
190 }
776353e @vboctor Enh #4036: [bugtracker] Changelog should not display versions with no…
vboctor authored
191
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
192 user_cache_array_rows( array_unique( $t_issue_handlers ) );
193
3e76ef7 @grangeway 0008214: Change Log displays the version description as many times as…
grangeway authored
194 if ( $t_issues_resolved > 0 ) {
195 if ( !$t_project_header_printed ) {
196 print_project_header( $t_project_name );
197 $t_project_header_printed = true;
198 }
101bb15 @vboctor Enh #4066: Support "future" versions and a description field (vboctor)
vboctor authored
199
3e76ef7 @grangeway 0008214: Change Log displays the version description as many times as…
grangeway authored
200 if ( !$t_version_header_printed ) {
201 print_version_header( $t_version_id );
202 $t_version_header_printed = true;
4f9717c @vboctor Implemented 5143: Possibility to extend the changelog
vboctor authored
203 }
204
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
205 if ( !is_blank( $t_description ) ) {
3e76ef7 @grangeway 0008214: Change Log displays the version description as many times as…
grangeway authored
206 echo string_display( "<br />$t_description<br /><br />" );
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
207 }
3e76ef7 @grangeway 0008214: Change Log displays the version description as many times as…
grangeway authored
208 }
209
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
210 $t_issue_set_ids = array();
211 $t_issue_set_levels = array();
212 $k = 0;
213
e980030 @jreese Fix #8931: Circle Relations cause roadmap to malfunction.
jreese authored
214 $t_cycle = false;
215 $t_cycle_ids = array();
216
299a4e1 @grangeway Reduce number of database queries, with some pre-caching
grangeway authored
217 while ( !empty( $t_issue_ids ) ) {
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
218 $t_issue_id = $t_issue_ids[$k];
219 $t_issue_parent = $t_issue_parents[$k];
220
195c160 @jreese Fixed logic error in roadmap/changelog.
jreese authored
221 if ( in_array( $t_issue_id, $t_cycle_ids ) && in_array( $t_issue_parent, $t_cycle_ids ) ) {
e980030 @jreese Fix #8931: Circle Relations cause roadmap to malfunction.
jreese authored
222 $t_cycle = true;
223 } else {
224 $t_cycle = false;
225 $t_cycle_ids[] = $t_issue_id;
226 }
227
228 if ( $t_cycle || !in_array( $t_issue_parent, $t_issue_ids ) ) {
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
229 $l = array_search( $t_issue_parent, $t_issue_set_ids );
230 if ( $l !== false ) {
231 for ( $m = $l+1; $m < count( $t_issue_set_ids ) && $t_issue_set_levels[$m] > $t_issue_set_levels[$l]; $m++ ) {
232 #do nothing
233 }
234 $t_issue_set_ids_end = array_splice( $t_issue_set_ids, $m );
235 $t_issue_set_levels_end = array_splice( $t_issue_set_levels, $m );
236 $t_issue_set_ids[] = $t_issue_id;
237 $t_issue_set_levels[] = $t_issue_set_levels[$l] + 1;
238 $t_issue_set_ids = array_merge( $t_issue_set_ids, $t_issue_set_ids_end );
239 $t_issue_set_levels = array_merge( $t_issue_set_levels, $t_issue_set_levels_end );
240 }
241 else {
242 $t_issue_set_ids[] = $t_issue_id;
243 $t_issue_set_levels[] = 0;
244 }
245 array_splice( $t_issue_ids, $k, 1 );
246 array_splice( $t_issue_parents, $k, 1 );
e980030 @jreese Fix #8931: Circle Relations cause roadmap to malfunction.
jreese authored
247
248 $t_cycle_ids = array();
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
249 }
250 else {
251 $k++;
252 }
253 if ( count( $t_issue_ids ) <= $k ) {
254 $k = 0;
255 }
256 }
257
258 for ( $j = 0; $j < count( $t_issue_set_ids ); $j++ ) {
259 $t_issue_set_id = $t_issue_set_ids[$j];
260 $t_issue_set_level = $t_issue_set_levels[$j];
261
262 helper_call_custom_function( 'changelog_print_issue', array( $t_issue_set_id, $t_issue_set_level ) );
776353e @vboctor Enh #4036: [bugtracker] Changelog should not display versions with no…
vboctor authored
263 }
264
ef672f7 @jreese Resolved #8651: Display release date in changelog/roadmap for version…
jreese authored
265 if ( $t_issues_resolved == 1 ) {
266 echo "[{$t_issues_resolved} " . lang_get( 'bug' ) . ']';
267 echo "<br />";
268 } else if ( $t_issues_resolved > 1 ) {
269 echo "[{$t_issues_resolved} " . lang_get( 'bugs' ) . ']';
270 echo "<br />";
271 }
272
07c3712 @grangeway html tidy
grangeway authored
273 }
274 if ( $t_project_header_printed ) {
aa6c71e @grangeway Fix: 0007131: Skip Blank Changelogs
grangeway authored
275 echo '</tt>';
07c3712 @grangeway html tidy
grangeway authored
276 }
1d2dc20 @grangeway 0008194: Roadmap and Changelog list nesting for parent/child issues
grangeway authored
277
278 $t_project_index++;
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
279 }
280
aa6c71e @grangeway Fix: 0007131: Skip Blank Changelogs
grangeway authored
281 if ( $t_project_index == 0 ) {
282 echo '<br /><span class="pagetitle">' . lang_get('changelog_empty') . '</span>';
283 }
0d3a01c @vboctor End #3638: The bugtracker should be able to produce a changelog.
vboctor authored
284 html_page_bottom1( __FILE__ );
7c263d9 As proposed on the mailing list, all text files now get the svn:eol-s…
Martin Fuchs authored
285 ?>
Something went wrong with that request. Please try again.