Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / bugnote_view_inc.php
blob3206383c41eeb4bbce447b8b1c3b67364aab98e7
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 - 2010 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 require_api( 'access_api.php' );
46 require_api( 'authentication_api.php' );
47 require_api( 'bug_api.php' );
48 require_api( 'bug_revision_api.php' );
49 require_api( 'bugnote_api.php' );
50 require_api( 'collapse_api.php' );
51 require_api( 'config_api.php' );
52 require_api( 'constant_inc.php' );
53 require_api( 'current_user_api.php' );
54 require_api( 'database_api.php' );
55 require_api( 'event_api.php' );
56 require_api( 'helper_api.php' );
57 require_api( 'lang_api.php' );
58 require_api( 'prepare_api.php' );
59 require_api( 'print_api.php' );
60 require_api( 'string_api.php' );
61 require_api( 'user_api.php' );
63 # grab the user id currently logged in
64 $t_user_id = auth_get_current_user_id();
66 #precache access levels
67 if ( isset( $g_project_override ) ) {
68 access_cache_matrix_project( $g_project_override );
69 } else {
70 access_cache_matrix_project( helper_get_current_project() );
73 # get the bugnote data
74 $t_bugnote_order = current_user_get_pref( 'bugnote_order' );
75 $t_bugnotes = bugnote_get_all_visible_bugnotes( $f_bug_id, $t_bugnote_order, 0, $t_user_id );
77 #precache users
78 $t_bugnote_users = array();
79 foreach($t_bugnotes as $t_bugnote) {
80 $t_bugnote_users[] = $t_bugnote->reporter_id;
82 user_cache_array_rows( $t_bugnote_users );
84 $num_notes = count( $t_bugnotes );
87 <?php # Bugnotes BEGIN ?>
88 <a name="bugnotes" id="bugnotes" /><br />
90 <?php
91 collapse_open( 'bugnotes' );
93 <table class="width100" cellspacing="1">
94 <tr>
95 <td class="form-title" colspan="2">
96 <?php
97 collapse_icon( 'bugnotes' ); ?>
98 <?php echo lang_get( 'bug_notes_title' ) ?>
99 </td>
100 </tr>
101 <?php
102 # no bugnotes
103 if ( 0 == $num_notes ) {
105 <tr>
106 <td class="center" colspan="2">
107 <?php echo lang_get( 'no_bugnotes_msg' ) ?>
108 </td>
109 </tr>
110 <?php }
112 event_signal( 'EVENT_VIEW_BUGNOTES_START', array( $f_bug_id, $t_bugnotes ) );
114 $t_normal_date_format = config_get( 'normal_date_format' );
115 $t_total_time = 0;
117 $t_bugnote_user_edit_threshold = config_get( 'bugnote_user_edit_threshold' );
118 $t_bugnote_user_delete_threshold = config_get( 'bugnote_user_delete_threshold' );
119 $t_bugnote_user_change_view_state_threshold = config_get( 'bugnote_user_change_view_state_threshold' );
120 $t_can_edit_all_bugnotes = access_has_bug_level( config_get( 'update_bugnote_threshold' ), $f_bug_id );
121 $t_can_delete_all_bugnotes = access_has_bug_level( config_get( 'delete_bugnote_threshold' ), $f_bug_id );
122 $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 );
124 for ( $i=0; $i < $num_notes; $i++ ) {
125 $t_bugnote = $t_bugnotes[$i];
127 if ( $t_bugnote->date_submitted != $t_bugnote->last_modified )
128 $t_bugnote_modified = true;
129 else
130 $t_bugnote_modified = false;
132 $t_bugnote_id_formatted = bugnote_format_id( $t_bugnote->id );
134 if ( 0 != $t_bugnote->time_tracking ) {
135 $t_time_tracking_hhmm = db_minutes_to_hhmm( $t_bugnote->time_tracking );
136 $t_bugnote->note_type = TIME_TRACKING; // for older entries that didn't set the type @@@PLR FIXME
137 $t_total_time += $t_bugnote->time_tracking;
138 } else {
139 $t_time_tracking_hhmm = '';
142 if ( VS_PRIVATE == $t_bugnote->view_state ) {
143 $t_bugnote_css = 'bugnote-private';
144 $t_bugnote_note_css = 'bugnote-note-private';
145 } else {
146 $t_bugnote_css = 'bugnote-public';
147 $t_bugnote_note_css = 'bugnote-note-public';
150 <tr class="bugnote" id="c<?php echo $t_bugnote->id ?>">
151 <td class="<?php echo $t_bugnote_css ?>">
152 <?php if ( ON == config_get("show_avatar") ) print_avatar( $t_bugnote->reporter_id ); ?>
153 <span class="small">(<a 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 $t_bugnote_id_formatted ?>)</a></span><br />
154 <?php
155 echo print_user( $t_bugnote->reporter_id );
157 <span class="small"><?php
158 if ( user_exists( $t_bugnote->reporter_id ) ) {
159 $t_access_level = access_get_project_level( null, (int)$t_bugnote->reporter_id );
160 echo '(', get_enum_element( 'access_levels', $t_access_level ), ')';
162 ?></span>
163 <?php if ( VS_PRIVATE == $t_bugnote->view_state ) { ?>
164 <span class="small">[ <?php echo lang_get( 'private' ) ?> ]</span>
165 <?php } ?>
166 <br />
167 <span class="small"><?php echo date( $t_normal_date_format, $t_bugnote->date_submitted ); ?></span><br />
168 <?php
169 if ( $t_bugnote_modified ) {
170 echo '<span class="small">' . lang_get( 'last_edited') . lang_get( 'word_separator' ) . date( $t_normal_date_format, $t_bugnote->last_modified ) . '</span><br />';
171 $t_revision_count = bug_revision_count( $f_bug_id, REV_BUGNOTE, $t_bugnote->id );
172 if ( $t_revision_count >= 1) {
173 $t_view_num_revisions_text = sprintf( lang_get( 'view_num_revisions' ), $t_revision_count );
174 echo '<span class="small"><a href="bug_revision_view_page.php?bugnote_id=' . $t_bugnote->id . '">' . $t_view_num_revisions_text . '</a></span><br />';
178 <br /><div class="small">
179 <?php
180 # bug must be open to be editable
181 if ( !bug_is_readonly( $f_bug_id ) ) {
183 # check if the user can edit this bugnote
184 if ( $t_user_id == $t_bugnote->reporter_id ) {
185 $t_can_edit_bugnote = access_has_bugnote_level( $t_bugnote_user_edit_threshold, $t_bugnote->id );
186 } else {
187 $t_can_edit_bugnote = $t_can_edit_all_bugnotes;
190 # check if the user can delete this bugnote
191 if ( $t_user_id == $t_bugnote->reporter_id ) {
192 $t_can_delete_bugnote = access_has_bugnote_level( $t_bugnote_user_delete_threshold, $t_bugnote->id );
193 } else {
194 $t_can_delete_bugnote = $t_can_delete_all_bugnotes;
197 # check if the user can make this bugnote private
198 if ( $t_user_id == $t_bugnote->reporter_id ) {
199 $t_can_change_view_state = access_has_bugnote_level( $t_bugnote_user_change_view_state_threshold, $t_bugnote->id );
200 } else {
201 $t_can_change_view_state = $t_can_change_view_state_all_bugnotes;
204 # show edit button if the user is allowed to edit this bugnote
205 if ( $t_can_edit_bugnote ) {
206 print_button( 'bugnote_edit_page.php?bugnote_id='.$t_bugnote->id, lang_get( 'bugnote_edit_link' ) );
209 # show delete button if the user is allowed to delete this bugnote
210 if ( $t_can_delete_bugnote ) {
211 print_button( 'bugnote_delete.php?bugnote_id='.$t_bugnote->id, lang_get( 'delete_link' ) );
214 # show make public or make private button if the user is allowed to change the view state of this bugnote
215 if ( $t_can_change_view_state ) {
216 if ( VS_PRIVATE == $t_bugnote->view_state ) {
217 print_button( 'bugnote_set_view_state.php?private=0&bugnote_id=' . $t_bugnote->id, lang_get( 'make_public' ) );
218 } else {
219 print_button( 'bugnote_set_view_state.php?private=1&bugnote_id=' . $t_bugnote->id, lang_get( 'make_private' ) );
224 </div>
225 </td>
226 <td class="<?php echo $t_bugnote_note_css ?>">
227 <?php
228 switch ( $t_bugnote->note_type ) {
229 case REMINDER:
230 echo '<em>' . lang_get( 'reminder_sent_to' ) . ' ';
231 $t_note_attr = utf8_substr( $t_bugnote->note_attr, 1, utf8_strlen( $t_bugnote->note_attr ) - 2 );
232 $t_to = array();
233 foreach ( explode( '|', $t_note_attr ) as $t_recipient ) {
234 $t_to[] = prepare_user_name( $t_recipient );
236 echo implode( ', ', $t_to ) . '</em><br /><br />';
237 case TIME_TRACKING:
238 if ( access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id ) ) {
239 echo '<b><big>', $t_time_tracking_hhmm, '</big></b><br /><br />';
241 break;
244 echo string_display_links( $t_bugnote->note );;
246 </td>
247 </tr>
248 <?php event_signal( 'EVENT_VIEW_BUGNOTE', array( $f_bug_id, $t_bugnote->id, VS_PRIVATE == $t_bugnote->view_state ) ); ?>
249 <tr class="spacer">
250 <td colspan="2"></td>
251 </tr>
252 <?php
253 } # end for loop
255 if ( $t_total_time > 0 && access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id ) ) {
256 echo '<tr><td colspan="2">', sprintf ( lang_get( 'total_time_for_issue' ), db_minutes_to_hhmm( $t_total_time ) ), '</td></tr>';
259 event_signal( 'EVENT_VIEW_BUGNOTES_END', $f_bug_id );
261 </table>
263 <?php
264 collapse_closed( 'bugnotes' );
267 <table class="width100" cellspacing="1">
268 <tr>
269 <td class="form-title" colspan="2">
270 <?php collapse_icon( 'bugnotes' ); ?>
271 <?php echo lang_get( 'bug_notes_title' ) ?>
272 </td>
273 </tr>
274 </table>
275 <?php
276 collapse_end( 'bugnotes' );