[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 20 # -------------------------------------------------------- 21 # $Id: html_api.php,v 1.218.2.4 2007-10-28 15:39:31 nuclear_eclipse Exp $ 22 # -------------------------------------------------------- 23 24 ########################################################################### 25 # HTML API 26 # 27 # These functions control the display of each page 28 # 29 # This is the call order of these functions, should you need to figure out 30 # which to modify or which to leave out. 31 # 32 # html_page_top1 33 # html_begin 34 # html_head_begin 35 # html_css 36 # html_content_type 37 # html_rss_link 38 # (html_meta_redirect) 39 # html_title 40 # html_page_top2 41 # html_page_top2a 42 # html_head_end 43 # html_body_begin 44 # html_header 45 # html_top_banner 46 # html_login_info 47 # (print_project_menu_bar) 48 # print_menu 49 # 50 # ...Page content here... 51 # 52 # html_page_bottom1 53 # (print_menu) 54 # html_page_bottom1a 55 # html_bottom_banner 56 # html_footer 57 # html_body_end 58 # html_end 59 # 60 ########################################################################### 61 62 $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; 63 64 require_once ( $t_core_dir . 'current_user_api.php' ); 65 require_once ( $t_core_dir . 'string_api.php' ); 66 require_once ( $t_core_dir . 'bug_api.php' ); 67 require_once ( $t_core_dir . 'project_api.php' ); 68 require_once ( $t_core_dir . 'helper_api.php' ); 69 require_once ( $t_core_dir . 'authentication_api.php' ); 70 require_once ( $t_core_dir . 'user_api.php' ); 71 require_once ( $t_core_dir . 'rss_api.php' ); 72 require_once ( $t_core_dir . 'wiki_api.php' ); 73 74 $g_rss_feed_url = null; 75 76 # flag for error handler to skip header menus 77 $g_error_send_page_header = true; 78 79 # Projax library disabled by default. It will be enabled if projax_api.php 80 # is included. But it must be included after html_api.php 81 $g_enable_projax = false; 82 83 # -------------------- 84 # Sets the url for the rss link associated with the current page. 85 # null: means no feed (default). 86 function html_set_rss_link( $p_rss_feed_url ) 87 { 88 if ( OFF != config_get( 'rss_enabled' ) ) { 89 global $g_rss_feed_url; 90 $g_rss_feed_url = $p_rss_feed_url; 91 } 92 } 93 94 # -------------------- 95 # Prints the link that allows auto-detection of the associated feed. 96 function html_rss_link() 97 { 98 global $g_rss_feed_url; 99 100 if ( $g_rss_feed_url !== null ) { 101 echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"$g_rss_feed_url\" />"; 102 } 103 } 104 105 # -------------------- 106 # Print the part of the page that comes before meta redirect tags should 107 # be inserted 108 function html_page_top1( $p_page_title = null ) { 109 html_begin(); 110 html_head_begin(); 111 html_css(); 112 html_content_type(); 113 include( config_get( 'meta_include_file' ) ); 114 html_rss_link(); 115 echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'; 116 html_title( $p_page_title ); 117 html_head_javascript(); 118 } 119 120 # -------------------- 121 # Print the part of the page that comes after meta tags, but before the 122 # actual page content 123 function html_page_top2() { 124 html_page_top2a(); 125 126 if ( !db_is_connected() ) { 127 return; 128 } 129 130 if ( auth_is_user_authenticated() ) { 131 html_login_info(); 132 133 if( ON == config_get( 'show_project_menu_bar' ) ) { 134 print_project_menu_bar(); 135 PRINT '<br />'; 136 } 137 } 138 print_menu(); 139 } 140 141 # -------------------- 142 # Print the part of the page that comes after meta tags and before the 143 # actual page content, but without login info or menus. This is used 144 # directly during the login process and other times when the user may 145 # not be authenticated 146 function html_page_top2a() { 147 global $g_error_send_page_header; 148 149 html_head_end(); 150 html_body_begin(); 151 $g_error_send_page_header = false; 152 html_header(); 153 html_top_banner(); 154 } 155 156 # -------------------- 157 # Print the part of the page that comes below the page content 158 # $p_file should always be the __FILE__ variable. This is passed to show source 159 function html_page_bottom1( $p_file = null ) { 160 if ( !db_is_connected() ) { 161 return; 162 } 163 164 if ( config_get( 'show_footer_menu' ) ) { 165 PRINT '<br />'; 166 print_menu(); 167 } 168 169 html_page_bottom1a( $p_file ); 170 } 171 172 # -------------------- 173 # Print the part of the page that comes below the page content but leave off 174 # the menu. This is used during the login process and other times when the 175 # user may not be authenticated. 176 function html_page_bottom1a( $p_file = null ) { 177 if ( null === $p_file ) { 178 $p_file = basename( $_SERVER['PHP_SELF'] ); 179 } 180 181 html_bottom_banner(); 182 html_footer( $p_file ); 183 html_body_end(); 184 html_end(); 185 } 186 187 # -------------------- 188 # (1) Print the document type and the opening <html> tag 189 function html_begin() { 190 # @@@ NOTE make this a configurable global. 191 #echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', "\n"; 192 #echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">', "\n"; 193 194 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', "\n"; 195 echo '<html>', "\n"; 196 } 197 198 # -------------------- 199 # (2) Begin the <head> section 200 function html_head_begin() { 201 echo '<head>', "\n"; 202 } 203 204 # -------------------- 205 # (3) Print the content-type 206 function html_content_type() { 207 echo "\t", '<meta http-equiv="Content-type" content="text/html;charset=', lang_get( 'charset' ), '" />', "\n"; 208 } 209 210 # -------------------- 211 # (4) Print the window title 212 function html_title( $p_page_title = null ) { 213 $t_title = config_get( 'window_title' ); 214 echo "\t", '<title>'; 215 if ( 0 == strlen( $p_page_title ) ) { 216 echo string_display( $t_title ); 217 } else { 218 if ( 0 == strlen( $t_title ) ) { 219 echo $p_page_title; 220 } else { 221 echo $p_page_title . ' - ' . string_display( $t_title ); 222 } 223 } 224 echo '</title>', "\n"; 225 } 226 227 # -------------------- 228 # (5) Print the link to include the css file 229 function html_css() { 230 $t_css_url = config_get( 'css_include_file' ); 231 echo "\t", '<link rel="stylesheet" type="text/css" href="', $t_css_url, '" />', "\n"; 232 233 # fix for NS 4.x css 234 echo "\t", '<script type="text/javascript" language="JavaScript"><!--', "\n"; 235 echo "\t\t", 'if(document.layers) {document.write("<style>td{padding:0px;}<\/style>")}', "\n"; 236 echo "\t", '// --></script>', "\n"; 237 } 238 239 # -------------------- 240 # (6) Print an HTML meta tag to redirect to another page 241 # This function is optional and may be called by pages that need a redirect. 242 # $p_time is the number of seconds to wait before redirecting. 243 # If we have handled any errors on this page and the 'stop_on_errors' config 244 # option is turned on, return false and don't redirect. 245 function html_meta_redirect( $p_url, $p_time = null, $p_sanitize = false ) { 246 if ( ON == config_get( 'stop_on_errors' ) && error_handled() ) { 247 return false; 248 } 249 250 if ( null === $p_time ) { 251 $p_time = current_user_get_pref( 'redirect_delay' ); 252 } 253 254 if ( $p_sanitize ) { 255 $t_url = string_sanitize_url( $p_url ); 256 } else { 257 $t_url = $p_url; 258 } 259 260 echo "\t<meta http-equiv=\"Refresh\" content=\"$p_time;URL=$t_url\" />\n"; 261 262 return true; 263 } 264 265 # --------------------- 266 # (6a) Javascript... 267 function html_head_javascript() { 268 if ( ON == config_get( 'use_javascript' ) ) { 269 echo "\t" . '<script type="text/javascript" language="JavaScript" src="javascript/common.js">'; 270 echo '</script>' . "\n"; 271 echo "\t" . '<script type="text/JavaScript" src="javascript/ajax.js">'; 272 echo '</script>' . "\n"; 273 274 global $g_enable_projax; 275 276 if ( $g_enable_projax ) { 277 echo '<script type="text/javascript" src="javascript/projax/prototype.js"></script>'; 278 echo '<script type="text/javascript" src="javascript/projax/scriptaculous.js"></script>'; 279 } 280 } 281 } 282 283 # -------------------- 284 # (7) End the <head> section 285 function html_head_end() { 286 echo '</head>', "\n"; 287 } 288 289 # -------------------- 290 # (8) Begin the <body> section 291 function html_body_begin() { 292 echo '<body>', "\n"; 293 } 294 295 # -------------------- 296 # (9) Print the title displayed at the top of the page 297 function html_header() { 298 $t_title = config_get( 'page_title' ); 299 echo '<div class="center"><span class="pagetitle">', string_display( $t_title ), '</span></div>', "\n"; 300 } 301 302 # -------------------- 303 # (10) Print a user-defined banner at the top of the page if there is one. 304 function html_top_banner() { 305 $t_page = config_get( 'top_include_page' ); 306 307 if ( !is_blank( $t_page ) && file_exists( $t_page ) && !is_dir( $t_page ) ) { 308 include( $t_page ); 309 } else { 310 if ( is_page_name( 'login_page' ) ) { 311 $t_align = 'center'; 312 } else { 313 $t_align = 'left'; 314 } 315 316 echo '<div align="', $t_align, '">'; 317 echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" width="242" height="102" alt="Mantis Bugtracker" src="images/mantis_logo.gif" /></a>'; 318 echo '</div>'; 319 } 320 } 321 322 # -------------------- 323 # (11) Print the user's account information 324 # Also print the select box where users can switch projects 325 function html_login_info() { 326 $t_username = current_user_get_field( 'username' ); 327 $t_access_level = get_enum_element( 'access_levels', current_user_get_access_level() ); 328 $t_now = date( config_get( 'complete_date_format' ) ); 329 $t_realname = current_user_get_field( 'realname' ); 330 331 PRINT '<table class="hide">'; 332 PRINT '<tr>'; 333 PRINT '<td class="login-info-left">'; 334 if ( current_user_is_anonymous() ) { 335 $t_return_page = $_SERVER['PHP_SELF']; 336 if ( isset( $_SERVER['QUERY_STRING'] ) ) { 337 $t_return_page .= '?' . $_SERVER['QUERY_STRING']; 338 } 339 340 $t_return_page = string_url( $t_return_page ); 341 PRINT lang_get( 'anonymous' ) . ' | <a href="login_page.php?return=' . $t_return_page . '">' . lang_get( 'login_link' ) . '</a>'; 342 if ( config_get( 'allow_signup' ) == ON ) { 343 PRINT ' | <a href="signup_page.php">' . lang_get( 'signup_link' ) . '</a>'; 344 } 345 } else { 346 echo lang_get( 'logged_in_as' ), ": <span class=\"italic\">", string_display( $t_username ), "</span> <span class=\"small\">"; 347 echo is_blank( $t_realname ) ? "($t_access_level)" : "(" . string_display( $t_realname ) . " - $t_access_level)"; 348 echo "</span>"; 349 } 350 PRINT '</td>'; 351 PRINT '<td class="login-info-middle">'; 352 PRINT "<span class=\"italic\">$t_now</span>"; 353 PRINT '</td>'; 354 PRINT '<td class="login-info-right">'; 355 PRINT '<form method="post" name="form_set_project" action="set_project.php">'; 356 357 echo lang_get( 'email_project' ), ': '; 358 if ( ON == config_get( 'show_extended_project_browser' ) ) { 359 print_extended_project_browser( helper_get_current_project_trace() ); 360 } else { 361 if ( ON == config_get( 'use_javascript' ) ) { 362 PRINT '<select name="project_id" class="small" onchange="document.forms.form_set_project.submit();">'; 363 } else { 364 PRINT '<select name="project_id" class="small">'; 365 } 366 print_project_option_list( join( ';', helper_get_current_project_trace() ), true, null, true ); 367 PRINT '</select> '; 368 } 369 PRINT '<input type="submit" class="button-small" value="' . lang_get( 'switch' ) . '" />'; 370 371 if ( OFF != config_get( 'rss_enabled' ) ) { 372 # Link to RSS issues feed for the selected project, including authentication details. 373 PRINT '<a href="' . rss_get_issues_feed_url() . '">'; 374 PRINT '<img src="images/rss.gif" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; 375 PRINT '</a>'; 376 } 377 378 PRINT '</form>'; 379 PRINT '</td>'; 380 PRINT '</tr>'; 381 PRINT '</table>'; 382 } 383 384 # -------------------- 385 # (12) Print a user-defined banner at the bottom of the page if there is one. 386 function html_bottom_banner() { 387 $t_page = config_get( 'bottom_include_page' ); 388 389 if ( !is_blank( $t_page ) && file_exists( $t_page ) && !is_dir( $t_page ) ) { 390 include( $t_page ); 391 } 392 } 393 394 # -------------------- 395 # (13) Print the page footer information 396 function html_footer( $p_file ) { 397 global $g_timer, $g_queries_array, $g_request_time; 398 399 # If a user is logged in, update their last visit time. 400 # We do this at the end of the page so that: 401 # 1) we can display the user's last visit time on a page before updating it 402 # 2) we don't invalidate the user cache immediately after fetching it 403 # 3) don't do this on the password verification or update page, as it causes the 404 # verification comparison to fail 405 if ( auth_is_user_authenticated() && !( is_page_name( 'verify.php' ) || is_page_name( 'account_update.php' ) ) ) { 406 $t_user_id = auth_get_current_user_id(); 407 user_update_last_visit( $t_user_id ); 408 } 409 410 echo "\t", '<br />', "\n"; 411 echo "\t", '<hr size="1" />', "\n"; 412 413 echo '<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr valign="top"><td>'; 414 if ( ON == config_get( 'show_version' ) ) { 415 echo "\t", '<span class="timer"><a href="http://www.mantisbt.org/" title="Free Web Based Bug Tracker">Mantis ', MANTIS_VERSION, '</a>', 416 '[<a href="http://www.mantisbt.org/" title="Free Web Based Bug Tracker" target="_blank">^</a>]</span>', "\n"; 417 } 418 echo "\t", '<address>Copyright © 2000 - 2007 Mantis Group</address>', "\n"; 419 420 # only display webmaster email is current user is not the anonymous user 421 if ( ! is_page_name( 'login_page.php' ) && !current_user_is_anonymous() ) { 422 echo "\t", '<address><a href="mailto:', config_get( 'webmaster_email' ), '">', config_get( 'webmaster_email' ), '</a></address>', "\n"; 423 } 424 425 # print timings 426 if ( ON == config_get( 'show_timer' ) ) { 427 $g_timer->print_times(); 428 } 429 430 # print db queries that were run 431 if ( helper_show_queries() ) { 432 $t_count = count( $g_queries_array ); 433 echo "\t", $t_count, ' total queries executed.<br />', "\n"; 434 $t_unique_queries = 0; 435 $t_shown_queries = array(); 436 for ( $i = 0; $i < $t_count; $i++ ) { 437 if ( ! in_array( $g_queries_array[$i][0], $t_shown_queries ) ) { 438 $t_unique_queries++; 439 $g_queries_array[$i][3] = false; 440 array_push( $t_shown_queries, $g_queries_array[$i][0] ); 441 } else { 442 $g_queries_array[$i][3] = true; 443 } 444 } 445 echo "\t", $t_unique_queries . ' unique queries executed.<br />', "\n"; 446 if ( ON == config_get( 'show_queries_list' ) ) { 447 echo "\t", '<table>', "\n"; 448 $t_total = 0; 449 for ( $i = 0; $i < $t_count; $i++ ) { 450 $t_time = $g_queries_array[$i][1]; 451 $t_caller = $g_queries_array[$i][2]; 452 $t_total += $t_time; 453 $t_style_tag = ''; 454 if ( true == $g_queries_array[$i][3] ) { 455 $t_style_tag = ' style="color: red;"'; 456 } 457 echo "\t", '<tr valign="top"><td', $t_style_tag, '>', ($i+1), '</td>'; 458 echo '<td', $t_style_tag, '>', $t_time , '</td>'; 459 echo '<td', $t_style_tag, '><span style="color: gray;">', $t_caller, '</span><br />', string_html_specialchars($g_queries_array[$i][0]), '</td></tr>', "\n"; 460 } 461 462 # @@@ Note sure if we should localize them given that they are debug info. Will add if requested by users. 463 echo "\t", '<tr><td></td><td>', $t_total, '</td><td>SQL Queries Total Time</td></tr>', "\n"; 464 echo "\t", '<tr><td></td><td>', round( microtime_float() - $g_request_time, 4 ), '</td><td>Page Request Total Time</td></tr>', "\n"; 465 echo "\t", '</table>', "\n"; 466 } 467 } 468 469 echo '</td><td><div align="right">'; 470 echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="images/mantis_logo_button.gif" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; 471 echo '</div></td></tr></table>'; 472 } 473 474 # -------------------- 475 # (14) End the <body> section 476 function html_body_end() { 477 echo '</body>', "\n"; 478 } 479 480 # -------------------- 481 # (15) Print the closing <html> tag 482 function html_end() { 483 echo '</html>', "\n"; 484 } 485 486 487 ########################################################################### 488 # HTML Menu API 489 ########################################################################### 490 491 function prepare_custom_menu_options( $p_config ) { 492 $t_custom_menu_options = config_get( $p_config ); 493 $t_options = array(); 494 495 foreach( $t_custom_menu_options as $t_custom_option ) { 496 $t_access_level = $t_custom_option[1]; 497 if ( access_has_project_level( $t_access_level ) ) { 498 $t_caption = lang_get_defaulted( $t_custom_option[0] ); 499 $t_link = $t_custom_option[2]; 500 $t_options[] = "<a href=\"$t_link\">$t_caption</a>"; 501 } 502 } 503 504 return $t_options; 505 } 506 507 # -------------------- 508 # Print the main menu 509 function print_menu() { 510 if ( auth_is_user_authenticated() ) { 511 $t_protected = current_user_get_field( 'protected' ); 512 $t_current_project = helper_get_current_project(); 513 514 PRINT '<table class="width100" cellspacing="0">'; 515 PRINT '<tr>'; 516 PRINT '<td class="menu">'; 517 $t_menu_options = array(); 518 519 # Main Page 520 $t_menu_options[] = '<a href="main_page.php">' . lang_get( 'main_link' ) . '</a>'; 521 522 # My View 523 $t_menu_options[] = '<a href="my_view_page.php">' . lang_get( 'my_view_link' ) . '</a>'; 524 525 # View Bugs 526 $t_menu_options[] = '<a href="view_all_bug_page.php">' . lang_get( 'view_bugs_link' ) . '</a>'; 527 528 # Report Bugs 529 if ( access_has_project_level( config_get( 'report_bug_threshold' ) ) ) { 530 $t_menu_options[] = string_get_bug_report_link(); 531 } 532 533 # Changelog Page 534 if ( access_has_project_level( config_get( 'view_changelog_threshold' ) ) ) { 535 $t_menu_options[] = '<a href="changelog_page.php">' . lang_get( 'changelog_link' ) . '</a>'; 536 } 537 538 # Roadmap Page 539 if ( access_has_project_level( config_get( 'roadmap_view_threshold' ) ) ) { 540 $t_menu_options[] = '<a href="roadmap_page.php">' . lang_get( 'roadmap_link' ) . '</a>'; 541 } 542 543 # Summary Page 544 if ( access_has_project_level( config_get( 'view_summary_threshold' ) ) ) { 545 $t_menu_options[] = '<a href="summary_page.php">' . lang_get( 'summary_link' ) . '</a>'; 546 } 547 548 # Project Documentation Page 549 if( ON == config_get( 'enable_project_documentation' ) ) { 550 $t_menu_options[] = '<a href="proj_doc_page.php">' . lang_get( 'docs_link' ) . '</a>'; 551 } 552 553 # Project Wiki 554 if ( wiki_is_enabled() ) { 555 $t_menu_options[] = '<a href="wiki.php?type=project&id=' . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; 556 } 557 558 # Manage Users (admins) or Manage Project (managers) or Manage Custom Fields 559 $t_show_access = min( config_get( 'manage_user_threshold' ), config_get( 'manage_project_threshold' ), config_get( 'manage_custom_fields_threshold' ) ); 560 if ( access_has_global_level( $t_show_access) || access_has_any_project( $t_show_access ) ) { 561 $t_current_project = helper_get_current_project(); 562 if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { 563 $t_link = 'manage_user_page.php'; 564 } else { 565 if ( access_has_project_level( config_get( 'manage_project_threshold' ), $t_current_project ) 566 && ( $t_current_project <> ALL_PROJECTS ) ) { 567 $t_link = 'manage_proj_edit_page.php?project_id=' . $t_current_project; 568 } else { 569 $t_link = 'manage_proj_page.php'; 570 } 571 } 572 $t_menu_options[] = "<a href=\"$t_link\">" . lang_get( 'manage_link' ) . '</a>'; 573 } 574 575 # News Page 576 if ( access_has_project_level( config_get( 'manage_news_threshold' ) ) ) { 577 # Admin can edit news for All Projects (site-wide) 578 if ( ( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) { 579 $t_menu_options[] = '<a href="news_menu_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; 580 } else { 581 $t_menu_options[] = '<a href="login_select_proj_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; 582 } 583 } 584 585 # Account Page (only show accounts that are NOT protected) 586 if ( OFF == $t_protected ) { 587 $t_menu_options[] = '<a href="account_page.php">' . lang_get( 'account_link' ) . '</a>'; 588 } 589 590 # Add custom options 591 $t_custom_options = prepare_custom_menu_options( 'main_menu_custom_options' ); 592 $t_menu_options = array_merge( $t_menu_options, $t_custom_options ); 593 if ( config_get('time_tracking_enabled') && config_get('time_tracking_with_billing') ) 594 $t_menu_options[] = '<a href="billing_page.php">' . lang_get( 'time_tracking_billing_link' ) . '</a>'; 595 596 # Logout (no if anonymously logged in) 597 if ( !current_user_is_anonymous() ) { 598 $t_menu_options[] = '<a href="logout_page.php">' . lang_get( 'logout_link' ) . '</a>'; 599 } 600 PRINT implode( $t_menu_options, ' | ' ); 601 PRINT '</td>'; 602 PRINT '<td class="menu right nowrap">'; 603 PRINT '<form method="post" action="jump_to_bug.php">'; 604 605 if ( ON == config_get( 'use_javascript' ) ) { 606 $t_bug_label = lang_get( 'issue_id' ); 607 PRINT "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" value=\"$t_bug_label\" onfocus=\"if (this.value == '$t_bug_label') this.value = ''\" onblur=\"if (this.value == '') this.value = '$t_bug_label'\" /> "; 608 } else { 609 PRINT "<input type=\"text\" name=\"bug_id\" size=\"10\" class=\"small\" /> "; 610 } 611 612 PRINT '<input type="submit" class="button-small" value="' . lang_get( 'jump' ) . '" /> '; 613 PRINT '</form>'; 614 PRINT '</td>'; 615 PRINT '</tr>'; 616 PRINT '</table>'; 617 } 618 } 619 620 # -------------------- 621 # Print the menu bar with a list of projects to which the user has access 622 function print_project_menu_bar() { 623 $t_project_ids = current_user_get_accessible_projects(); 624 625 PRINT '<table class="width100" cellspacing="0">'; 626 PRINT '<tr>'; 627 PRINT '<td class="menu">'; 628 PRINT '<a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a>'; 629 630 foreach ( $t_project_ids as $t_id ) { 631 PRINT " | <a href=\"set_project.php?project_id=$t_id\">" . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; 632 print_subproject_menu_bar( $t_id, $t_id . ';' ); 633 } 634 635 PRINT '</td>'; 636 PRINT '</tr>'; 637 PRINT '</table>'; 638 } 639 640 # -------------------- 641 # Print the menu bar with a list of projects to which the user has access 642 function print_subproject_menu_bar( $p_project_id, $p_parents = '' ) { 643 $t_subprojects = current_user_get_accessible_subprojects( $p_project_id ); 644 $t_char = ':'; 645 foreach ( $t_subprojects as $t_subproject ) { 646 PRINT "$t_char <a href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; 647 print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' ); 648 $t_char = ','; 649 } 650 } 651 652 # -------------------- 653 # Print the menu for the graph summary section 654 function print_menu_graph() { 655 if ( config_get( 'use_jpgraph' ) ) { 656 $t_icon_path = config_get( 'icon_path' ); 657 658 PRINT '<br />'; 659 PRINT '<a href="summary_page.php"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; 660 PRINT '<a href="summary_graph_imp_status.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; 661 PRINT '<a href="summary_graph_imp_priority.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; 662 PRINT '<a href="summary_graph_imp_severity.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; 663 PRINT '<a href="summary_graph_imp_category.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; 664 PRINT '<a href="summary_graph_imp_resolution.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; 665 } 666 } 667 668 # -------------------- 669 # Print the menu for the manage section 670 # $p_page specifies the current page name so it's link can be disabled 671 function print_manage_menu( $p_page = '' ) { 672 $t_manage_user_page = 'manage_user_page.php'; 673 $t_manage_project_menu_page = 'manage_proj_page.php'; 674 $t_manage_custom_field_page = 'manage_custom_field_page.php'; 675 $t_manage_config_page = 'adm_config_report.php'; 676 $t_manage_prof_menu_page = 'manage_prof_menu_page.php'; 677 # $t_documentation_page = 'documentation_page.php'; 678 679 switch ( $p_page ) { 680 case $t_manage_user_page: 681 $t_manage_user_page = ''; 682 break; 683 case $t_manage_project_menu_page: 684 $t_manage_project_menu_page = ''; 685 break; 686 case $t_manage_custom_field_page: 687 $t_manage_custom_field_page = ''; 688 break; 689 case $t_manage_config_page: 690 $t_manage_config_page = ''; 691 break; 692 case $t_manage_prof_menu_page: 693 $t_manage_prof_menu_page = ''; 694 break; 695 # case $t_documentation_page: 696 # $t_documentation_page = ''; 697 # break; 698 } 699 700 PRINT '<br /><div align="center">'; 701 if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { 702 print_bracket_link( $t_manage_user_page, lang_get( 'manage_users_link' ) ); 703 } 704 if ( access_has_project_level( config_get( 'manage_project_threshold' ) ) ) { 705 print_bracket_link( $t_manage_project_menu_page, lang_get( 'manage_projects_link' ) ); 706 } 707 if ( access_has_global_level( config_get( 'manage_custom_fields_threshold' ) ) ) { 708 print_bracket_link( $t_manage_custom_field_page, lang_get( 'manage_custom_field_link' ) ); 709 } 710 if ( access_has_global_level( config_get( 'manage_global_profile_threshold' ) ) ) { 711 print_bracket_link( $t_manage_prof_menu_page, lang_get( 'manage_global_profiles_link' ) ); 712 } 713 if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { 714 print_bracket_link( $t_manage_config_page, lang_get( 'manage_config_link' ) ); 715 } 716 # print_bracket_link( $t_documentation_page, lang_get( 'documentation_link' ) ); 717 PRINT '</div>'; 718 } 719 720 # -------------------- 721 # Print the menu for the manage configuration section 722 # $p_page specifies the current page name so it's link can be disabled 723 function print_manage_config_menu( $p_page = '' ) { 724 $t_configuration_report = 'adm_config_report.php'; 725 $t_permissions_summary_report = 'adm_permissions_report.php'; 726 $t_manage_work_threshold = 'manage_config_work_threshold_page.php'; 727 $t_manage_email = 'manage_config_email_page.php'; 728 $t_manage_workflow = 'manage_config_workflow_page.php'; 729 730 switch ( $p_page ) { 731 case $t_configuration_report: 732 $t_configuration_report = ''; 733 break; 734 case $t_permissions_summary_report: 735 $t_permissions_summary_report = ''; 736 break; 737 case $t_manage_work_threshold: 738 $t_manage_work_threshold = ''; 739 break; 740 case $t_manage_email: 741 $t_manage_email = ''; 742 break; 743 case $t_manage_workflow: 744 $t_manage_workflow = ''; 745 break; 746 } 747 748 PRINT '<br /><div align="center">'; 749 if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { 750 print_bracket_link( $t_configuration_report, lang_get_defaulted( 'configuration_report' ) ); 751 print_bracket_link( $t_permissions_summary_report, lang_get( 'permissions_summary_report' ) ); 752 print_bracket_link( $t_manage_work_threshold, lang_get( 'manage_threshold_config' ) ); 753 print_bracket_link( $t_manage_workflow, lang_get( 'manage_workflow_config' ) ); 754 print_bracket_link( $t_manage_email, lang_get( 'manage_email_config' ) ); 755 } 756 PRINT '</div>'; 757 } 758 759 # -------------------- 760 # Print the menu for the account section 761 # $p_page specifies the current page name so it's link can be disabled 762 function print_account_menu( $p_page='' ) { 763 $t_account_page = 'account_page.php'; 764 $t_account_prefs_page = 'account_prefs_page.php'; 765 $t_account_profile_menu_page = 'account_prof_menu_page.php'; 766 $t_account_sponsor_page = 'account_sponsor_page.php'; 767 768 switch ( $p_page ) { 769 case $t_account_page : $t_account_page = ''; break; 770 case $t_account_prefs_page : $t_account_prefs_page = ''; break; 771 case $t_account_profile_menu_page : $t_account_profile_menu_page = ''; break; 772 case $t_account_sponsor_page : $t_account_sponsor_page = ''; break; 773 } 774 775 print_bracket_link( $t_account_page, lang_get( 'account_link' ) ); 776 print_bracket_link( $t_account_prefs_page, lang_get( 'change_preferences_link' ) ); 777 if ( access_has_project_level( config_get( 'add_profile_threshold' ) ) ) { 778 print_bracket_link( $t_account_profile_menu_page, lang_get( 'manage_profiles_link' ) ); 779 } 780 if ( ( config_get( 'enable_sponsorship' ) == ON ) && 781 ( access_has_project_level( config_get( 'view_sponsorship_total_threshold' ) ) ) && 782 !current_user_is_anonymous() ) { 783 print_bracket_link( $t_account_sponsor_page, lang_get( 'my_sponsorship' ) ); 784 } 785 } 786 787 # -------------------- 788 # Print the menu for the docs section 789 # $p_page specifies the current page name so it's link can be disabled 790 function print_doc_menu( $p_page='' ) { 791 $t_documentation_html = config_get( 'manual_url' ); 792 $t_proj_doc_page = 'proj_doc_page.php'; 793 $t_proj_doc_add_page = 'proj_doc_add_page.php'; 794 795 switch ( $p_page ) { 796 case $t_documentation_html : $t_documentation_html = ''; break; 797 case $t_proj_doc_page : $t_proj_doc_page = ''; break; 798 case $t_proj_doc_add_page : $t_proj_doc_add_page = ''; break; 799 } 800 801 print_bracket_link( $t_documentation_html, lang_get( 'user_documentation' ) ); 802 print_bracket_link( $t_proj_doc_page, lang_get( 'project_documentation' ) ); 803 if ( file_allow_project_upload() ) { 804 print_bracket_link( $t_proj_doc_add_page, lang_get( 'add_file' ) ); 805 } 806 } 807 808 # -------------------- 809 # Print the menu for the summary section 810 # $p_page specifies the current page name so it's link can be disabled 811 function print_summary_menu( $p_page='' ) { 812 PRINT '<div align="center">'; 813 print_bracket_link( 'print_all_bug_page.php', lang_get( 'print_all_bug_page_link' ) ); 814 815 if ( config_get( 'use_jpgraph' ) != 0 ) { 816 $t_summary_page = 'summary_page.php'; 817 $t_summary_jpgraph_page = 'summary_jpgraph_page.php'; 818 819 switch ( $p_page ) { 820 case $t_summary_page : $t_summary_page = ''; break; 821 case $t_summary_jpgraph_page: $t_summary_jpgraph_page = ''; break; 822 } 823 824 print_bracket_link( $t_summary_page, lang_get( 'summary_link' ) ); 825 print_bracket_link( $t_summary_jpgraph_page, lang_get( 'summary_jpgraph_link' ) ); 826 } 827 PRINT '</div>'; 828 } 829 830 831 #========================= 832 # Candidates for moving to print_api 833 #========================= 834 835 # -------------------- 836 # Print the color legend for the status colors 837 function html_status_legend() { 838 PRINT '<br />'; 839 PRINT '<table class="width100" cellspacing="1">'; 840 PRINT '<tr>'; 841 842 $t_arr = explode_enum_string( config_get( 'status_enum_string' ) ); 843 $enum_count = count( $t_arr ); 844 $width = (int)(100 / $enum_count); 845 for ( $i=0; $i < $enum_count; $i++) { 846 $t_s = explode_enum_arr( $t_arr[$i] ); 847 $t_val = get_enum_element( 'status', $t_s[0] ); 848 $t_color = get_status_color( $t_s[0] ); 849 850 PRINT "<td class=\"small-caption\" width=\"$width%\" bgcolor=\"$t_color\">$t_val</td>"; 851 } 852 853 PRINT '</tr>'; 854 PRINT '</table>'; 855 if ( ON == config_get( 'status_percentage_legend' ) ) { 856 html_status_percentage_legend(); 857 } 858 } 859 860 # -------------------- 861 # Print the legend for the status percentage 862 function html_status_percentage_legend() { 863 864 $t_mantis_bug_table = config_get( 'mantis_bug_table' ); 865 $t_project_id = helper_get_current_project(); 866 $t_user_id = auth_get_current_user_id(); 867 868 #checking if it's a per project statistic or all projects 869 $t_specific_where = helper_project_specific_where( $t_project_id, $t_user_id ); 870 871 $query = "SELECT status, COUNT(*) AS number 872 FROM $t_mantis_bug_table 873 WHERE $t_specific_where 874 GROUP BY status"; 875 $result = db_query( $query ); 876 877 $t_bug_count = 0; 878 $t_status_count_array = array(); 879 880 while ( $row = db_fetch_array( $result ) ) { 881 882 $t_status_count_array[ $row['status'] ] = $row['number']; 883 $t_bug_count += $row['number']; 884 } 885 886 $t_arr = explode_enum_string( config_get( 'status_enum_string' ) ); 887 $enum_count = count( $t_arr ); 888 889 if ( $t_bug_count > 0 ) { 890 echo '<br />'; 891 echo '<table class="width100" cellspacing="1">'; 892 echo '<tr>'; 893 echo '<td class="form-title" colspan="'.$enum_count.'">'.lang_get( 'issue_status_percentage' ).'</td>'; 894 echo '</tr>'; 895 echo '<tr>'; 896 897 for ( $i=0; $i < $enum_count; $i++) { 898 $t_s = explode_enum_arr( $t_arr[$i] ); 899 $t_color = get_status_color( $t_s[0] ); 900 $t_status = $t_s[0]; 901 902 if ( !isset( $t_status_count_array[ $t_status ] ) ) { 903 $t_status_count_array[ $t_status ] = 0; 904 } 905 906 $width = round( ( $t_status_count_array[ $t_status ] / $t_bug_count ) * 100 ); 907 908 if ($width > 0) { 909 echo "<td class=\"small-caption-center\" width=\"$width%\" bgcolor=\"$t_color\">$width%</td>"; 910 } 911 } 912 913 echo '</tr>'; 914 echo '</table>'; 915 } 916 } 917 918 # -------------------- 919 # Print an html button inside a form 920 function html_button ( $p_action, $p_button_text, $p_fields = null, $p_method = 'post' ) { 921 $p_action = urlencode( $p_action ); 922 $p_button_text = string_attribute( $p_button_text ); 923 if ( null === $p_fields ) { 924 $p_fields = array(); 925 } 926 927 if ( strtolower( $p_method ) == 'get' ) { 928 $t_method = 'get'; 929 } else { 930 $t_method = 'post'; 931 } 932 933 PRINT "<form method=\"$t_method\" action=\"$p_action\">\n"; 934 935 foreach ( $p_fields as $key => $val ) { 936 $key = string_attribute( $key ); 937 $val = string_attribute( $val ); 938 939 PRINT " <input type=\"hidden\" name=\"$key\" value=\"$val\" />\n"; 940 } 941 942 PRINT " <input type=\"submit\" class=\"button\" value=\"$p_button_text\" />\n"; 943 PRINT "</form>\n"; 944 } 945 946 # -------------------- 947 # Print a button to update the given bug 948 function html_button_bug_update( $p_bug_id ) { 949 if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) { 950 html_button( string_get_bug_update_page(), 951 lang_get( 'update_bug_button' ), 952 array( 'bug_id' => $p_bug_id ) ); 953 } 954 } 955 956 # -------------------- 957 # Print Change Status to: button 958 # This code is similar to print_status_option_list except 959 # there is no masking, except for the current state 960 function html_button_bug_change_status( $p_bug_id ) { 961 $t_bug_project_id = bug_get_field( $p_bug_id, 'project_id' ); 962 $t_bug_current_state = bug_get_field( $p_bug_id, 'status' ); 963 $t_current_access = access_get_project_level( $t_bug_project_id ); 964 965 $t_enum_list = get_status_option_list( $t_current_access, $t_bug_current_state, false, 966 ( bug_get_field( $p_bug_id, 'reporter_id' ) == auth_get_current_user_id() && ( ON == config_get( 'allow_reporter_close' ) ) ) ); 967 968 if ( count( $t_enum_list ) > 0 ) { 969 # resort the list into ascending order after noting the key from the first element (the default) 970 $t_default_arr = each( $t_enum_list ); 971 $t_default = $t_default_arr['key']; 972 ksort( $t_enum_list ); 973 reset( $t_enum_list ); 974 975 echo "<form method=\"post\" action=\"bug_change_status_page.php\">"; 976 977 $t_button_text = lang_get( 'bug_status_to_button' ); 978 echo "<input type=\"submit\" class=\"button\" value=\"$t_button_text\" />"; 979 980 echo " <select name=\"new_status\">"; # space at beginning of line is important 981 foreach ( $t_enum_list as $key => $val ) { 982 echo "<option value=\"$key\" "; 983 check_selected( $key, $t_default ); 984 echo ">$val</option>"; 985 } 986 echo '</select>'; 987 988 $t_bug_id = string_attribute( $p_bug_id ); 989 echo "<input type=\"hidden\" name=\"bug_id\" value=\"$t_bug_id\" />\n"; 990 991 echo "</form>\n"; 992 } 993 } 994 995 # -------------------- 996 # Print Assign To: combo box of possible handlers 997 function html_button_bug_assign_to( $p_bug_id ) { 998 # make sure status is allowed of assign would cause auto-set-status 999 $t_status = bug_get_field( $p_bug_id, 'status' ); # workflow implementation 1000 1001 if ( ON == config_get( 'auto_set_status_to_assigned' ) && 1002 !bug_check_workflow( $t_status, config_get( 'bug_assigned_status' ) ) ) { # workflow 1003 return; 1004 } 1005 1006 # make sure current user has access to modify bugs. 1007 if ( !access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $p_bug_id ) ) { 1008 return; 1009 } 1010 1011 $t_reporter_id = bug_get_field( $p_bug_id, 'reporter_id' ); 1012 $t_handler_id = bug_get_field( $p_bug_id, 'handler_id' ); 1013 $t_current_user_id = auth_get_current_user_id(); 1014 $t_new_status = ( ON == config_get( 'auto_set_status_to_assigned' ) ) ? config_get( 'bug_assigned_status' ) : $t_status; 1015 1016 $t_options = array(); 1017 $t_default_assign_to = null; 1018 1019 if ( ( $t_handler_id != $t_current_user_id ) && 1020 ( access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug_id, $t_current_user_id ) ) ) { 1021 $t_options[] = array( $t_current_user_id, '[' . lang_get( 'myself' ) . ']' ); 1022 $t_default_assign_to = $t_current_user_id; 1023 } 1024 1025 if ( ( $t_handler_id != $t_reporter_id ) && user_exists( $t_reporter_id ) && 1026 ( access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug_id, $t_reporter_id ) ) ) { 1027 $t_options[] = array( $t_reporter_id, '[' . lang_get( 'reporter' ) . ']' ); 1028 1029 if ( $t_default_assign_to === null ) { 1030 $t_default_assign_to = $t_reporter_id; 1031 } 1032 } 1033 1034 PRINT "<form method=\"post\" action=\"bug_assign.php\">"; 1035 1036 $t_button_text = lang_get( 'bug_assign_to_button' ); 1037 PRINT "<input type=\"submit\" class=\"button\" value=\"$t_button_text\" />"; 1038 1039 PRINT " <select name=\"handler_id\">"; # space at beginning of line is important 1040 1041 $t_already_selected = false; 1042 1043 foreach ( $t_options as $t_entry ) { 1044 $t_id = string_attribute( $t_entry[0] ); 1045 $t_caption = string_attribute( $t_entry[1] ); 1046 1047 # if current user and reporter can't be selected, then select the first 1048 # user in the list. 1049 if ( $t_default_assign_to === null ) { 1050 $t_default_assign_to = $t_id; 1051 } 1052 1053 PRINT "<option value=\"$t_id\" "; 1054 1055 if ( ( $t_id == $t_default_assign_to ) && !$t_already_selected ) { 1056 check_selected( $t_id, $t_default_assign_to ); 1057 $t_already_selected = true; 1058 } 1059 1060 PRINT ">$t_caption</option>"; 1061 } 1062 1063 # allow un-assigning if already assigned. 1064 if ( $t_handler_id != 0 ) { 1065 PRINT "<option value=\"0\"></option>"; 1066 } 1067 1068 $t_project_id = bug_get_field( $p_bug_id, 'project_id' ); 1069 # 0 means currently selected 1070 print_assign_to_option_list( 0, $t_project_id ); 1071 PRINT "</select>"; 1072 1073 $t_bug_id = string_attribute( $p_bug_id ); 1074 PRINT "<input type=\"hidden\" name=\"bug_id\" value=\"$t_bug_id\" />\n"; 1075 1076 PRINT "</form>\n"; 1077 } 1078 1079 # -------------------- 1080 # Print a button to move the given bug to a different project 1081 function html_button_bug_move( $p_bug_id ) { 1082 $t_status = bug_get_field( $p_bug_id, 'status' ); 1083 1084 if ( access_has_bug_level( config_get( 'move_bug_threshold' ), $p_bug_id ) ) { 1085 html_button( 'bug_actiongroup_page.php', 1086 lang_get( 'move_bug_button' ), 1087 array( 'bug_arr[]' => $p_bug_id, 'action' => 'MOVE' ) ); 1088 } 1089 } 1090 1091 # -------------------- 1092 # Print a button to move the given bug to a different project 1093 function html_button_bug_create_child( $p_bug_id ) { 1094 if ( ON == config_get( 'enable_relationship' ) ) { 1095 if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) { 1096 html_button( string_get_bug_report_url(), 1097 lang_get( 'create_child_bug_button' ), 1098 array( 'm_id' => $p_bug_id ) ); 1099 } 1100 } 1101 } 1102 1103 # -------------------- 1104 # Print a button to reopen the given bug 1105 function html_button_bug_reopen( $p_bug_id ) { 1106 $t_status = bug_get_field( $p_bug_id, 'status' ); 1107 $t_reopen_status = config_get( 'bug_reopen_status' ); 1108 $t_project = bug_get_field( $p_bug_id, 'project_id' ); 1109 1110 if ( access_has_bug_level( config_get( 'reopen_bug_threshold' ), $p_bug_id ) || 1111 ( ( bug_get_field( $p_bug_id, 'reporter_id' ) == auth_get_current_user_id() ) && 1112 ( ON == config_get( 'allow_reporter_reopen' ) ) 1113 ) 1114 ) { 1115 html_button( 'bug_change_status_page.php', 1116 lang_get( 'reopen_bug_button' ), 1117 array( 'bug_id' => $p_bug_id , 1118 'new_status' => $t_reopen_status, 1119 'reopen_flag' => ON ) ); 1120 } 1121 } 1122 1123 # -------------------- 1124 # Print a button to monitor the given bug 1125 function html_button_bug_monitor( $p_bug_id ) { 1126 if ( access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_bug_id ) ) { 1127 html_button( 'bug_monitor.php', 1128 lang_get( 'monitor_bug_button' ), 1129 array( 'bug_id' => $p_bug_id, 'action' => 'add' ) ); 1130 } 1131 } 1132 1133 # -------------------- 1134 # Print a button to unmonitor the given bug 1135 # no reason to ever disallow someone from unmonitoring a bug 1136 function html_button_bug_unmonitor( $p_bug_id ) { 1137 html_button( 'bug_monitor.php', 1138 lang_get( 'unmonitor_bug_button' ), 1139 array( 'bug_id' => $p_bug_id, 'action' => 'delete' ) ); 1140 } 1141 1142 # -------------------- 1143 # Print a button to delete the given bug 1144 function html_button_bug_delete( $p_bug_id ) { 1145 if ( access_has_bug_level( config_get( 'delete_bug_threshold' ), $p_bug_id ) ) { 1146 html_button( 'bug_actiongroup_page.php', 1147 lang_get( 'delete_bug_button' ), 1148 array( 'bug_arr[]' => $p_bug_id, 'action' => 'DELETE' ) ); 1149 } 1150 } 1151 1152 # -------------------- 1153 # Print a button to create a wiki page 1154 function html_button_wiki( $p_bug_id ) { 1155 if ( ON == config_get( 'wiki_enable' ) ) { 1156 if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) { 1157 html_button( 'wiki.php', 1158 lang_get_defaulted( 'Wiki' ), 1159 array( 'id' => $p_bug_id, 'type' => 'issue' ), 1160 'get' ); 1161 } 1162 } 1163 } 1164 1165 # -------------------- 1166 # Print all buttons for view bug pages 1167 function html_buttons_view_bug_page( $p_bug_id ) { 1168 $t_resolved = config_get( 'bug_resolved_status_threshold' ); 1169 $t_status = bug_get_field( $p_bug_id, 'status' ); 1170 $t_readonly = bug_is_readonly( $p_bug_id ); 1171 1172 PRINT '<table><tr class="vcenter">'; 1173 if ( !$t_readonly ) { 1174 # UPDATE button 1175 echo '<td class="center">'; 1176 html_button_bug_update( $p_bug_id ); 1177 echo '</td>'; 1178 1179 # ASSIGN button 1180 echo '<td class="center">'; 1181 html_button_bug_assign_to( $p_bug_id ); 1182 echo '</td>'; 1183 } 1184 1185 # Change State button 1186 echo '<td class="center">'; 1187 html_button_bug_change_status( $p_bug_id ); 1188 echo '</td>'; 1189 1190 # MONITOR/UNMONITOR button 1191 echo '<td class="center">'; 1192 if ( !current_user_is_anonymous() ) { 1193 if ( user_is_monitoring_bug( auth_get_current_user_id(), $p_bug_id ) ) { 1194 html_button_bug_unmonitor( $p_bug_id ); 1195 } else { 1196 html_button_bug_monitor( $p_bug_id ); 1197 } 1198 } 1199 echo '</td>'; 1200 1201 if ( !$t_readonly ) { 1202 # CREATE CHILD button 1203 echo '<td class="center">'; 1204 html_button_bug_create_child( $p_bug_id ); 1205 echo '</td>'; 1206 } 1207 1208 if ( $t_resolved <= $t_status ) { # resolved is not the same as readonly 1209 PRINT '<td class="center">'; 1210 # REOPEN button 1211 html_button_bug_reopen( $p_bug_id ); 1212 PRINT '</td>'; 1213 } 1214 1215 if ( !$t_readonly ) { 1216 # MOVE button 1217 echo '<td class="center">'; 1218 html_button_bug_move( $p_bug_id ); 1219 echo '</td>'; 1220 } 1221 1222 # DELETE button 1223 echo '<td class="center">'; 1224 html_button_bug_delete( $p_bug_id ); 1225 echo '</td>'; 1226 1227 helper_call_custom_function( 'print_bug_view_page_custom_buttons', array( $p_bug_id ) ); 1228 1229 echo '</tr></table>'; 1230 } 1231 1232 /** 1233 * Print the Update Tag button 1234 * @param integer Tag ID 1235 */ 1236 function html_button_tag_update( $p_tag_id ) { 1237 if ( access_has_global_level( config_get( 'tag_edit_threshold' ) ) 1238 || ( auth_get_current_user_id() == tag_get_field( $p_tag_id, 'user_id' ) 1239 && access_has_global_level( config_get( 'tag_edit_own_threshold' ) ) ) ) 1240 { 1241 html_button( 'tag_update_page.php', lang_get( 'tag_update_button' ), array( 'tag_id' => $p_tag_id ) ); 1242 } 1243 } 1244 1245 /** 1246 * Print the Delete Tag button 1247 * @param integer Tag ID 1248 */ 1249 function html_button_tag_delete( $p_tag_id ) { 1250 if ( access_has_global_level( config_get( 'tag_edit_threshold' ) ) ) { 1251 html_button( 'tag_delete.php', lang_get( 'tag_delete_button' ), array( 'tag_id' => $p_tag_id ) ); 1252 } 1253 } 1254 1255 /** 1256 * Print all buttons for the Tag View page 1257 * @param integer Tag ID 1258 */ 1259 function html_buttons_tag_view_page( $p_tag_id ) { 1260 html_button_tag_update( $p_tag_id ); 1261 html_button_tag_delete( $p_tag_id ); 1262 } 1263 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |