forked from mantisbt/mantisbt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bugnote_view_inc.php
379 lines (339 loc) · 11.7 KB
/
bugnote_view_inc.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT 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.
#
# MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* This include file prints out the list of bugnotes attached to the bug
* $f_bug_id must be set and be set to the bug id
*
* @package MantisBT
* @copyright Copyright 2000 - 2002 Kenzaburo Ito - [email protected]
* @copyright Copyright 2002 MantisBT Team - [email protected]
* @link http://www.mantisbt.org
*
* @uses access_api.php
* @uses authentication_api.php
* @uses bug_api.php
* @uses bug_revision_api.php
* @uses bugnote_api.php
* @uses collapse_api.php
* @uses config_api.php
* @uses constant_inc.php
* @uses current_user_api.php
* @uses database_api.php
* @uses event_api.php
* @uses helper_api.php
* @uses lang_api.php
* @uses prepare_api.php
* @uses print_api.php
* @uses string_api.php
* @uses user_api.php
*/
if( !defined( 'BUGNOTE_VIEW_INC_ALLOW' ) ) {
return;
}
require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
require_api( 'bug_activity_api.php' );
require_api( 'bug_api.php' );
require_api( 'bug_revision_api.php' );
require_api( 'bugnote_api.php' );
require_api( 'collapse_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'current_user_api.php' );
require_api( 'database_api.php' );
require_api( 'event_api.php' );
require_api( 'helper_api.php' );
require_api( 'lang_api.php' );
require_api( 'prepare_api.php' );
require_api( 'print_api.php' );
require_api( 'string_api.php' );
require_api( 'user_api.php' );
#precache access levels
access_cache_matrix_project( helper_get_current_project() );
$t_show_time_tracking = config_get( 'time_tracking_enabled' )
&& access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_bug_id );
# get attachments data
$t_fields = config_get( 'bug_view_page_fields' );
$t_fields = columns_filter_disabled( $t_fields );
$t_show_attachments = in_array( 'attachments', $t_fields );
# If included from bug_view_inc.php, then this may already be set.
if( !isset( $t_bug_activity_get_all_result ) ) {
$t_bug_activity_get_all_result = bug_activity_get_all( $f_bug_id, /* include_attachments */ $t_show_attachments );
}
$t_activities = $t_bug_activity_get_all_result['activities'];
$t_bugnotes = $t_bug_activity_get_all_result['bugnotes'];
# Pre-cache users
$t_users_to_cache = array();
foreach( $t_activities as $t_activity ) {
$t_users_to_cache[$t_activity['user_id']] = true;
}
user_cache_array_rows( array_keys( $t_users_to_cache ) );
$t_activities_count = count( $t_activities );
?>
<?php # Bugnotes BEGIN ?>
<div class="col-md-12 col-xs-12">
<a id="attachments"></a>
<a id="bugnotes"></a>
<div class="space-10"></div>
<?php
$t_collapse_block = is_collapsed( 'bugnotes' );
$t_block_css = $t_collapse_block ? 'collapsed' : '';
$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up';
?>
<div id="bugnotes" class="widget-box widget-color-blue2 <?php echo $t_block_css ?>">
<div class="widget-header widget-header-small">
<h4 class="widget-title lighter">
<?php print_icon( 'fa-comments', 'ace-icon' ); ?>
<?php echo lang_get( 'activities_title' ) ?>
</h4>
<div class="widget-toolbar">
<a data-action="collapse" href="#">
<?php print_icon( $t_block_icon, '1 ace-icon bigger-125' ); ?>
</a>
</div>
</div>
<div class="widget-body">
<div class="widget-main no-padding">
<div class="table-responsive">
<table class="table table-bordered table-condensed table-striped">
<?php
# no bugnotes
if( 0 == $t_activities_count ) {
?>
<tr class="bugnotes-empty">
<td class="center" colspan="2">
<?php echo lang_get( 'no_bugnotes_msg' ) ?>
</td>
</tr>
<?php }
event_signal( 'EVENT_VIEW_BUGNOTES_START', array( $f_bug_id, $t_bugnotes ) );
$t_normal_date_format = config_get( 'normal_date_format' );
$t_total_time = 0;
foreach( $t_activities as $t_activity ) {
if( $t_activity['type'] !== ENTRY_TYPE_NOTE ) {
continue;
}
if( $t_activity['type'] == ENTRY_TYPE_NOTE && $t_activity['note']->time_tracking != 0 ) {
$t_time_tracking_hhmm = db_minutes_to_hhmm( $t_activity['note']->time_tracking );
$t_total_time += $t_activity['note']->time_tracking;
} else {
$t_time_tracking_hhmm = '';
}
$t_category_class = 'category';
if( $t_activity['private'] ) {
$t_category_class = 'bugnote-private';
}
?>
<tr class="bugnote visible-on-hover-toggle" id="c<?php echo $t_activity['id'] ?>">
<td class="category">
<div class="pull-left padding-2"><?php print_avatar( $t_activity['user_id'], 'bugnote', 80 ); ?>
</div>
<div class="pull-left padding-2">
<p class="no-margin">
<?php
print_icon( 'fa-user', 'grey' );
echo ' ';
print_user( $t_activity['user_id'] );
?>
</p>
<p class="no-margin small lighter">
<?php print_icon( 'fa-clock-o', 'grey' ); ?>
<?php echo date( $t_normal_date_format, $t_activity['timestamp'] ); ?>
<?php if( $t_activity['private'] ) { ?>
  
<?php print_icon( 'fa-eye', 'red' ); ?>
<?php echo lang_get( 'private' ) ?>
<?php } ?>
</p>
<p class="no-margin">
<?php
if( user_exists( $t_activity['user_id'] ) ) {
$t_access_level = access_get_project_level( null, $t_activity['user_id'] );
$t_label = layout_is_rtl() ? 'arrowed-right' : 'arrowed-in-right';
echo '<span class="label label-sm label-default ' . $t_label . '">', access_level_get_string( $t_access_level ), '</span>';
}
?>
 
<?php if( $t_activity['type'] == ENTRY_TYPE_NOTE ) { ?>
<?php print_icon( 'fa-link', 'grey' ); ?>
<a rel="bookmark" href="<?php echo string_get_bugnote_view_url( $t_activity['note']->bug_id, $t_activity['note']->id) ?>" class="lighter" title="<?php echo lang_get( 'bugnote_link_title' ) ?>">
<?php echo htmlentities( config_get_global( 'bugnote_link_tag' ) ) . $t_activity['id_formatted'] ?>
</a>
<?php } ?>
</p>
<?php
if( $t_activity['modified'] ) {
echo '<p class="no-margin small lighter">';
print_icon( 'fa-retweet' );
echo ' ' . lang_get( 'last_edited')
. lang_get( 'word_separator' )
. date( $t_normal_date_format, $t_activity['last_modified'] )
. '</p>';
if( access_can_view_bugnote_revisions( $t_activity['id'] ) ) {
$t_revision_count = bug_revision_count( $f_bug_id, REV_BUGNOTE, $t_activity['id'] );
if( $t_revision_count >= 1 ) {
$t_view_num_revisions_text = sprintf( lang_get( 'view_num_revisions' ), $t_revision_count );
?>
<p class="no-margin">
<span class="small bugnote-revisions-link">
<a href="bug_revision_view_page.php?bugnote_id=<?php echo $t_activity['id'] ?>">
<?php echo $t_view_num_revisions_text ?>
</a>
</span>
</p>
<?php
}
}
}
?>
<div class="clearfix"></div>
<div class="space-2"></div>
<div class="btn-group visible-on-hover">
<?php
# show edit button if the user is allowed to edit this bugnote
if( $t_activity['can_edit'] ) {
echo '<div class="pull-left">';
print_form_button(
'bugnote_edit_page.php',
lang_get( 'edit' ),
array( 'bugnote_id' => $t_activity['id'] ),
OFF );
echo '</div>';
}
# show delete button if the user is allowed to delete this bugnote
if( $t_activity['can_delete'] ) {
echo '<div class="pull-left">';
if( $t_activity['type'] == ENTRY_TYPE_NOTE ) {
if ( !isset( $t_security_token_notes_delete ) ) {
$t_security_token_notes_delete = form_security_token( 'bugnote_delete' );
}
print_form_button(
'bugnote_delete.php',
lang_get( 'delete' ),
array( 'bugnote_id' => $t_activity['id'] ),
$t_security_token_notes_delete );
} else {
if ( !isset( $t_security_token_attachments_delete ) ) {
$t_security_token_attachments_delete = form_security_token( 'bug_file_delete' );
}
if( $t_activity['can_delete'] ) {
print_link_button( 'bug_file_delete.php?file_id=' . $t_activity['id'] . form_security_param( 'bug_file_delete', $t_security_token_attachments_delete ),
lang_get( 'delete' ), 'btn-xs' );
}
}
echo '</div>';
}
# show make public or make private button if the user is allowed to change the view state of this bugnote
if( $t_activity['can_change_view_state'] ) {
if ( !isset( $t_security_token_state ) ) {
$t_security_token_state = form_security_token( 'bugnote_set_view_state' );
}
echo '<div class="pull-left">';
if( $t_activity['private'] ) {
print_form_button(
'bugnote_set_view_state.php',
lang_get( 'make_public' ),
array( 'private' => '0', 'bugnote_id' => $t_activity['id'] ),
$t_security_token_state );
} else {
print_form_button(
'bugnote_set_view_state.php',
lang_get( 'make_private' ),
array( 'private' => '1', 'bugnote_id' => $t_activity['id'] ),
$t_security_token_state );
}
echo '</div>';
}
?>
</div>
</div>
</td>
<td class="<?php echo $t_activity['style'] ?>">
<?php
if( $t_activity['type'] == ENTRY_TYPE_NOTE ) {
$t_add_space = false;
switch ( $t_activity['note']->note_type ) {
case REMINDER:
echo '<strong>';
# List of recipients; remove surrounding delimiters
$t_recipients = trim( $t_activity['note']->note_attr, '|' );
if( empty( $t_recipients ) ) {
echo lang_get( 'reminder_sent_none' );
} else {
# If recipients list's last char is not a delimiter, it was truncated
$t_truncated = ( '|' != mb_substr( $t_activity['note']->note_attr, mb_strlen( $t_activity['note']->note_attr ) - 1 ) );
# Build recipients list for display
$t_to = array();
foreach ( explode( '|', $t_recipients ) as $t_recipient ) {
$t_to[] = prepare_user_name( $t_recipient );
}
echo lang_get( 'reminder_sent_to' ) . ': '
. implode( ', ', $t_to )
. ( $t_truncated ? ' (' . lang_get( 'reminder_list_truncated' ) . ')' : '' );
}
echo '</strong><br /><br />';
$t_add_space = true;
break;
case TIME_TRACKING:
if( $t_show_time_tracking ) {
echo '<div class="time-tracked label label-grey label-sm">', lang_get( 'time_tracking_time_spent' ) . ' ' . $t_time_tracking_hhmm, '</div>';
echo '<div class="clearfix"></div>';
$t_add_space = true;
}
break;
}
if( !is_blank( $t_activity['note']->note ) ) {
echo string_display_links( $t_activity['note']->note );
$t_add_space = true;
}
}
if ( !isset( $t_security_token_attachments_delete ) ) {
$t_security_token_attachments_delete = form_security_token( 'bug_file_delete' );
}
foreach( $t_activity['attachments'] as $t_attachment ) {
print_bug_attachment( $t_attachment, $t_security_token_attachments_delete );
}
?>
</td>
</tr>
<?php
if( $t_activity['type'] == ENTRY_TYPE_NOTE ) {
event_signal( 'EVENT_VIEW_BUGNOTE', array( $f_bug_id, $t_activity['id'], $t_activity['private'] ) );
}
?>
<tr class="spacer">
<td colspan="2"></td>
</tr>
<?php
} # end for loop
event_signal( 'EVENT_VIEW_BUGNOTES_END', $f_bug_id );
?>
</table>
</div>
</div>
</div>
</div>
<?php
if( $t_total_time > 0 && $t_show_time_tracking ) {
echo '<div class="time-tracking-total pull-right">';
print_icon( 'fa-clock-o', 'ace-icon bigger-110 red' );
echo ' ';
printf( lang_get( 'total_time_for_issue' ),
'<span class="time-tracked">' . db_minutes_to_hhmm( $t_total_time ) . '</span>'
);
echo '</div>';
}
?>
</div>