/
html_api.php
754 lines (653 loc) · 24.8 KB
/
html_api.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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: html_api.php,v 1.62 2003-02-24 10:32:32 jfitzell Exp $
# --------------------------------------------------------
###########################################################################
# HTML API
#
# These functions control the display of each page
#
# This is the call order of these functions, should you need to figure out
# which to modify or which to leave out.
#
# html_page_top1
# html_begin
# html_head_begin
# html_content_type
# html_title
# html_css
# (html_meta_redirect)
# html_page_top2
# html_page_top2a
# html_head_end
# html_body_begin
# html_header
# html_top_banner
# html_login_info
# (print_project_menu_bar)
# print_menu
#
# ...Page content here...
#
# html_page_bottom1
# (print_menu)
# html_page_bottom1a
# html_bottom_banner
# html_footer
# html_body_end
# html_end
#
###########################################################################
$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
require_once( $t_core_dir . 'current_user_api.php' );
require_once( $t_core_dir . 'string_api.php' );
require_once( $t_core_dir . 'bug_api.php' );
require_once( $t_core_dir . 'project_api.php' );
require_once( $t_core_dir . 'helper_api.php' );
# --------------------
# Print the part of the page that comes before meta redirect tags should
# be inserted
function html_page_top1() {
html_begin();
html_head_begin();
html_content_type();
html_title();
html_css();
include( config_get( 'meta_include_file' ) );
}
# --------------------
# Print the part of the page that comes after meta tags, but before the
# actual page content
function html_page_top2() {
html_page_top2a();
html_login_info();
if( ON == config_get( 'show_project_menu_bar' ) ) {
print_project_menu_bar();
echo '<br />';
}
print_menu();
}
# --------------------
# Print the part of the page that comes after meta tags and before the
# actual page content, but without login info or menus. This is used
# directly during the login process and other times when the user may
# not be authenticated
function html_page_top2a() {
html_head_end();
html_body_begin();
html_header();
html_top_banner();
}
# --------------------
# Print the part of the page that comes below the page content
# $p_file should always be the __FILE__ variable. This is passed to show source
function html_page_bottom1( $p_file = null ) {
if ( config_get( 'show_footer_menu' ) ) {
echo '<br />';
print_menu();
}
html_page_bottom1a( $p_file );
}
# --------------------
# Print the part of the page that comes below the page content but leave off
# the menu. This is used during the login process and other times when the
# user may not be authenticated.
function html_page_bottom1a( $p_file = null ) {
if ( ! php_version_at_least( '4.1.0' ) ) {
global $_SERVER;
}
if ( null === $p_file ) {
$p_file = basename( $_SERVER['PHP_SELF'] );
}
html_bottom_banner();
html_footer( $p_file );
html_body_end();
html_end();
}
# --------------------
# (1) Print the document type and the opening <html> tag
function html_begin() {
# @@@ NOTE make this a configurable global.
#echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
#echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">';
echo '<html>';
}
# --------------------
# (2) Begin the <head> section
function html_head_begin() {
echo '<head>';
}
# --------------------
# (3) Print the content-type
function html_content_type() {
echo '<meta http-equiv="Content-type" content="text/html;charset=' . lang_get( 'charset' ) . '" />';
}
# --------------------
# (4) Print the window title
function html_title() {
$t_title = config_get( 'window_title' );
if ( auth_is_user_authenticated() &&
db_is_connected() &&
ON == config_get( 'show_project_in_title' ) ) {
if ( ! is_blank( $t_title ) ) {
$t_title .= ' - ';
}
$t_title .= project_get_name( helper_get_current_project() );
}
echo '<title>' . string_display( $t_title ) . "</title>\n";
}
# --------------------
# (5) Print the link to include the css file
function html_css() {
$t_css_url = config_get( 'css_include_file' );
echo '<link rel="stylesheet" type="text/css" href="' . $t_css_url . '" />';
echo '<script language="JavaScript" type="text/javascript">';
echo '<!--';
echo 'if(document.layers) {document.write("<style>td{padding:0px;}<\/style>")}';
echo '//-->';
echo '</script>';
}
# --------------------
# (6) Print an HTML meta tag to redirect to another page
# This function is optional and may be called by pages that need a redirect.
# $p_time is the number of seconds to wait before redirecting.
# If we have handled any errors on this page and the 'stop_on_errors' config
# option is turned on, return false and don't redirect.
function html_meta_redirect( $p_url, $p_time=null ) {
if ( ON == config_get( 'stop_on_errors' ) && error_handled() ) {
return false;
}
if ( null === $p_time ) {
$p_time = config_get( 'wait_time' );
}
echo "<meta http-equiv=\"Refresh\" content=\"$p_time;URL=$p_url\" />";
return true;
}
# --------------------
# (7) End the <head> section
function html_head_end() {
echo '</head>';
}
# --------------------
# (8) Begin the <body> section
function html_body_begin() {
echo '<body>';
}
# --------------------
# (9) Print the title displayed at the top of the page
function html_header() {
$t_title = config_get( 'page_title' );
if ( auth_is_user_authenticated() &&
db_is_connected() &&
ON == config_get( 'show_project_in_title' ) ) {
if ( ! is_blank( $t_title ) ) {
$t_title .= ' - ';
}
$t_title .= project_get_name( helper_get_current_project() );
}
echo '<div class="center"><span class="pagetitle">' . string_display( $t_title ) . '</span></div>';
}
# --------------------
# (10) Print a user-defined banner at the top of the page if there is one.
function html_top_banner() {
$t_page = config_get( 'top_include_page' );
if ( !is_blank( $t_page ) &&
file_exists( $t_page ) &&
!is_dir( $t_page ) ) {
include( $t_page );
}
}
# --------------------
# (11) Print the user's account information
# Also print the select box where users can switch projects
function html_login_info() {
$t_username = current_user_get_field( 'username' );
$t_access_level = get_enum_element( 'access_levels', current_user_get_access_level() );
$t_now = date( config_get( 'complete_date_format' ) );
echo '<table class="hide">';
echo '<tr>';
echo '<td class="login-info-left">';
echo lang_get( 'logged_in_as' ) . ": <span class=\"italic\">$t_username</span> <span class=\"small\">($t_access_level)</span>";
echo '</td>';
echo '<td class="login-info-middle">';
echo "<span class=\"italic\">$t_now</span>";
echo '</td>';
echo '<td class="login-info-right">';
echo '<form method="post" name="form_set_project" action="set_project.php">';
if ( ON == config_get( 'use_javascript' )) {
echo '<select name="project_id" class="small" onchange="document.forms.form_set_project.submit();">';
} else {
echo '<select name="project_id" class="small">';
}
print_project_option_list( helper_get_current_project() );
echo '</select>';
echo '<input type="submit" value="' . lang_get( 'switch' ) . '" class="small" />';
echo '</form>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
# --------------------
# (12) Print a user-defined banner at the bottom of the page if there is one.
function html_bottom_banner() {
$t_page = config_get( 'bottom_include_page' );
if ( !is_blank( $t_page ) &&
file_exists( $t_page ) &&
!is_dir( $t_page ) ) {
include( $t_page );
}
}
# --------------------
# (13) Print the page footer information
function html_footer( $p_file ) {
global $g_timer, $g_queries_array;
print_source_link( $p_file );
# If a user is logged in, update their last visit time.
# We do this at the end of the page so that:
# 1) we can display the user's last visit time on a page before updating it
# 2) we don't invalidate the user cache immediately after fetching it
if ( auth_is_user_authenticated() ) {
$t_user_id = auth_get_current_user_id();
user_update_last_visit( $t_user_id );
}
echo '<br />';
echo '<hr size="1" />';
if ( ON == config_get( 'show_version' ) ) {
echo "<span class=\"timer\"><a href=\"http://mantisbt.sourceforge.net/\">Mantis " . config_get( 'mantis_version' ) . "</a></span>";
}
echo '<address>Copyright (C) 2000 - 2003</address>';
echo '<address><a href="mailto:' . config_get( 'webmaster_email' ) . '">' . config_get( 'webmaster_email' ) . '</a></address>';
if ( ON == config_get( 'show_timer' ) ) {
$g_timer->print_times();
}
if ( ON == config_get( 'show_queries_count' ) ) {
$t_count = count( $g_queries_array );
echo "$t_count total queries executed.<br />";
echo count( array_unique ( $g_queries_array ) ) . " unique queries executed.<br />";
if ( ON == config_get( 'show_queries_list' ) ) {
echo '<table>';
$t_shown_queries = array();
for ( $i = 0; $i < $t_count; $i++ ) {
if ( in_array( $g_queries_array[$i], $t_shown_queries ) ) {
echo '<tr><td style="color: red">'. ($i+1) ."</td><td style=\"color: red\">$g_queries_array[$i]</td></tr>";
} else {
array_push( $t_shown_queries, $g_queries_array[$i] );
echo '<tr><td>'. ($i+1) ."</td><td>$g_queries_array[$i]</td></tr>";
}
}
echo '</table>';
}
}
}
# --------------------
# (14) End the <body> section
function html_body_end() {
echo '</body>';
}
# --------------------
# (15) Print the closing <html> tag
function html_end() {
echo '</html>';
}
###########################################################################
# HTML Menu API
###########################################################################
# --------------------
# Print the main menu
function print_menu() {
if ( auth_is_user_authenticated() ) {
$t_protected = current_user_get_field( 'protected' );
echo '<table class="width100" cellspacing="0">';
echo '<tr>';
echo '<td class="menu">';
echo '<a href="main_page.php">' . lang_get( 'main_link' ) . '</a> | ';
echo '<a href="view_all_bug_page.php">' . lang_get( 'view_bugs_link' ) . '</a> | ';
if ( access_has_project_level( REPORTER ) ) {
echo string_get_bug_report_link() . ' | ';
}
if ( access_has_project_level( config_get( 'view_summary_threshold' ) ) ) {
echo '<a href="summary_page.php">' . lang_get( 'summary_link' ) . '</a> | ';
}
echo '<a href="proj_doc_page.php">' . lang_get( 'docs_link' ) . '</a> | ';
if ( access_has_project_level( MANAGER ) ) {
if ( access_has_project_level( ADMINISTRATOR ) ) {
$t_link = 'manage_user_page.php';
} else {
$t_link = 'manage_proj_page.php';
}
echo "<a href=\"$t_link\">" . lang_get( 'manage_link' ) . '</a> | ';
}
if ( access_has_project_level( MANAGER ) ) {
# Admin can edit news for All Projects (site-wide)
if ( ( 0 != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) {
echo '<a href="news_menu_page.php">' . lang_get( 'edit_news_link' ) . '</a> | ';
} else {
echo '<a href="login_select_proj_page.php">' . lang_get( 'edit_news_link' ) . '</a> | ';
}
}
# only show accounts that are NOT protected
if ( OFF == $t_protected ) {
echo '<a href="account_page.php">' . lang_get( 'account_link' ) . '</a> | ';
}
echo '<a href="logout_page.php">' . lang_get( 'logout_link' ) . '</a>';
echo '</td>';
echo '<td class="right" style="white-space: nowrap;">';
echo '<form method="post" action="jump_to_bug.php">';
echo "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" /> ";
echo '<input type="submit" value="' . lang_get( 'jump' ) . '" class="small" /> ';
echo '</form>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
}
# --------------------
# Print the menu bar with a list of projects to which the user has access
function print_project_menu_bar() {
$t_user_id = current_user_get_field( 'id' );
$t_access_level = current_user_get_field( 'access_level' );
$t_pub = PUBLIC;
$t_prv = PRIVATE;
$t_project_table = config_get( 'mantis_project_table' );
$t_project_user_list_table = config_get( 'mantis_project_user_list_table' );
if ( ADMINISTRATOR == $t_access_level ) {
$query = "SELECT p.id, p.name
FROM $t_project_table p
WHERE p.enabled=1
ORDER BY p.name";
} else {
$query = "SELECT p.id, p.name
FROM $t_project_table p, $t_project_user_list_table u
WHERE p.enabled=1
AND p.id=u.project_id
AND ((p.view_state=$t_pub) OR
(p.view_state=$t_prv AND u.user_id=$t_user_id))
ORDER BY p.name";
}
$result = db_query( $query );
$project_count = db_num_rows( $result );
echo '<table class="width100" cellspacing="0">';
echo '<tr>';
echo '<td class="menu">';
echo '<a href="set_project.php?project_id=0">' . lang_get( 'all_projects' ) . '</a>';
for ( $i=0 ; $i < $project_count ; $i++ ) {
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, 'v' );
echo " | <a href=\"set_project.php?project_id=$v_id\">" . string_display( $v_name ) . '</a>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
}
# --------------------
# Print the menu for the graph summary section
function print_menu_graph() {
if ( config_get( 'use_jpgraph' ) ) {
$t_icon_path = config_get( 'icon_path' );
echo '<a href="summary_page.php"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | ';
echo '<a href="summary_graph_imp_status.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | ';
echo '<a href="summary_graph_imp_priority.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | ';
echo '<a href="summary_graph_imp_severity.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | ';
echo '<a href="summary_graph_imp_category.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | ';
echo '<a href="summary_graph_imp_resolution.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>';
}
}
# --------------------
# Print the menu for the manage section
# $p_page specifies the current page name so it's link can be disabled
function print_manage_menu( $p_page='' ) {
if ( !access_has_project_level( ADMINISTRATOR ) ) {
return;
}
$t_manage_user_page = 'manage_user_page.php';
$t_manage_project_menu_page = 'manage_proj_page.php';
$t_manage_custom_field_page = 'manage_custom_field_page.php';
$t_documentation_page = 'documentation_page.php';
switch ( $p_page ) {
case $t_manage_user_page : $t_manage_user_page = ''; break;
case $t_manage_project_menu_page: $t_manage_project_menu_page = ''; break;
case $t_manage_custom_field_page: $t_manage_custom_field_page = ''; break;
case $t_documentation_page : $t_documentation_page = ''; break;
}
echo '<br /><div align="center">';
print_bracket_link( $t_manage_user_page, lang_get( 'manage_users_link' ) );
print_bracket_link( $t_manage_project_menu_page, lang_get( 'manage_projects_link' ) );
print_bracket_link( $t_manage_custom_field_page, lang_get( 'manage_custom_field_link' ) );
print_bracket_link( $t_documentation_page, lang_get( 'documentation_link' ) );
echo '</div>';
}
# --------------------
# Print the menu for the account section
# $p_page specifies the current page name so it's link can be disabled
function print_account_menu( $p_page='' ) {
$t_account_page = 'account_page.php';
$t_account_prefs_page = 'account_prefs_page.php';
$t_account_profile_menu_page = 'account_prof_menu_page.php';
switch ( $p_page ) {
case $t_account_page : $t_account_page = ''; break;
case $t_account_prefs_page : $t_account_prefs_page = ''; break;
case $t_account_profile_menu_page : $t_account_profile_menu_page = ''; break;
}
print_bracket_link( $t_account_page, lang_get( 'account_link' ) );
print_bracket_link( $t_account_prefs_page, lang_get( 'change_preferences_link' ) );
print_bracket_link( $t_account_profile_menu_page, lang_get( 'manage_profiles_link' ) );
}
# --------------------
# Print the menu for the docs section
# $p_page specifies the current page name so it's link can be disabled
function print_doc_menu( $p_page='' ) {
$t_documentation_html = 'doc/documentation.html';
$t_proj_doc_page = 'proj_doc_page.php';
$t_proj_doc_add_page = 'proj_doc_add_page.php';
switch ( $p_page ) {
case $t_documentation_html : $t_documentation_html = ''; break;
case $t_proj_doc_page : $t_proj_doc_page = ''; break;
case $t_proj_doc_add_page : $t_proj_doc_add_page = ''; break;
}
print_bracket_link( $t_documentation_html, lang_get( 'user_documentation' ) );
print_bracket_link( $t_proj_doc_page, lang_get( 'project_documentation' ) );
if ( file_allow_project_upload() ) {
print_bracket_link( $t_proj_doc_add_page, lang_get( 'add_file' ) );
}
}
# --------------------
# Print the menu for the management docs section
# $p_page specifies the current page name so it's link can be disabled
function print_manage_doc_menu( $p_page='' ) {
$t_path = config_get( 'path' ).'doc/';
$t_documentation_page = 'documentation_page.php';
switch ( $p_page ) {
case $t_documentation_page: $t_documentation_page = ''; break;
}
echo '<br /><div align="center">';
print_bracket_link( $t_documentation_page, lang_get( 'system_info_link' ) );
print_bracket_link( $t_path.'ChangeLog', 'ChangeLog' );
print_bracket_link( $t_path.'README', 'README' );
print_bracket_link( $t_path.'INSTALL', 'INSTALL' );
print_bracket_link( $t_path.'UPGRADING', 'UPGRADING' );
print_bracket_link( $t_path.'CUSTOMIZATION', 'CUSTOMIZATION' );
echo '</div>';
}
# --------------------
# Print the menu for the summary section
# $p_page specifies the current page name so it's link can be disabled
function print_summary_menu( $p_page='' ) {
echo '<div align="center">';
print_bracket_link( 'print_all_bug_page.php', lang_get( 'print_all_bug_page_link' ) );
if ( config_get( 'use_jpgraph' ) != 0 ) {
$t_summary_page = 'summary_page.php';
$t_summary_jpgraph_page = 'summary_jpgraph_page.php';
switch ( $p_page ) {
case $t_summary_page : $t_summary_page = ''; break;
case $t_summary_jpgraph_page: $t_summary_jpgraph_page = ''; break;
}
print_bracket_link( $t_summary_page, lang_get( 'summary_link' ) );
print_bracket_link( $t_summary_jpgraph_page, lang_get( 'summary_jpgraph_link' ) );
}
echo '</div>';
}
#=========================
# Candidates for moving to print_api
#=========================
# --------------------
# Print the color legend for the status colors
function html_status_legend() {
echo '<br />';
echo '<table class="width100" cellspacing="1">';
echo '<tr>';
$t_arr = explode_enum_string( config_get( 'status_enum_string' ) );
$enum_count = count( $t_arr );
$width = (integer) (100 / $enum_count);
for ($i=0;$i<$enum_count;$i++) {
$t_s = explode_enum_arr( $t_arr[$i] );
$t_val = get_enum_element( 'status', $t_s[0] );
$t_color = get_status_color( $t_s[0] );
echo "<td class=\"small-caption\" width=\"$width%\" bgcolor=\"$t_color\">$t_val</td>";
}
echo '</tr>';
echo '</table>';
}
# --------------------
# Print an html button inside a form
function html_button ( $p_action, $p_button_text, $p_fields = null ) {
$p_action = urlencode( $p_action );
$p_button_text = string_attribute( $p_button_text );
if ( null === $p_fields ) {
$p_fields = array();
}
echo "<form method=\"post\" action=\"$p_action\">\n";
foreach ( $p_fields as $key => $val ) {
$key = string_attribute( $key );
$val = string_attribute( $val );
echo " <input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
}
echo " <input type=\"submit\" value=\"$p_button_text\" />\n";
echo "</form>\n";
}
# --------------------
# Print a button to update the given bug
function html_button_bug_update( $p_bug_id ) {
if ( access_has_project_level( config_get( 'update_bug_threshold' ) ) ) {
echo '<td class="center">';
html_button( string_get_bug_update_page(),
lang_get( 'update_bug_button' ),
array( 'bug_id' => $p_bug_id ) );
echo '</td>';
}
}
# --------------------
# Print a button to assign the given bug
function html_button_bug_assign( $p_bug_id ) {
if ( access_has_project_level( config_get( 'handle_bug_threshold' ) ) ) {
$t_handler_id = bug_get_field( $p_bug_id, 'handler_id' );
if ( $t_handler_id != auth_get_current_user_id() ) {
echo '<td class="center">';
html_button( 'bug_assign.php',
lang_get( 'bug_assign_button' ),
array( 'bug_id' => $p_bug_id ) );
echo '</td>';
}
}
}
# --------------------
# Print a button to resolve the given bug
function html_button_bug_resolve( $p_bug_id ) {
if ( access_has_project_level( config_get( 'handle_bug_threshold' ) ) ) {
echo '<td class="center">';
html_button( 'bug_resolve_page.php',
lang_get( 'resolve_bug_button' ),
array( 'bug_id' => $p_bug_id ) );
echo '</td>';
}
}
# --------------------
# Print a button to reopen the given bug
function html_button_bug_reopen( $p_bug_id ) {
if ( access_has_project_level( config_get( 'reopen_bug_threshold' ) )
|| ( bug_get_field( $p_bug_id, 'reporter_id' ) == auth_get_current_user_id()
&& ON == config_get( 'allow_reporter_reopen' ) ) ) {
echo '<td class="center">';
html_button( 'bug_reopen_page.php',
lang_get( 'reopen_bug_button' ),
array( 'bug_id' => $p_bug_id ) );
echo '</td>';
}
}
# --------------------
# Print a button to close the given bug
function html_button_bug_close( $p_bug_id ) {
$t_status = bug_get_field( $p_bug_id, 'status' );
if ( access_can_close_bug ( $p_bug_id ) && ( $t_status < CLOSED ) ) {
echo '<td class="center">';
html_button( 'bug_close_page.php',
lang_get( 'close_bug_button' ),
array( 'bug_id' => $p_bug_id ) );
echo '</td>';
}
}
# --------------------
# Print a button to monitor the given bug
function html_button_bug_monitor( $p_bug_id ) {
if ( access_has_project_level( config_get( 'monitor_bug_threshold' ) ) ) {
echo '<td class="center">';
html_button( 'bug_monitor.php',
lang_get( 'monitor_bug_button' ),
array( 'bug_id' => $p_bug_id, 'action' => 'add' ) );
echo '</td>';
}
}
# --------------------
# Print a button to unmonitor the given bug
# no reason to ever disallow someone from unmonitoring a bug
function html_button_bug_unmonitor( $p_bug_id ) {
echo '<td class="center">';
html_button( 'bug_monitor.php',
lang_get( 'unmonitor_bug_button' ),
array( 'bug_id' => $p_bug_id, 'action' => 'delete' ) );
echo '</td>';
}
# --------------------
# Print a button to delete the given bug
function html_button_bug_delete( $p_bug_id ) {
if ( access_has_project_level( config_get( 'delete_bug_threshold' ) ) ) {
echo '<td class="center">';
html_button( 'bug_delete.php',
lang_get( 'delete_bug_button' ),
array( 'bug_id' => $p_bug_id ) );
echo '</td>';
}
}
# --------------------
# Print all buttons for view bug pages
function html_buttons_view_bug_page( $p_bug_id ) {
$t_resolved = config_get( 'bug_resolved_status_threshold' );
$t_status = bug_get_field( $p_bug_id, 'status' );
if ( $t_status < $t_resolved ) {
# UPDATE button
html_button_bug_update( $p_bug_id );
# ASSIGN button
html_button_bug_assign( $p_bug_id );
# RESOLVE button
html_button_bug_resolve( $p_bug_id );
} else {
# REOPEN button
html_button_bug_reopen( $p_bug_id );
}
# CLOSE button
html_button_bug_close( $p_bug_id );
# MONITOR/UNMONITOR button
if ( user_is_monitoring_bug( auth_get_current_user_id(), $p_bug_id ) ) {
html_button_bug_unmonitor( $p_bug_id );
} else {
html_button_bug_monitor( $p_bug_id );
}
# DELETE button
html_button_bug_delete( $p_bug_id );
}
?>