1<?php
2# MantisBT - A PHP based bugtracking system
3
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.
8#
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.
13#
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/>.
16
17/**
18 * View all bugs include file
19 *
20 * @package MantisBT
21 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
24 *
25 * @uses category_api.php
26 * @uses columns_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses current_user_api.php
30 * @uses event_api.php
31 * @uses filter_api.php
32 * @uses gpc_api.php
33 * @uses helper_api.php
34 * @uses html_api.php
35 * @uses lang_api.php
36 * @uses print_api.php
37 */
38
39if( !defined( 'VIEW_ALL_INC_ALLOW' ) ) {
40	return;
41}
42
43require_api( 'category_api.php' );
44require_api( 'columns_api.php' );
45require_api( 'config_api.php' );
46require_api( 'constant_inc.php' );
47require_api( 'current_user_api.php' );
48require_api( 'event_api.php' );
49require_api( 'filter_api.php' );
50require_api( 'gpc_api.php' );
51require_api( 'helper_api.php' );
52require_api( 'html_api.php' );
53require_api( 'lang_api.php' );
54require_api( 'print_api.php' );
55
56$t_filter = current_user_get_bug_filter();
57filter_init( $t_filter );
58
59list( $t_sort, ) = explode( ',', $g_filter['sort'] );
60list( $t_dir, ) = explode( ',', $g_filter['dir'] );
61
62$g_checkboxes_exist = false;
63
64$t_current_project = helper_get_current_project();
65# Improve performance by caching category data in one pass
66if( $t_current_project > 0 ) {
67	category_get_all_rows( $t_current_project );
68}
69
70$g_columns = helper_get_columns_to_view( COLUMNS_TARGET_VIEW_PAGE );
71
72bug_cache_columns_data( $t_rows, $g_columns );
73
74$t_filter_position = config_get( 'filter_position' );
75
76# -- ====================== FILTER FORM ========================= --
77if( ( $t_filter_position & FILTER_POSITION_TOP ) == FILTER_POSITION_TOP ) {
78	filter_draw_selection_area();
79}
80# -- ====================== end of FILTER FORM ================== --
81
82
83# -- ====================== BUG LIST ============================ --
84
85?>
86<div class="col-md-12 col-xs-12">
87<div class="space-10"></div>
88<form id="bug_action" method="post" action="bug_actiongroup_page.php">
89<?php # CSRF protection not required here - form does not result in modifications ?>
90<div class="widget-box widget-color-blue2">
91	<div class="widget-header widget-header-small">
92	<h4 class="widget-title lighter">
93		<?php print_icon( 'fa-columns', 'ace-icon' ); ?>
94		<?php echo lang_get( 'viewing_bugs_title' ) ?>
95		<?php
96			# -- Viewing range info --
97			$v_start = 0;
98			$v_end = 0;
99			if (count($t_rows) > 0) {
100				$v_start = $g_filter['per_page'] * ($f_page_number - 1) + 1;
101				$v_end = $v_start + count($t_rows) - 1;
102			}
103			echo '<span class="badge"> ' . $v_start . ' - ' . $v_end . ' / ' . $t_bug_count . '</span>' ;
104		?>
105	</h4>
106	</div>
107
108	<div class="widget-body">
109
110	<div class="widget-toolbox padding-8 clearfix">
111		<div class="btn-toolbar">
112			<div class="btn-group pull-left">
113		<?php
114			$t_filter_param = filter_get_temporary_key_param( $t_filter );
115			if( empty( $t_filter_param ) ) {
116				$t_summary_link = 'view_all_set.php?summary=1&temporary=y';
117			} else {
118				$t_filter_param = '?' . $t_filter_param;
119				$t_summary_link = 'summary_page.php' . $t_filter_param;
120			}
121			# -- Print and Export links --
122			print_small_button( 'print_all_bug_page.php' . $t_filter_param, lang_get( 'print_all_bug_page_link' ) );
123			print_small_button( 'csv_export.php' . $t_filter_param, lang_get( 'csv_export' ) );
124			print_small_button( 'excel_xml_export.php' . $t_filter_param, lang_get( 'excel_export' ) );
125			if( access_has_project_level( config_get( 'view_summary_threshold' ), $t_current_project ) ) {
126				print_small_button( $t_summary_link, lang_get( 'summary_link' ) );
127			}
128
129			$t_event_menu_options = $t_links = event_signal('EVENT_MENU_FILTER');
130
131			foreach ($t_event_menu_options as $t_plugin => $t_plugin_menu_options) {
132				foreach ($t_plugin_menu_options as $t_callback => $t_callback_menu_options) {
133					if (!is_array($t_callback_menu_options)) {
134						$t_callback_menu_options = array($t_callback_menu_options);
135					}
136
137					foreach ($t_callback_menu_options as $t_menu_option) {
138						if ($t_menu_option) {
139							echo $t_menu_option;
140						}
141					}
142				}
143			}
144		?>
145		</div>
146		<div class="btn-group pull-right"><?php
147			# -- Page number links --
148			$t_tmp_filter_key = filter_get_temporary_key( $t_filter );
149			print_page_links( 'view_all_bug_page.php', 1, $t_page_count, (int)$f_page_number, $t_tmp_filter_key );
150			?>
151		</div>
152	</div>
153</div>
154
155<div class="widget-main no-padding">
156	<div class="table-responsive checkbox-range-selection">
157	<table id="buglist" class="table table-bordered table-condensed table-hover table-striped">
158	<thead>
159<?php # -- Bug list column header row -- ?>
160<tr class="buglist-headers">
161<?php
162	$t_title_function = 'print_column_title';
163	$t_sort_properties = filter_get_visible_sort_properties_array( $t_filter, COLUMNS_TARGET_VIEW_PAGE );
164	foreach( $g_columns as $t_column ) {
165		helper_call_custom_function( $t_title_function, array( $t_column, COLUMNS_TARGET_VIEW_PAGE, $t_sort_properties ) );
166	}
167?>
168</tr>
169
170</thead><tbody>
171
172<?php
173/**
174 * Output Bug Rows
175 *
176 * @param array $p_rows An array of bug objects.
177 * @return void
178 */
179function write_bug_rows( array $p_rows ) {
180	global $g_columns, $g_filter;
181
182	$t_in_stickies = ( $g_filter && ( 'on' == $g_filter[FILTER_PROPERTY_STICKY] ) );
183
184	# -- Loop over bug rows --
185
186	$t_rows = count( $p_rows );
187	for( $i=0; $i < $t_rows; $i++ ) {
188		$t_row = $p_rows[$i];
189
190		if( ( 0 == $t_row->sticky ) && ( 0 == $i ) ) {
191			$t_in_stickies = false;
192		}
193		if( ( 0 == $t_row->sticky ) && $t_in_stickies ) {	# demarcate stickies, if any have been shown
194?>
195		   <tr>
196				   <td colspan="<?php echo count( $g_columns ); ?>" bgcolor="#d3d3d3"></td>
197		   </tr>
198<?php
199			$t_in_stickies = false;
200		}
201
202		echo '<tr>';
203
204		$t_column_value_function = 'print_column_value';
205		foreach( $g_columns as $t_column ) {
206			helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row ) );
207		}
208		echo '</tr>';
209	}
210}
211
212
213write_bug_rows( $t_rows );
214# -- ====================== end of BUG LIST ========================= --
215?>
216
217</tbody>
218</table>
219</div>
220
221<div class="widget-toolbox padding-8 clearfix">
222<?php
223# -- ====================== MASS BUG MANIPULATION =================== --
224# @@@ ideally buglist-footer would be in <tfoot>, but that's not possible due to global g_checkboxes_exist set via write_bug_rows()
225?>
226	<div class="form-inline pull-left">
227<?php
228		if( $g_checkboxes_exist ) {
229			echo '<label class="inline">';
230			echo '<input class="ace check_all input-sm" type="checkbox" id="bug_arr_all" name="bug_arr_all" value="all" />';
231			echo '<span class="lbl padding-6">' . lang_get( 'select_all' ) . ' </span > ';
232			echo '</label>';
233		}
234		if( $g_checkboxes_exist ) {
235?>
236			<select name="action" class="input-sm">
237				<?php print_all_bug_action_option_list($t_unique_project_ids) ?>
238			</select>
239			<input type="submit" class="btn btn-primary btn-white btn-sm btn-round" value="<?php echo lang_get('ok'); ?>"/>
240<?php
241		} else {
242			echo '&#160;';
243		}
244?>
245			</div>
246			<div class="btn-group pull-right">
247				<?php
248					$t_tmp_filter_key = filter_get_temporary_key( $t_filter );
249					print_page_links('view_all_bug_page.php', 1, $t_page_count, (int)$f_page_number, $t_tmp_filter_key );
250				?>
251			</div>
252<?php # -- ====================== end of MASS BUG MANIPULATION ========================= -- ?>
253</div>
254
255</div>
256</div>
257</div>
258</form>
259</div>
260<?php
261
262# -- ====================== FILTER FORM ========================= --
263if( ( $t_filter_position & FILTER_POSITION_BOTTOM ) == FILTER_POSITION_BOTTOM ) {
264	filter_draw_selection_area();
265}
266# -- ====================== end of FILTER FORM ================== --
267