SOAP API: do not try to unserialize an invalid filter
[mantis.git] / bugnote_view_inc.php
bloba6581bf249b640e37dc0714e526eeef93335df82
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 * This include file prints out the list of bugnotes attached to the bug
19 * $f_bug_id must be set and be set to the bug id
21 * @package MantisBT
22 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
23 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
24 * @link http://www.mantisbt.org
26 * @uses access_api.php
27 * @uses authentication_api.php
28 * @uses bug_api.php
29 * @uses bug_revision_api.php
30 * @uses bugnote_api.php
31 * @uses collapse_api.php
32 * @uses config_api.php
33 * @uses constant_inc.php
34 * @uses current_user_api.php
35 * @uses database_api.php
36 * @uses event_api.php
37 * @uses helper_api.php
38 * @uses lang_api.php
39 * @uses prepare_api.php
40 * @uses print_api.php
41 * @uses string_api.php
42 * @uses user_api.php
45 if ( !defined( 'BUGNOTE_VIEW_INC_ALLOW' ) ) {
46 return;
49 require_api( 'access_api.php' );
50 require_api( 'authentication_api.php' );
51 require_api( 'bug_api.php' );
52 require_api( 'bug_revision_api.php' );
53 require_api( 'bugnote_api.php' );
54 require_api( 'collapse_api.php' );
55 require_api( 'config_api.php' );
56 require_api( 'constant_inc.php' );
57 require_api( 'current_user_api.php' );
58 require_api( 'database_api.php' );
59 require_api( 'event_api.php' );
60 require_api( 'helper_api.php' );
61 require_api( 'lang_api.php' );
62 require_api( 'prepare_api.php' );
63 require_api( 'print_api.php' );
64 require_api( 'string_api.php' );
65 require_api( 'user_api.php' );
67 # grab the user id currently logged in
68 $t_user_id = auth_get_current_user_id();
70 #precache access levels
71 if ( isset( $g_project_override ) ) {
72 access_cache_matrix_project( $g_project_override );
73 } else {
74 access_cache_matrix_project( helper_get_current_project() );
77 # get the bugnote data
78 $t_bugnote_order = current_user_get_pref( 'bugnote_order' );
79 $t_bugnotes = bugnote_get_all_visible_bugnotes( $f_bug_id, $t_bugnote_order, 0, $t_user_id );
81 #precache users
82 $t_bugnote_users = array();
83 foreach($t_bugnotes as $t_bugnote) {
84 $t_bugnote_users[] = $t_bugnote->reporter_id;
86 user_cache_array_rows( $t_bugnote_users );
88 $num_notes = count( $t_bugnotes );
91 <?php # Bugnotes BEGIN ?>
92 <a id="bugnotes"></a><br />
94 <?php
95 collapse_open( 'bugnotes' );
97 <table class="bugnotes width100" cellspacing="1">
98 <tr>
99 <td class="form-title" colspan="2">
100 <?php
101 collapse_icon( 'bugnotes' ); ?>
102 <?php echo lang_get( 'bug_notes_title' ) ?>
103 </td>
104 </tr>
105 <?php
106 # no bugnotes
107 if ( 0 == $num_notes ) {
109 <tr class="bugnotes-empty">
110 <td class="center" colspan="2">
111 <?php echo lang_get( 'no_bugnotes_msg' ) ?>
112 </td>
113 </tr>
114 <?php }
116 event_signal( 'EVENT_VIEW_BUGNOTES_START', array( $f_bug_id, $t_bugnotes ) );
118 $t_normal_date_format = config_get( 'normal_date_format' );
119 $t_total_time = 0;
121 $t_bugnote_user_edit_threshold = config_get( 'bugnote_user_edit_threshold' );
122 $t_bugnote_user_delete_threshold = config_get( 'bugnote_user_delete_threshold' );
123 $t_bugnote_user_change_view_state_threshold = config_get( 'bugnote_user_change_view_state_threshold' );
124 $t_can_edit_all_bugnotes = access_has_bug_level( config_get( 'update_bugnote_threshold' ), $f_bug_id );
125 $t_can_delete_all_bugnotes = access_has_bug_level( config_get( 'delete_bugnote_threshold' ), $f_bug_id );
126 $t_can_change_view_state_all_bugnotes = $t_can_edit_all_bugnotes && access_has_bug_level( config_get( 'change_view_status_threshold' ), $f_bug_id );
128 for ( $i=0; $i < $num_notes; $i++ ) {
129 $t_bugnote = $t_bugnotes[$i];
131 if ( $t_bugnote->date_submitted != $t_bugnote->last_modified )
132 $t_bugnote_modified = true;
133 else
134 $t_bugnote_modified = false;
136 $t_bugnote_id_formatted = bugnote_format_id( $t_bugnote->id );
138 if ( 0 != $t_bugnote->time_tracking ) {
139 $t_time_tracking_hhmm = db_minutes_to_hhmm( $t_bugnote->time_tracking );
140 $t_bugnote->note_type = TIME_TRACKING; // for older entries that didn't set the type @@@PLR FIXME
141 $t_total_time += $t_bugnote->time_tracking;
142 } else {
143 $t_time_tracking_hhmm = '';
146 if ( VS_PRIVATE == $t_bugnote->view_state ) {
147 $t_bugnote_css = 'bugnote-private';
148 } else {
149 $t_bugnote_css = 'bugnote-public';
152 if ( TIME_TRACKING == $t_bugnote->note_type ) {
153 $t_bugnote_css .= ' bugnote-time-tracking';
154 } else if ( REMINDER == $t_bugnote->note_type ) {
155 $t_bugnote_css .= ' bugnote-reminder';
158 <tr class="bugnote <?php echo $t_bugnote_css ?>" id="c<?php echo $t_bugnote->id ?>">
159 <td class="bugnote-meta">
160 <?php if ( ON == config_get("show_avatar") ) print_avatar( $t_bugnote->reporter_id ); ?>
161 <span class="small bugnote-permalink"><a rel="bookmark" href="<?php echo string_get_bugnote_view_url($t_bugnote->bug_id, $t_bugnote->id) ?>" title="<?php echo lang_get( 'bugnote_link_title' ) ?>"><?php echo htmlentities( config_get_global( 'bugnote_link_tag' ) ) . $t_bugnote_id_formatted ?></a></span><br />
163 <span class="bugnote-reporter">
164 <?php
165 echo print_user( $t_bugnote->reporter_id );
167 <span class="small access-level"><?php
168 if ( user_exists( $t_bugnote->reporter_id ) ) {
169 $t_access_level = access_get_project_level( null, (int)$t_bugnote->reporter_id );
170 echo '(', get_enum_element( 'access_levels', $t_access_level ), ')';
172 ?></span>
173 </span>
175 <?php if ( VS_PRIVATE == $t_bugnote->view_state ) { ?>
176 <span class="small bugnote-view-state">[ <?php echo lang_get( 'private' ) ?> ]</span>
177 <?php } ?>
178 <br />
179 <span class="small bugnote-date-submitted"><?php echo date( $t_normal_date_format, $t_bugnote->date_submitted ); ?></span><br />
180 <?php
181 if ( $t_bugnote_modified ) {
182 echo '<span class="small bugnote-last-modified">' . lang_get( 'last_edited') . lang_get( 'word_separator' ) . date( $t_normal_date_format, $t_bugnote->last_modified ) . '</span><br />';
183 $t_revision_count = bug_revision_count( $f_bug_id, REV_BUGNOTE, $t_bugnote->id );
184 if ( $t_revision_count >= 1) {
185 $t_view_num_revisions_text = sprintf( lang_get( 'view_num_revisions' ), $t_revision_count );
186 echo '<span class="small bugnote-revisions-link"><a href="bug_revision_view_page.php?bugnote_id=' . $t_bugnote->id . '">' . $t_view_num_revisions_text . '</a></span><br />';
190 <br /><div class="small bugnote-buttons">
191 <?php
192 # bug must be open to be editable
193 if ( !bug_is_readonly( $f_bug_id ) ) {
195 # check if the user can edit this bugnote
196 if ( $t_user_id == $t_bugnote->reporter_id ) {
197 $t_can_edit_bugnote = access_has_bugnote_level( $t_bugnote_user_edit_threshold, $t_bugnote->id );
198 } else {
199 $t_can_edit_bugnote = $t_can_edit_all_bugnotes;
202 # check if the user can delete this bugnote
203 if ( $t_user_id == $t_bugnote->reporter_id ) {
204 $t_can_delete_bugnote = access_has_bugnote_level( $t_bugnote_user_delete_threshold, $t_bugnote->id );
205 } else {
206 $t_can_delete_bugnote = $t_can_delete_all_bugnotes;
209 # check if the user can make this bugnote private
210 if ( $t_user_id == $t_bugnote->reporter_id ) {
211 $t_can_change_view_state = access_has_bugnote_level( $t_bugnote_user_change_view_state_threshold, $t_bugnote->id );
212 } else {
213 $t_can_change_view_state = $t_can_change_view_state_all_bugnotes;
216 # show edit button if the user is allowed to edit this bugnote
217 if ( $t_can_edit_bugnote ) {
218 print_button( 'bugnote_edit_page.php?bugnote_id='.$t_bugnote->id, lang_get( 'bugnote_edit_link' ) );
221 # show delete button if the user is allowed to delete this bugnote
222 if ( $t_can_delete_bugnote ) {
223 print_button( 'bugnote_delete.php?bugnote_id='.$t_bugnote->id, lang_get( 'delete_link' ) );
226 # show make public or make private button if the user is allowed to change the view state of this bugnote
227 if ( $t_can_change_view_state ) {
228 if ( VS_PRIVATE == $t_bugnote->view_state ) {
229 print_button( 'bugnote_set_view_state.php?private=0&bugnote_id=' . $t_bugnote->id, lang_get( 'make_public' ) );
230 } else {
231 print_button( 'bugnote_set_view_state.php?private=1&bugnote_id=' . $t_bugnote->id, lang_get( 'make_private' ) );
236 </div>
237 </td>
238 <td class="bugnote-note">
239 <?php
240 switch ( $t_bugnote->note_type ) {
241 case REMINDER:
242 echo '<em>' . lang_get( 'reminder_sent_to' ) . ' ';
243 $t_note_attr = utf8_substr( $t_bugnote->note_attr, 1, utf8_strlen( $t_bugnote->note_attr ) - 2 );
244 $t_to = array();
245 foreach ( explode( '|', $t_note_attr ) as $t_recipient ) {
246 $t_to[] = prepare_user_name( $t_recipient );
248 echo implode( ', ', $t_to ) . '</em><br /><br />';
249 case TIME_TRACKING:
250 if ( access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id ) ) {
251 echo '<div class="time-tracked">', $t_time_tracking_hhmm, '</div>';
253 break;
256 echo string_display_links( $t_bugnote->note );;
258 </td>
259 </tr>
260 <?php event_signal( 'EVENT_VIEW_BUGNOTE', array( $f_bug_id, $t_bugnote->id, VS_PRIVATE == $t_bugnote->view_state ) ); ?>
261 <tr class="spacer">
262 <td colspan="2"></td>
263 </tr>
264 <?php
265 } # end for loop
267 event_signal( 'EVENT_VIEW_BUGNOTES_END', $f_bug_id );
269 </table>
270 <?php
272 if ( $t_total_time > 0 && access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id ) ) {
273 echo '<p class="time-tracking-total">', sprintf ( lang_get( 'total_time_for_issue' ), '<span class="time-tracked">' . db_minutes_to_hhmm( $t_total_time ) . '</span>' ), '</p>';
275 collapse_closed( 'bugnotes' );
278 <table class="width100" cellspacing="1">
279 <tr>
280 <td class="form-title" colspan="2">
281 <?php collapse_icon( 'bugnotes' ); ?>
282 <?php echo lang_get( 'bug_notes_title' ) ?>
283 </td>
284 </tr>
285 </table>
286 <?php
287 collapse_end( 'bugnotes' );