mantisbt:issue:8253
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mantisbt:issue:8253 [2007/11/07 00:33] – Used PHP Syntax Highlighting for PHP code. vboctor | mantisbt:issue:8253 [2010/05/04 09:08] (current) – rattkin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Improved Mantis/ | ====== Improved Mantis/ | ||
| - | FIXME | + | FIXME I think, the description is a little bit clumsy. Please correct. |
| The following description works with mantis version 1.1.0rc2 and dokuwiki version 2007-06-26b. It based on [[mantisbt: | The following description works with mantis version 1.1.0rc2 and dokuwiki version 2007-06-26b. It based on [[mantisbt: | ||
| + | |||
| + | You can get all these files from [[http:// | ||
| ===== Dokuwiki ===== | ===== Dokuwiki ===== | ||
| Grab the latest (2007-06-26b) version and install it. Make sure it is working properly. | Grab the latest (2007-06-26b) version and install it. Make sure it is working properly. | ||
| + | |||
| ==== Mantis Syntax Plug-in ==== | ==== Mantis Syntax Plug-in ==== | ||
| + | If you only want links back to mantis, there is no need for a systax plugin. You can use interwiki shortcuts to create links back to mantis (see [[http:// | ||
| + | |||
| + | The syntax plugin based an the plugin from Victor Boctor, but I changed the syntax. Now it uses **{** like almost all other plugins instead of **~**. | ||
| For the syntax-plugin with support for the dokuwiki admin panel, you have to create several files: | For the syntax-plugin with support for the dokuwiki admin panel, you have to create several files: | ||
| Line 31: | Line 37: | ||
| /** | /** | ||
| * A plug-in that hyper links references to Mantis issues. | * A plug-in that hyper links references to Mantis issues. | ||
| - | * to Mantis issues should use the following format: | + | * to Mantis issues should use the following format: |
| * | * | ||
| * All DokuWiki plugins to extend the parser/ | * All DokuWiki plugins to extend the parser/ | ||
| Line 122: | Line 128: | ||
| === dokuwiki\lib\plugins\mantis\style.css === | === dokuwiki\lib\plugins\mantis\style.css === | ||
| - | < | + | < |
| div.dokuwiki a.mantislink { | div.dokuwiki a.mantislink { | ||
| background: transparent url(images/ | background: transparent url(images/ | ||
| Line 130: | Line 136: | ||
| === dokuwiki\lib\plugins\mantis\conf\default.php === | === dokuwiki\lib\plugins\mantis\conf\default.php === | ||
| + | <code php> | ||
| + | <?php | ||
| + | $conf[' | ||
| + | $conf[' | ||
| + | $conf[' | ||
| + | ?> | ||
| + | </ | ||
| === dokuwiki\lib\plugins\mantis\conf\metadata.php | === dokuwiki\lib\plugins\mantis\conf\metadata.php | ||
| + | <code php> | ||
| + | <?php | ||
| + | $meta[' | ||
| + | $meta[' | ||
| + | $meta[' | ||
| + | ?> | ||
| + | </ | ||
| === dokuwiki\lib\plugins\mantis\images\bug.gif | === dokuwiki\lib\plugins\mantis\images\bug.gif | ||
| - | A Picture with a little bug, placed in front of the bug links. The file is grabed from dokuwiki.org | + | A [[http:// |
| === dokuwiki\lib\plugins\mantis\lang\en\settings.php | === dokuwiki\lib\plugins\mantis\lang\en\settings.php | ||
| + | <code php> | ||
| + | <?php | ||
| + | /*USE : UTF8*/ | ||
| + | /* | ||
| + | * English language file | ||
| + | */ | ||
| + | $lang[' | ||
| + | $lang[' | ||
| + | ?> | ||
| + | </ | ||
| + | ==== Mantis Template ==== | ||
| + | Go to DokuWiki settings and configure mantis URL at the bottom of the setup page. | ||
| + | Copy the default template (dokuwiki/ | ||
| + | |||
| + | Replace the **main.php** with this one: | ||
| + | <code php> | ||
| + | <?php | ||
| + | /** | ||
| + | * DokuWiki mantis Template | ||
| + | * | ||
| + | * This is the template you need to change for the overall look | ||
| + | * of DokuWiki. | ||
| + | * | ||
| + | */ | ||
| + | |||
| + | // must be run from within DokuWiki | ||
| + | if (!defined(' | ||
| + | |||
| + | global $g_path ; | ||
| + | |||
| + | require_once( $conf[' | ||
| + | |||
| + | $g_path = $conf[' | ||
| + | |||
| + | $t_core_path = config_get( ' | ||
| + | |||
| + | |||
| + | html_begin(); | ||
| + | html_head_begin(); | ||
| + | html_css(); | ||
| + | html_content_type(); | ||
| + | include( config_get( ' | ||
| + | html_rss_link(); | ||
| + | echo '< | ||
| + | |||
| + | | ||
| + | |||
| + | html_title( $p_page_title ); | ||
| + | html_head_javascript(); | ||
| + | |||
| + | html_page_top2() | ||
| + | | ||
| + | // $t_mantis_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; | ||
| + | ?> | ||
| + | <div class=" | ||
| + | <?php html_msgarea()?> | ||
| + | <div class=" | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_searchform()?>& | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | </ | ||
| + | |||
| + | <?php if($conf[' | ||
| + | <div class=" | ||
| + | <?php tpl_breadcrumbs()?> | ||
| + | <?php // | ||
| + | </ | ||
| + | <?php }?> | ||
| + | |||
| + | <?php if($conf[' | ||
| + | <div class=" | ||
| + | <?php tpl_youarehere() ?> | ||
| + | </ | ||
| + | <?php }?> | ||
| + | |||
| + | </ | ||
| + | <?php flush()?> | ||
| + | <div class=" | ||
| + | <!-- wikipage start --> | ||
| + | <?php tpl_content()?> | ||
| + | <!-- wikipage stop --> | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | |||
| + | <?php flush()?> | ||
| + | |||
| + | <div class=" | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <?php tpl_userinfo()?> | ||
| + | </ | ||
| + | <div class=" | ||
| + | <?php tpl_pageinfo()?> | ||
| + | </ | ||
| + | </ | ||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | </ | ||
| + | <div class=" | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | <?php tpl_button(' | ||
| + | </ | ||
| + | <div class=" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | |||
| + | <?php | ||
| + | html_page_bottom1( __FILE__ ); | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | ==== Authentication (Single Sign-On) ==== | ||
| + | Create dokuwiki\inc\auth\mantis.class.php with the code below. | ||
| + | <code php> | ||
| + | <?php | ||
| + | /** | ||
| + | * Mantis auth backend | ||
| + | * | ||
| + | * Uses external Trust mechanism to check against Mantis' | ||
| + | * user cookie. | ||
| + | * | ||
| + | * @author | ||
| + | */ | ||
| + | |||
| + | |||
| + | require_once( $conf[' | ||
| + | |||
| + | # | ||
| + | |||
| + | class auth_mantis extends auth_basic { | ||
| + | /** | ||
| + | * Constructor. | ||
| + | * | ||
| + | * Sets additional capabilities and config strings | ||
| + | */ | ||
| + | function auth_mantis(){ | ||
| + | $this-> | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Authenticates the user using Mantis APIs. | ||
| + | */ | ||
| + | function trustExternal($user, | ||
| + | global $USERINFO; | ||
| + | global $conf; | ||
| + | |||
| + | if ( auth_is_user_authenticated() ) { | ||
| + | // okay we're logged in - set the globals | ||
| + | $USERINFO[' | ||
| + | $USERINFO[' | ||
| + | $USERINFO[' | ||
| + | |||
| + | $t_project_name = getNS( getID() ); | ||
| + | $t_project_id = project_get_id_by_name( $t_project_name ); | ||
| + | $t_access_level = access_get_project_level( $t_project_id ); | ||
| + | $t_access_level_string = strtoupper( get_enum_to_string( config_get( ' | ||
| + | |||
| + | $USERINFO[' | ||
| + | |||
| + | $_SERVER[' | ||
| + | $_SESSION[$conf[' | ||
| + | $_SESSION[$conf[' | ||
| + | |||
| + | return true; | ||
| + | } | ||
| + | |||
| + | // to be sure | ||
| + | auth_logoff(); | ||
| + | |||
| + | return false; | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Logout from Mantis | ||
| + | */ | ||
| + | function logOff(){ | ||
| + | auth_logout(); | ||
| + | } | ||
| + | } | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | ==== Authorisation Configuration ==== | ||
| + | |||
| + | Create '' | ||
| + | |||
| + | <code php> | ||
| + | # acl.auth.php | ||
| + | # <?php exit()?> | ||
| + | # Don't modify the lines above | ||
| + | # | ||
| + | # Access Control Lists | ||
| + | # | ||
| + | # Editing this file by hand shouldn' | ||
| + | # Manager interface instead. | ||
| + | # | ||
| + | # If your auth backend allows special char like spaces in groups | ||
| + | # or user names you need to urlencode them (only chars <128, leave | ||
| + | # UTF-8 multibyte chars as is) | ||
| + | # | ||
| + | # none 0 | ||
| + | # read 1 | ||
| + | # edit 2 | ||
| + | # create 4 | ||
| + | # upload 8 | ||
| + | # delete 16 | ||
| + | |||
| + | * @VIEWER 1 | ||
| + | * @REPORTER 2 | ||
| + | * @DEVELOPER 8 | ||
| + | * @MANAGER 8 | ||
| + | * @ADMINISTRATOR 8 | ||
| + | * @ALL 0 | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Redirect dokuwiki login/ | ||
| + | |||
| + | If you are using url rewrite, append the following lines in your .htaccess file. See also [[http:// | ||
| + | < | ||
| + | RewriteCond %{QUERY_STRING} do=login | ||
| + | RewriteCond %{QUERY_STRING} (id=.*) | ||
| + | RewriteRule .* / | ||
| + | |||
| + | RewriteCond %{QUERY_STRING} do=logout | ||
| + | RewriteRule .* / | ||
| + | |||
| + | </ | ||
| ===== Mantis ===== | ===== Mantis ===== | ||
| + | In mantis there are changes in two file necessary. | ||
| + | ==== code/ | ||
| + | <code php> | ||
| + | <?php | ||
| + | # Mantis - a php based bugtracking system | ||
| + | # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org | ||
| + | # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net | ||
| + | # Mantis 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. | ||
| + | # | ||
| + | # Mantis 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. | ||
| + | # GNU General Public License for more details. | ||
| + | # | ||
| + | # You should have received a copy of the GNU General Public License | ||
| + | # along with Mantis. | ||
| + | |||
| + | # -------------------------------------------------------- | ||
| + | # $Id: html_api.php, | ||
| + | # -------------------------------------------------------- | ||
| + | |||
| + | ########################################################################### | ||
| + | # 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_meta_redirect) | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # (print_project_menu_bar) | ||
| + | # | ||
| + | # | ||
| + | # ...Page content here... | ||
| + | # | ||
| + | # | ||
| + | # (print_menu) | ||
| + | # | ||
| + | # | ||
| + | # html_footer | ||
| + | # html_body_end | ||
| + | # html_end | ||
| + | # | ||
| + | ########################################################################### | ||
| + | |||
| + | $t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR; | ||
| + | |||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | require_once( $t_core_dir . ' | ||
| + | |||
| + | $g_rss_feed_url = null; | ||
| + | |||
| + | # flag for error handler to skip header menus | ||
| + | $g_error_send_page_header = true; | ||
| + | |||
| + | # Projax library disabled by default. | ||
| + | # is included. | ||
| + | $g_enable_projax = false; | ||
| + | |||
| + | # -------------------- | ||
| + | # Sets the url for the rss link associated with the current page. | ||
| + | # null: means no feed (default). | ||
| + | function html_set_rss_link( $p_rss_feed_url ) | ||
| + | { | ||
| + | if ( OFF != config_get( ' | ||
| + | global $g_rss_feed_url; | ||
| + | $g_rss_feed_url = $p_rss_feed_url; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Prints the link that allows auto-detection of the associated feed. | ||
| + | function html_rss_link() | ||
| + | { | ||
| + | global $g_rss_feed_url; | ||
| + | |||
| + | if ( $g_rss_feed_url !== null ) { | ||
| + | echo "< | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the part of the page that comes before meta redirect tags should | ||
| + | # be inserted | ||
| + | function html_page_top1( $p_page_title = null ) { | ||
| + | global $g_path; | ||
| + | html_begin(); | ||
| + | html_head_begin(); | ||
| + | html_css(); | ||
| + | html_content_type(); | ||
| + | include( config_get( ' | ||
| + | html_rss_link(); | ||
| + | echo '< | ||
| + | html_title( $p_page_title ); | ||
| + | html_head_javascript(); | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the part of the page that comes after meta tags, but before the | ||
| + | # actual page content | ||
| + | function html_page_top2() { | ||
| + | html_page_top2a(); | ||
| + | |||
| + | if ( !db_is_connected() ) { | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | if ( auth_is_user_authenticated() ) { | ||
| + | html_login_info(); | ||
| + | |||
| + | if( ON == config_get( ' | ||
| + | print_project_menu_bar(); | ||
| + | PRINT '< | ||
| + | } | ||
| + | } | ||
| + | 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. | ||
| + | # directly during the login process and other times when the user may | ||
| + | # not be authenticated | ||
| + | function html_page_top2a() { | ||
| + | global $g_error_send_page_header; | ||
| + | |||
| + | html_head_end(); | ||
| + | html_body_begin(); | ||
| + | $g_error_send_page_header = false; | ||
| + | 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 ( !db_is_connected() ) { | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | if ( config_get( ' | ||
| + | PRINT '< | ||
| + | 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 ( null === $p_file ) { | ||
| + | $p_file = basename( $_SERVER[' | ||
| + | } | ||
| + | |||
| + | html_bottom_banner(); | ||
| + | html_footer( $p_file ); | ||
| + | html_body_end(); | ||
| + | html_end(); | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (1) Print the document type and the opening < | ||
| + | function html_begin() { | ||
| + | # @@@ NOTE make this a configurable global. | ||
| + | #echo '< | ||
| + | #echo '< | ||
| + | |||
| + | echo '< | ||
| + | echo '< | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (2) Begin the < | ||
| + | function html_head_begin() { | ||
| + | echo '< | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (3) Print the content-type | ||
| + | function html_content_type() { | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (4) Print the window title | ||
| + | function html_title( $p_page_title = null ) { | ||
| + | $t_title = config_get( ' | ||
| + | echo " | ||
| + | if ( 0 == strlen( $p_page_title ) ) { | ||
| + | echo string_display( $t_title ); | ||
| + | } else { | ||
| + | if ( 0 == strlen( $t_title ) ) { | ||
| + | echo $p_page_title; | ||
| + | } else { | ||
| + | echo $p_page_title . ' - ' . string_display( $t_title ); | ||
| + | } | ||
| + | } | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (5) Print the link to include the css file | ||
| + | function html_css() { | ||
| + | $t_css_url = config_get( ' | ||
| + | echo " | ||
| + | |||
| + | # fix for NS 4.x css | ||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (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 ' | ||
| + | # option is turned on, return false and don't redirect. | ||
| + | function html_meta_redirect( $p_url, $p_time = null, $p_sanitize = false ) { | ||
| + | if ( ON == config_get( ' | ||
| + | return false; | ||
| + | } | ||
| + | |||
| + | if ( null === $p_time ) { | ||
| + | $p_time = current_user_get_pref( ' | ||
| + | } | ||
| + | |||
| + | if ( $p_sanitize ) { | ||
| + | $t_url = string_sanitize_url( $p_url ); | ||
| + | } else { | ||
| + | $t_url = $p_url; | ||
| + | } | ||
| + | |||
| + | echo " | ||
| + | |||
| + | return true; | ||
| + | } | ||
| + | |||
| + | # --------------------- | ||
| + | # (6a) Javascript... | ||
| + | function html_head_javascript() { | ||
| + | global $g_path; | ||
| + | if ( ON == config_get( ' | ||
| + | echo " | ||
| + | echo '</ | ||
| + | echo " | ||
| + | echo '</ | ||
| + | |||
| + | global $g_enable_projax; | ||
| + | |||
| + | if ( $g_enable_projax ) { | ||
| + | echo '< | ||
| + | echo '< | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (7) End the < | ||
| + | function html_head_end() { | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (8) Begin the < | ||
| + | function html_body_begin() { | ||
| + | echo '< | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (9) Print the title displayed at the top of the page | ||
| + | function html_header() { | ||
| + | $t_title = config_get( ' | ||
| + | echo '< | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (10) Print a user-defined banner at the top of the page if there is one. | ||
| + | function html_top_banner() { | ||
| + | global $g_path; | ||
| + | $t_page = config_get( ' | ||
| + | |||
| + | if ( !is_blank( $t_page ) && file_exists( $t_page ) && !is_dir( $t_page ) ) { | ||
| + | include( $t_page ); | ||
| + | } else { | ||
| + | if ( is_page_name( ' | ||
| + | $t_align = ' | ||
| + | } else { | ||
| + | $t_align = ' | ||
| + | } | ||
| + | |||
| + | echo '< | ||
| + | echo '<a href=" | ||
| + | echo '</ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (11) Print the user's account information | ||
| + | # Also print the select box where users can switch projects | ||
| + | function html_login_info() { | ||
| + | global $g_path; | ||
| + | $t_username = current_user_get_field( ' | ||
| + | $t_access_level = get_enum_element( ' | ||
| + | $t_now = date( config_get( ' | ||
| + | $t_realname = current_user_get_field( ' | ||
| + | |||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | if ( current_user_is_anonymous() ) { | ||
| + | $t_return_page = $_SERVER[' | ||
| + | if ( isset( $_SERVER[' | ||
| + | $t_return_page .= '?' | ||
| + | } | ||
| + | |||
| + | $t_return_page = string_url( | ||
| + | PRINT lang_get( ' | ||
| + | if ( config_get( ' | ||
| + | PRINT ' | <a href="' | ||
| + | } | ||
| + | } else { | ||
| + | echo lang_get( ' | ||
| + | echo is_blank( $t_realname ) ? " | ||
| + | echo "</ | ||
| + | } | ||
| + | PRINT '</ | ||
| + | PRINT '< | ||
| + | PRINT "< | ||
| + | PRINT '</ | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | |||
| + | echo lang_get( ' | ||
| + | if ( ON == config_get( ' | ||
| + | print_extended_project_browser( helper_get_current_project_trace() ); | ||
| + | } else { | ||
| + | if ( ON == config_get( ' | ||
| + | PRINT '< | ||
| + | } else { | ||
| + | PRINT '< | ||
| + | } | ||
| + | print_project_option_list( join( ';', | ||
| + | PRINT '</ | ||
| + | } | ||
| + | PRINT '< | ||
| + | |||
| + | if ( OFF != config_get( ' | ||
| + | # Link to RSS issues feed for the selected project, including authentication details. | ||
| + | PRINT '<a href="' | ||
| + | PRINT '< | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (12) Print a user-defined banner at the bottom of the page if there is one. | ||
| + | function html_bottom_banner() { | ||
| + | $t_page = config_get( ' | ||
| + | |||
| + | 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, | ||
| + | |||
| + | # 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 | ||
| + | # 3) don't do this on the password verification or update page, as it causes the | ||
| + | # verification comparison to fail | ||
| + | if ( auth_is_user_authenticated() && !( is_page_name( ' | ||
| + | $t_user_id = auth_get_current_user_id(); | ||
| + | user_update_last_visit( $t_user_id ); | ||
| + | } | ||
| + | |||
| + | echo " | ||
| + | echo " | ||
| + | |||
| + | echo '< | ||
| + | if ( ON == config_get( ' | ||
| + | echo " | ||
| + | ' | ||
| + | } | ||
| + | echo " | ||
| + | |||
| + | # only display webmaster email is current user is not the anonymous user | ||
| + | if ( ! is_page_name( ' | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | # print timings | ||
| + | if ( ON == config_get( ' | ||
| + | $g_timer-> | ||
| + | } | ||
| + | |||
| + | # print db queries that were run | ||
| + | if ( helper_show_queries() ) { | ||
| + | $t_count = count( $g_queries_array ); | ||
| + | echo " | ||
| + | $t_unique_queries = 0; | ||
| + | $t_shown_queries = array(); | ||
| + | for ( $i = 0; $i < $t_count; $i++ ) { | ||
| + | if ( ! in_array( $g_queries_array[$i][0], | ||
| + | $t_unique_queries++; | ||
| + | $g_queries_array[$i][3] = false; | ||
| + | array_push( $t_shown_queries, | ||
| + | } else { | ||
| + | $g_queries_array[$i][3] = true; | ||
| + | } | ||
| + | } | ||
| + | echo " | ||
| + | if ( ON == config_get( ' | ||
| + | echo " | ||
| + | $t_total = 0; | ||
| + | for ( $i = 0; $i < $t_count; $i++ ) { | ||
| + | $t_time = $g_queries_array[$i][1]; | ||
| + | $t_caller = $g_queries_array[$i][2]; | ||
| + | $t_total += $t_time; | ||
| + | $t_style_tag = ''; | ||
| + | if ( true == $g_queries_array[$i][3] ) { | ||
| + | $t_style_tag = ' style=" | ||
| + | } | ||
| + | echo " | ||
| + | echo '< | ||
| + | echo '< | ||
| + | } | ||
| + | |||
| + | # @@@ Note sure if we should localize them given that they are debug info. Will add if requested by users. | ||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | } | ||
| + | } | ||
| + | |||
| + | echo '</ | ||
| + | echo '<a href=" | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (14) End the < | ||
| + | function html_body_end() { | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # (15) Print the closing < | ||
| + | function html_end() { | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | |||
| + | ########################################################################### | ||
| + | # HTML Menu API | ||
| + | ########################################################################### | ||
| + | |||
| + | function prepare_custom_menu_options( $p_config ) { | ||
| + | $t_custom_menu_options = config_get( $p_config ); | ||
| + | $t_options = array(); | ||
| + | |||
| + | foreach( $t_custom_menu_options as $t_custom_option ) { | ||
| + | $t_access_level = $t_custom_option[1]; | ||
| + | if ( access_has_project_level( $t_access_level ) ) { | ||
| + | $t_caption = lang_get_defaulted( $t_custom_option[0] ); | ||
| + | $t_link = $t_custom_option[2]; | ||
| + | $t_options[] = "<a href=\" | ||
| + | } | ||
| + | } | ||
| + | |||
| + | return $t_options; | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the main menu | ||
| + | function print_menu() { | ||
| + | |||
| + | global $g_path; | ||
| + | |||
| + | if ( auth_is_user_authenticated() ) { | ||
| + | $t_protected = current_user_get_field( ' | ||
| + | $t_current_project = helper_get_current_project(); | ||
| + | |||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | $t_menu_options = array(); | ||
| + | |||
| + | # Main Page | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | |||
| + | # My View | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | |||
| + | # View Bugs | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | |||
| + | # Report Bugs | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | $t_menu_options[] = string_get_bug_report_link(); | ||
| + | } | ||
| + | |||
| + | # Changelog Page | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | |||
| + | # Roadmap Page | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | |||
| + | # Summary Page | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | |||
| + | # Project Documentation Page | ||
| + | if( ON == config_get( ' | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | |||
| + | # Project Wiki | ||
| + | if ( wiki_is_enabled() ) { | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | |||
| + | # Manage Users (admins) or Manage Project (managers) or Manage Custom Fields | ||
| + | $t_show_access = min( config_get( ' | ||
| + | if ( access_has_global_level( $t_show_access) || access_has_any_project( $t_show_access ) ) { | ||
| + | $t_current_project = helper_get_current_project(); | ||
| + | if ( access_has_global_level( config_get( ' | ||
| + | $t_link = '' | ||
| + | } else { | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | && | ||
| + | $t_link = '' | ||
| + | } else { | ||
| + | $t_link = '' | ||
| + | } | ||
| + | } | ||
| + | $t_menu_options[] = "<a href=\" | ||
| + | } | ||
| + | |||
| + | # News Page | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | # Admin can edit news for All Projects (site-wide) | ||
| + | if ( ( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) { | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } else { | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # Account Page (only show accounts that are NOT protected) | ||
| + | if ( OFF == $t_protected ) { | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | |||
| + | # Add custom options | ||
| + | $t_custom_options = prepare_custom_menu_options( ' | ||
| + | $t_menu_options = array_merge( $t_menu_options, | ||
| + | if ( config_get(' | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | |||
| + | # Logout (no if anonymously logged in) | ||
| + | if ( !current_user_is_anonymous() ) { | ||
| + | $t_menu_options[] = '<a href="' | ||
| + | } | ||
| + | PRINT implode( $t_menu_options, | ||
| + | PRINT '</ | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | |||
| + | if ( ON == config_get( ' | ||
| + | $t_bug_label = lang_get( ' | ||
| + | PRINT "< | ||
| + | } else { | ||
| + | PRINT "< | ||
| + | } | ||
| + | |||
| + | PRINT '< | ||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the menu bar with a list of projects to which the user has access | ||
| + | function print_project_menu_bar() { | ||
| + | global $g_path; | ||
| + | $t_project_ids = current_user_get_accessible_projects(); | ||
| + | |||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | PRINT '<a href="' | ||
| + | |||
| + | foreach ( $t_project_ids as $t_id ) { | ||
| + | PRINT " | <a href=\"" | ||
| + | print_subproject_menu_bar( $t_id, $t_id . ';' | ||
| + | } | ||
| + | |||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the menu bar with a list of projects to which the user has access | ||
| + | function print_subproject_menu_bar( $p_project_id, | ||
| + | global $g_path; | ||
| + | $t_subprojects = current_user_get_accessible_subprojects( $p_project_id ); | ||
| + | $t_char = ':'; | ||
| + | foreach ( $t_subprojects as $t_subproject ) { | ||
| + | PRINT " | ||
| + | print_subproject_menu_bar( $t_subproject, | ||
| + | $t_char = ','; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the menu for the graph summary section | ||
| + | function print_menu_graph() { | ||
| + | global $g_path; | ||
| + | if ( config_get( ' | ||
| + | $t_icon_path = config_get( ' | ||
| + | |||
| + | PRINT '< | ||
| + | PRINT '<a href="' | ||
| + | PRINT '<a href="' | ||
| + | PRINT '<a href="' | ||
| + | PRINT '<a href="' | ||
| + | PRINT '<a href="' | ||
| + | PRINT '<a href="' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # 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 = '' | ||
| + | global $g_path; | ||
| + | $t_manage_user_page = '' | ||
| + | $t_manage_project_menu_page = '' | ||
| + | $t_manage_custom_field_page = '' | ||
| + | $t_manage_config_page = '' | ||
| + | $t_manage_prof_menu_page | ||
| + | # $t_documentation_page = '' | ||
| + | |||
| + | 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_manage_config_page: | ||
| + | $t_manage_config_page = ''; | ||
| + | break; | ||
| + | case $t_manage_prof_menu_page: | ||
| + | $t_manage_prof_menu_page = ''; | ||
| + | break; | ||
| + | # case $t_documentation_page: | ||
| + | # | ||
| + | # break; | ||
| + | } | ||
| + | |||
| + | PRINT '< | ||
| + | if ( access_has_global_level( config_get( ' | ||
| + | print_bracket_link( $t_manage_user_page, | ||
| + | } | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | print_bracket_link( $t_manage_project_menu_page, | ||
| + | } | ||
| + | if ( access_has_global_level( config_get( ' | ||
| + | print_bracket_link( $t_manage_custom_field_page, | ||
| + | } | ||
| + | if ( access_has_global_level( config_get( ' | ||
| + | print_bracket_link( $t_manage_prof_menu_page, | ||
| + | } | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | print_bracket_link( $t_manage_config_page, | ||
| + | } | ||
| + | # print_bracket_link( $t_documentation_page, | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the menu for the manage configuration section | ||
| + | # $p_page specifies the current page name so it's link can be disabled | ||
| + | function print_manage_config_menu( $p_page = '' | ||
| + | global $g_path; | ||
| + | $t_configuration_report = '' | ||
| + | $t_permissions_summary_report = '' | ||
| + | $t_manage_work_threshold | ||
| + | $t_manage_email = '' | ||
| + | $t_manage_workflow = '' | ||
| + | |||
| + | switch ( $p_page ) { | ||
| + | case $t_configuration_report: | ||
| + | $t_configuration_report = ''; | ||
| + | break; | ||
| + | case $t_permissions_summary_report: | ||
| + | $t_permissions_summary_report = ''; | ||
| + | break; | ||
| + | case $t_manage_work_threshold: | ||
| + | $t_manage_work_threshold = ''; | ||
| + | break; | ||
| + | case $t_manage_email: | ||
| + | $t_manage_email = ''; | ||
| + | break; | ||
| + | case $t_manage_workflow: | ||
| + | $t_manage_workflow = ''; | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | PRINT '< | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | print_bracket_link( $t_configuration_report, | ||
| + | print_bracket_link( $t_permissions_summary_report, | ||
| + | print_bracket_link( $t_manage_work_threshold, | ||
| + | print_bracket_link( $t_manage_workflow, | ||
| + | print_bracket_link( $t_manage_email, | ||
| + | } | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # 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='' | ||
| + | global $g_path; | ||
| + | $t_account_page = '' | ||
| + | $t_account_prefs_page = '' | ||
| + | $t_account_profile_menu_page = '' | ||
| + | $t_account_sponsor_page = '' | ||
| + | |||
| + | switch ( $p_page ) { | ||
| + | case $t_account_page : | ||
| + | case $t_account_prefs_page : | ||
| + | case $t_account_profile_menu_page : | ||
| + | case $t_account_sponsor_page : | ||
| + | } | ||
| + | |||
| + | print_bracket_link( $t_account_page, | ||
| + | print_bracket_link( $t_account_prefs_page, | ||
| + | if ( access_has_project_level( config_get( ' | ||
| + | print_bracket_link( $t_account_profile_menu_page, | ||
| + | } | ||
| + | if ( ( config_get( ' | ||
| + | ( access_has_project_level( config_get( ' | ||
| + | !current_user_is_anonymous() ) { | ||
| + | print_bracket_link( $t_account_sponsor_page, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # 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='' | ||
| + | global $g_path; | ||
| + | $t_documentation_html = config_get( ' | ||
| + | $t_proj_doc_page = '' | ||
| + | $t_proj_doc_add_page = '' | ||
| + | |||
| + | switch ( $p_page ) { | ||
| + | case $t_documentation_html : | ||
| + | case $t_proj_doc_page : | ||
| + | case $t_proj_doc_add_page : | ||
| + | } | ||
| + | |||
| + | print_bracket_link( $t_documentation_html, | ||
| + | print_bracket_link( $t_proj_doc_page, | ||
| + | if ( file_allow_project_upload() ) { | ||
| + | print_bracket_link( $t_proj_doc_add_page, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # 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='' | ||
| + | global $g_path; | ||
| + | PRINT '< | ||
| + | print_bracket_link( '' | ||
| + | |||
| + | if ( config_get( ' | ||
| + | $t_summary_page = '' | ||
| + | $t_summary_jpgraph_page = '' | ||
| + | |||
| + | switch ( $p_page ) { | ||
| + | case $t_summary_page : | ||
| + | case $t_summary_jpgraph_page: | ||
| + | } | ||
| + | |||
| + | print_bracket_link( $t_summary_page, | ||
| + | print_bracket_link( $t_summary_jpgraph_page, | ||
| + | } | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | |||
| + | # | ||
| + | # Candidates for moving to print_api | ||
| + | # | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the color legend for the status colors | ||
| + | function html_status_legend() { | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | PRINT '< | ||
| + | |||
| + | $t_arr = explode_enum_string( config_get( ' | ||
| + | $enum_count = count( $t_arr ); | ||
| + | $width = (int)(100 / $enum_count); | ||
| + | for ( $i=0; $i < $enum_count; | ||
| + | $t_s = explode_enum_arr( $t_arr[$i] ); | ||
| + | $t_val = get_enum_element( ' | ||
| + | $t_color = get_status_color( $t_s[0] ); | ||
| + | |||
| + | PRINT "< | ||
| + | } | ||
| + | |||
| + | PRINT '</ | ||
| + | PRINT '</ | ||
| + | if ( ON == config_get( ' | ||
| + | html_status_percentage_legend(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print the legend for the status percentage | ||
| + | function html_status_percentage_legend() { | ||
| + | |||
| + | $t_mantis_bug_table = config_get( ' | ||
| + | $t_project_id = helper_get_current_project(); | ||
| + | $t_user_id = auth_get_current_user_id(); | ||
| + | |||
| + | #checking if it's a per project statistic or all projects | ||
| + | $t_specific_where = helper_project_specific_where( $t_project_id, | ||
| + | |||
| + | $query = " | ||
| + | FROM $t_mantis_bug_table | ||
| + | WHERE $t_specific_where | ||
| + | GROUP BY status"; | ||
| + | $result = db_query( $query ); | ||
| + | |||
| + | $t_bug_count = 0; | ||
| + | $t_status_count_array = array(); | ||
| + | |||
| + | while ( $row = db_fetch_array( $result ) ) { | ||
| + | |||
| + | $t_status_count_array[ $row[' | ||
| + | $t_bug_count += $row[' | ||
| + | } | ||
| + | |||
| + | $t_arr = explode_enum_string( config_get( ' | ||
| + | $enum_count = count( $t_arr ); | ||
| + | |||
| + | if ( $t_bug_count > 0 ) { | ||
| + | echo '< | ||
| + | echo '< | ||
| + | echo '< | ||
| + | echo '< | ||
| + | echo '</ | ||
| + | echo '< | ||
| + | |||
| + | for ( $i=0; $i < $enum_count; | ||
| + | $t_s = explode_enum_arr( $t_arr[$i] ); | ||
| + | $t_color = get_status_color( $t_s[0] ); | ||
| + | $t_status = $t_s[0]; | ||
| + | |||
| + | if ( !isset( $t_status_count_array[ $t_status ] ) ) { | ||
| + | $t_status_count_array[ $t_status ] = 0; | ||
| + | } | ||
| + | |||
| + | $width = round( ( $t_status_count_array[ $t_status ] / $t_bug_count ) * 100 ); | ||
| + | |||
| + | if ($width > 0) { | ||
| + | echo "< | ||
| + | } | ||
| + | } | ||
| + | |||
| + | echo '</ | ||
| + | echo '</ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print an html button inside a form | ||
| + | function html_button ( $p_action, $p_button_text, | ||
| + | $p_action = urlencode( $p_action ); | ||
| + | $p_button_text = string_attribute( $p_button_text ); | ||
| + | if ( null === $p_fields ) { | ||
| + | $p_fields = array(); | ||
| + | } | ||
| + | |||
| + | if ( strtolower( $p_method ) == ' | ||
| + | $t_method = ' | ||
| + | } else { | ||
| + | $t_method = ' | ||
| + | } | ||
| + | |||
| + | PRINT "< | ||
| + | |||
| + | foreach ( $p_fields as $key => $val ) { | ||
| + | $key = string_attribute( $key ); | ||
| + | $val = string_attribute( $val ); | ||
| + | |||
| + | PRINT " | ||
| + | } | ||
| + | |||
| + | PRINT " | ||
| + | PRINT "</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to update the given bug | ||
| + | function html_button_bug_update( $p_bug_id ) { | ||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | html_button( string_get_bug_update_page(), | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print Change Status to: button | ||
| + | # This code is similar to print_status_option_list except | ||
| + | # there is no masking, except for the current state | ||
| + | function html_button_bug_change_status( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | $t_bug_project_id = bug_get_field( $p_bug_id, ' | ||
| + | $t_bug_current_state = bug_get_field( $p_bug_id, ' | ||
| + | $t_current_access = access_get_project_level( $t_bug_project_id ); | ||
| + | |||
| + | $t_enum_list = get_status_option_list( $t_current_access, | ||
| + | ( bug_get_field( $p_bug_id, ' | ||
| + | |||
| + | if ( count( $t_enum_list ) > 0 ) { | ||
| + | # resort the list into ascending order after noting the key from the first element (the default) | ||
| + | $t_default_arr = each( $t_enum_list ); | ||
| + | $t_default = $t_default_arr[' | ||
| + | ksort( $t_enum_list ); | ||
| + | reset( $t_enum_list ); | ||
| + | |||
| + | echo "< | ||
| + | |||
| + | $t_button_text = lang_get( ' | ||
| + | echo "< | ||
| + | |||
| + | echo " <select name=\" | ||
| + | foreach ( $t_enum_list as $key => $val ) { | ||
| + | echo "< | ||
| + | check_selected( $key, $t_default ); | ||
| + | echo "> | ||
| + | } | ||
| + | echo '</ | ||
| + | |||
| + | $t_bug_id = string_attribute( $p_bug_id ); | ||
| + | echo "< | ||
| + | |||
| + | echo "</ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print Assign To: combo box of possible handlers | ||
| + | function html_button_bug_assign_to( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | # make sure status is allowed of assign would cause auto-set-status | ||
| + | $t_status = bug_get_field( $p_bug_id, ' | ||
| + | |||
| + | if ( ON == config_get( ' | ||
| + | !bug_check_workflow( $t_status, config_get( ' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | # make sure current user has access to modify bugs. | ||
| + | if ( !access_has_bug_level( config_get( ' | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | $t_reporter_id = bug_get_field( $p_bug_id, ' | ||
| + | $t_handler_id = bug_get_field( $p_bug_id, ' | ||
| + | $t_current_user_id = auth_get_current_user_id(); | ||
| + | $t_new_status = ( ON == config_get( ' | ||
| + | |||
| + | $t_options = array(); | ||
| + | $t_default_assign_to = null; | ||
| + | |||
| + | if ( ( $t_handler_id != $t_current_user_id ) && | ||
| + | ( access_has_bug_level( config_get( ' | ||
| + | $t_options[] = array( $t_current_user_id, | ||
| + | $t_default_assign_to = $t_current_user_id; | ||
| + | } | ||
| + | |||
| + | if ( ( $t_handler_id != $t_reporter_id ) && user_exists( $t_reporter_id ) && | ||
| + | ( access_has_bug_level( config_get( ' | ||
| + | $t_options[] = array( $t_reporter_id, | ||
| + | |||
| + | if ( $t_default_assign_to === null ) { | ||
| + | $t_default_assign_to = $t_reporter_id; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | PRINT "< | ||
| + | |||
| + | $t_button_text = lang_get( ' | ||
| + | PRINT "< | ||
| + | |||
| + | PRINT " <select name=\" | ||
| + | |||
| + | $t_already_selected = false; | ||
| + | |||
| + | foreach ( $t_options as $t_entry ) { | ||
| + | $t_id = string_attribute( $t_entry[0] ); | ||
| + | $t_caption = string_attribute( $t_entry[1] ); | ||
| + | |||
| + | # if current user and reporter can't be selected, then select the first | ||
| + | # user in the list. | ||
| + | if ( $t_default_assign_to === null ) { | ||
| + | $t_default_assign_to = $t_id; | ||
| + | } | ||
| + | |||
| + | PRINT "< | ||
| + | |||
| + | if ( ( $t_id == $t_default_assign_to ) && !$t_already_selected ) { | ||
| + | check_selected( $t_id, $t_default_assign_to ); | ||
| + | $t_already_selected = true; | ||
| + | } | ||
| + | |||
| + | PRINT "> | ||
| + | } | ||
| + | |||
| + | # allow un-assigning if already assigned. | ||
| + | if ( $t_handler_id != 0 ) { | ||
| + | PRINT "< | ||
| + | } | ||
| + | |||
| + | $t_project_id = bug_get_field( $p_bug_id, ' | ||
| + | # 0 means currently selected | ||
| + | print_assign_to_option_list( 0, $t_project_id ); | ||
| + | PRINT "</ | ||
| + | |||
| + | $t_bug_id = string_attribute( $p_bug_id ); | ||
| + | PRINT "< | ||
| + | |||
| + | PRINT "</ | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to move the given bug to a different project | ||
| + | function html_button_bug_move( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | $t_status = bug_get_field( $p_bug_id, ' | ||
| + | |||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | html_button( '' | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to move the given bug to a different project | ||
| + | function html_button_bug_create_child( $p_bug_id ) { | ||
| + | if ( ON == config_get( ' | ||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | html_button( string_get_bug_report_url(), | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to reopen the given bug | ||
| + | function html_button_bug_reopen( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | $t_status = bug_get_field( $p_bug_id, ' | ||
| + | $t_reopen_status = config_get( ' | ||
| + | $t_project = bug_get_field( $p_bug_id, ' | ||
| + | |||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | ( ( bug_get_field( $p_bug_id, ' | ||
| + | ( ON == config_get( ' | ||
| + | ) | ||
| + | ) { | ||
| + | html_button( '' | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | ' | ||
| + | ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to monitor the given bug | ||
| + | function html_button_bug_monitor( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | html_button( '' | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # 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 ) { | ||
| + | global $g_path; | ||
| + | html_button( '' | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to delete the given bug | ||
| + | function html_button_bug_delete( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | html_button( '' | ||
| + | lang_get( ' | ||
| + | array( ' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print a button to create a wiki page | ||
| + | function html_button_wiki( $p_bug_id ) { | ||
| + | global $g_path; | ||
| + | if ( ON == config_get( ' | ||
| + | if ( access_has_bug_level( config_get( ' | ||
| + | html_button( '' | ||
| + | lang_get_defaulted( ' | ||
| + | array( ' | ||
| + | ' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # -------------------- | ||
| + | # Print all buttons for view bug pages | ||
| + | function html_buttons_view_bug_page( $p_bug_id ) { | ||
| + | $t_resolved = config_get( ' | ||
| + | $t_status = bug_get_field( $p_bug_id, ' | ||
| + | $t_readonly = bug_is_readonly( $p_bug_id ); | ||
| + | |||
| + | PRINT '< | ||
| + | if ( !$t_readonly ) { | ||
| + | # UPDATE button | ||
| + | echo '< | ||
| + | html_button_bug_update( $p_bug_id ); | ||
| + | echo '</ | ||
| + | |||
| + | # ASSIGN button | ||
| + | echo '< | ||
| + | html_button_bug_assign_to( $p_bug_id ); | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | # Change State button | ||
| + | echo '< | ||
| + | html_button_bug_change_status( $p_bug_id ); | ||
| + | echo '</ | ||
| + | |||
| + | # MONITOR/ | ||
| + | echo '< | ||
| + | if ( !current_user_is_anonymous() ) { | ||
| + | if ( user_is_monitoring_bug( auth_get_current_user_id(), | ||
| + | html_button_bug_unmonitor( $p_bug_id ); | ||
| + | } else { | ||
| + | html_button_bug_monitor( $p_bug_id ); | ||
| + | } | ||
| + | } | ||
| + | echo '</ | ||
| + | |||
| + | if ( !$t_readonly ) { | ||
| + | # CREATE CHILD button | ||
| + | echo '< | ||
| + | html_button_bug_create_child( $p_bug_id ); | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | if ( $t_resolved <= $t_status ) { # resolved is not the same as readonly | ||
| + | PRINT '< | ||
| + | # REOPEN button | ||
| + | html_button_bug_reopen( $p_bug_id ); | ||
| + | PRINT '</ | ||
| + | } | ||
| + | |||
| + | if ( !$t_readonly ) { | ||
| + | # MOVE button | ||
| + | echo '< | ||
| + | html_button_bug_move( $p_bug_id ); | ||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | # DELETE button | ||
| + | echo '< | ||
| + | html_button_bug_delete( $p_bug_id ); | ||
| + | echo '</ | ||
| + | |||
| + | helper_call_custom_function( ' | ||
| + | |||
| + | echo '</ | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Print the Update Tag button | ||
| + | * @param integer Tag ID | ||
| + | */ | ||
| + | function html_button_tag_update( $p_tag_id ) { | ||
| + | global $g_path; | ||
| + | if ( access_has_global_level( config_get( ' | ||
| + | || ( auth_get_current_user_id() == tag_get_field( $p_tag_id, ' | ||
| + | && | ||
| + | { | ||
| + | html_button( '' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Print the Delete Tag button | ||
| + | * @param integer Tag ID | ||
| + | */ | ||
| + | function html_button_tag_delete( $p_tag_id ) { | ||
| + | global $g_path; | ||
| + | if ( access_has_global_level( config_get( ' | ||
| + | html_button( '' | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Print all buttons for the Tag View page | ||
| + | * @param integer Tag ID | ||
| + | */ | ||
| + | function html_buttons_tag_view_page( $p_tag_id ) { | ||
| + | html_button_tag_update( $p_tag_id ); | ||
| + | html_button_tag_delete( $p_tag_id ); | ||
| + | } | ||
| + | ?> | ||
| + | </ | ||
| + | ==== core/ | ||
| + | In this file only two functions are changed, so it is overkill to place the whole file here. Replace the functions with the following | ||
| + | === function string_get_bug_update_link === | ||
| + | <code php> | ||
| + | # -------------------- | ||
| + | # return an href anchor that links to a bug UPDATE page for the given bug | ||
| + | # account for the user preference and site override | ||
| + | function string_get_bug_update_link( $p_bug_id, $p_user_id = null ) { | ||
| + | global $g_path; | ||
| + | $t_summary = string_attribute( bug_get_field( $p_bug_id, ' | ||
| + | return '<a href="' | ||
| + | } | ||
| + | </ | ||
| + | === function string_get_bug_report_link === | ||
| + | <code php> | ||
| + | # -------------------- | ||
| + | # return an href anchor that links to a bug REPORT page for the given bug | ||
| + | # account for the user preference and site override | ||
| + | function string_get_bug_report_link( $p_user_id = null ) { | ||
| + | global $g_path; | ||
| + | return '<a href="' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Configuration ===== | ||
| + | ==== Dokuwiki ==== | ||
| + | |||
| + | Log in as administrator, | ||
| + | :!: You have to config the filepath and URL to your mantis in the syntax plugin | ||
| + | |||
| + | ==== Mantis ==== | ||
| + | |||
| + | Include this in your mantis configuration. Adjust the paths so it match your install. | ||
| + | |||
| + | <code php> | ||
| + | ##################### | ||
| + | # Wiki Integration | ||
| + | ##################### | ||
| + | |||
| + | # Wiki Integration Enabled? | ||
| + | $g_wiki_enable = ON; | ||
| + | |||
| + | # Wiki Engine | ||
| + | $g_wiki_engine = ' | ||
| + | |||
| + | # Wiki namespace to be used as root for all pages relating to this mantis installation. | ||
| + | $g_wiki_root_namespace = ' | ||
| + | |||
| + | # URL under which the wiki engine is hosted. | ||
| + | $g_wiki_engine_url = $t_protocol . '://' | ||
| + | |||
| + | # CSS file | ||
| + | $g_css_include_file = '/ | ||
| + | </ | ||
mantisbt/issue/8253.1194413581.txt.gz · Last modified: 2008/10/29 04:36 (external edit)
