/
roadmap_page.php
241 lines (189 loc) · 8.17 KB
/
roadmap_page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net
# Mantis is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Mantis is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mantis. If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------
# $Id$
# --------------------------------------------------------
require_once( 'core.php' );
$t_core_path = config_get( 'core_path' );
require_once( $t_core_path.'bug_api.php' );
# Print header for the specified project version.
function print_version_header( $p_version_row ) {
$t_project_id = $p_version_row['project_id'];
$t_version_name = $p_version_row['version'];
$t_project_name = project_get_field( $t_project_id, 'name' );
$t_release_title = string_display( $t_project_name ) . ' - ' . string_display( $t_version_name );
echo '<tt>';
echo '<br />', $t_release_title, '<br />';
echo str_pad( '', strlen( $t_release_title ), '=' ), '<br />';
}
# print project header
function print_project_header( $p_project_name ) {
echo '<br /><span class="pagetitle">', string_display( $p_project_name ), ' - ', lang_get( 'roadmap' ), '</span><br />';
}
$t_user_id = auth_get_current_user_id();
$f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
if ( ALL_PROJECTS == $f_project_id ) {
$t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
foreach ( $t_topprojects as $t_project ) {
$t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
}
$t_project_ids_to_check = array_unique( $t_project_ids );
$t_project_ids = array();
foreach ( $t_project_ids_to_check as $t_project_id ) {
$t_roadmap_view_access_level = config_get( 'roadmap_view_threshold', null, null, $t_project_id );
if ( access_has_project_level( $t_roadmap_view_access_level, $t_project_id ) ) {
$t_project_ids[] = $t_project_id;
}
}
} else {
access_ensure_project_level( config_get( 'roadmap_view_threshold' ), $f_project_id );
$t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $f_project_id );
array_unshift( $t_project_ids, $f_project_id );
}
html_page_top1( lang_get( 'roadmap' ) ); // title
html_page_top2();
$t_project_index = 0;
foreach( $t_project_ids as $t_project_id ) {
$c_project_id = db_prepare_int( $t_project_id );
$t_project_name = project_get_field( $t_project_id, 'name' );
$t_can_view_private = access_has_project_level( config_get( 'private_bug_threshold' ), $t_project_id );
$t_limit_reporters = config_get( 'limit_reporters' );
$t_user_access_level_is_reporter = ( REPORTER == access_get_project_level( $t_project_id ) );
$t_resolved = config_get( 'bug_resolved_status_threshold' );
$t_bug_table = db_get_table( 'mantis_bug_table' );
$t_relation_table = db_get_table( 'mantis_bug_relationship_table' );
$t_version_rows = array_reverse( version_get_all_rows( $t_project_id ) );
$t_project_header_printed = false;
foreach( $t_version_rows as $t_version_row ) {
if ( $t_version_row['released'] == 1 ) {
continue;
}
$t_issues_planned = 0;
$t_issues_resolved = 0;
$t_issues_counted = array();
$t_version_header_printed = false;
$t_version = $t_version_row['version'];
$c_version = db_prepare_string( $t_version );
$query = "SELECT sbt.*, $t_relation_table.source_bug_id, dbt.target_version as parent_version FROM $t_bug_table AS sbt
LEFT JOIN $t_relation_table ON sbt.id=$t_relation_table.destination_bug_id AND $t_relation_table.relationship_type=2
LEFT JOIN $t_bug_table AS dbt ON dbt.id=$t_relation_table.source_bug_id
WHERE sbt.project_id=" . db_param(0) . " AND sbt.target_version=" . db_param(1) . " ORDER BY sbt.status ASC, sbt.last_updated DESC";
$t_description = $t_version_row['description'];
$t_first_entry = true;
$t_result = db_query_bound( $query, Array( $c_project_id, $c_version ) );
$t_issue_ids = array();
$t_issue_parents = array();
while ( $t_row = db_fetch_array( $t_result ) ) {
# hide private bugs if user doesn't have access to view them.
if ( !$t_can_view_private && ( $t_row['view_state'] == VS_PRIVATE ) ) {
continue;
}
bug_cache_database_result( $t_row );
# check limit_Reporter (Issue #4770)
# reporters can view just issues they reported
if ( ON === $t_limit_reporters && $t_user_access_level_is_reporter &&
!bug_is_user_reporter( $t_row['id'], $t_user_id )) {
continue;
}
$t_issue_id = $t_row['id'];
$t_issue_parent = $t_row['source_bug_id'];
$t_parent_version = $t_row['parent_version'];
if ( !helper_call_custom_function( 'roadmap_include_issue', array( $t_issue_id ) ) ) {
continue;
}
if ( !isset( $t_issues_counted[$t_issue_id] ) ) {
$t_issues_planned++;
if ( bug_is_resolved( $t_issue_id ) ) {
$t_issues_resolved++;
}
$t_issues_counted[$t_issue_id] = true;
}
if ( 0 === strcasecmp( $t_parent_version, $t_version ) ) {
$t_issue_ids[] = $t_issue_id;
$t_issue_parents[] = $t_issue_parent;
} else if ( !in_array( $t_issue_id, $t_issue_ids ) ) {
$t_issue_ids[] = $t_issue_id;
$t_issue_parents[] = null;
}
}
$t_progress = $t_issues_planned > 0 ? ( (integer) ( $t_issues_resolved * 100 / $t_issues_planned ) ) : 0;
if ( $t_issues_planned > 0 ) {
$t_progress = (integer) ( $t_issues_resolved * 100 / $t_issues_planned );
if ( !$t_project_header_printed ) {
print_project_header( $t_project_name );
$t_project_header_printed = true;
}
if ( !$t_version_header_printed ) {
print_version_header( $t_version_row );
$t_version_header_printed = true;
}
if ( !is_blank( $t_description ) ) {
echo string_display( '<br />' .$t_description . '<br />' );
}
// show progress bar
echo '<div class="progress400">';
echo ' <span class="bar" style="width: ' . $t_progress . '%;">' . $t_progress . '%</span>';
echo '</div>';
}
$t_issue_set_ids = array();
$t_issue_set_levels = array();
$k = 0;
while ( 0 < count( $t_issue_ids ) ) {
$t_issue_id = $t_issue_ids[$k];
$t_issue_parent = $t_issue_parents[$k];
if ( !in_array( $t_issue_parent, $t_issue_ids ) ) {
$l = array_search( $t_issue_parent, $t_issue_set_ids );
if ( $l !== false ) {
for ( $m = $l+1; $m < count( $t_issue_set_ids ) && $t_issue_set_levels[$m] > $t_issue_set_levels[$l]; $m++ ) {
#do nothing
}
$t_issue_set_ids_end = array_splice( $t_issue_set_ids, $m );
$t_issue_set_levels_end = array_splice( $t_issue_set_levels, $m );
$t_issue_set_ids[] = $t_issue_id;
$t_issue_set_levels[] = $t_issue_set_levels[$l] + 1;
$t_issue_set_ids = array_merge( $t_issue_set_ids, $t_issue_set_ids_end );
$t_issue_set_levels = array_merge( $t_issue_set_levels, $t_issue_set_levels_end );
}
else {
$t_issue_set_ids[] = $t_issue_id;
$t_issue_set_levels[] = 0;
}
array_splice( $t_issue_ids, $k, 1 );
array_splice( $t_issue_parents, $k, 1 );
}
else {
$k++;
}
if ( count( $t_issue_ids ) <= $k ) {
$k = 0;
}
}
for ( $j = 0; $j < count( $t_issue_set_ids ); $j++ ) {
$t_issue_set_id = $t_issue_set_ids[$j];
$t_issue_set_level = $t_issue_set_levels[$j];
helper_call_custom_function( 'roadmap_print_issue', array( $t_issue_set_id, $t_issue_set_level ) );
}
if ( $t_issues_planned > 0 ) {
echo '<br />';
echo sprintf( lang_get( 'resolved_progress' ), $t_issues_resolved, $t_issues_planned, $t_progress );
echo '<br /></tt>';
}
}
$t_project_index++;
}
html_page_bottom1( __FILE__ );
?>