mantisbt:7075:integration_with_dokuwiki
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mantisbt:7075:integration_with_dokuwiki [2006/05/17 10:57] – Added source modifications to html_api.php vboctor | mantisbt:7075:integration_with_dokuwiki [2020/05/14 08:33] (current) – Since 2008, this page is just a redirect stub; deleting it after setting up a proper redirection using Redirect plugin dregad | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Integrating DokuWiki with Mantis ====== | ||
| - | ===== Disclaimer ===== | ||
| - | |||
| - | This document describes the steps needed to integrate DokuWiki with Mantis. | ||
| - | |||
| - | |||
| - | ===== Integration Functionality ===== | ||
| - | |||
| - | The integration between Mantis and DokuWiki so far achieves the following: | ||
| - | |||
| - | * Customises DokuWiki to honour Mantis authentication (i.e. single sign-on). | ||
| - | * Customises DokuWiki authorisation based on Mantis access levels (i.e. groups). | ||
| - | * Adds a Wiki link on the issue view simple/ | ||
| - | * Adds a Wiki menu option which maps to the corresponding project Wiki page, or general page in case of "All Projects" | ||
| - | * Provides a way for Wiki pages to link to Mantis issues, e.g. ~~Mantis: | ||
| - | |||
| - | ===== Tips ===== | ||
| - | |||
| - | Following are some tips that are of interest to Mantis / DokuWiki integration: | ||
| - | |||
| - | * To define a template for all Wiki pages within a namespace, create '' | ||
| - | |||
| - | ===== DockuWiki Steps ===== | ||
| - | |||
| - | ==== Installation ==== | ||
| - | |||
| - | Install [[http:// | ||
| - | |||
| - | ==== Configuration ==== | ||
| - | |||
| - | Modify the configuration values in '' | ||
| - | |||
| - | <code php> | ||
| - | # | ||
| - | # Add the following lines: | ||
| - | # | ||
| - | |||
| - | define( ' | ||
| - | define( ' | ||
| - | |||
| - | # | ||
| - | # Modify the following configuration options to match the values below: | ||
| - | # | ||
| - | |||
| - | $conf[' | ||
| - | $conf[' | ||
| - | $conf[' | ||
| - | </ | ||
| - | |||
| - | ==== Authentication (Single Sign-On) ==== | ||
| - | |||
| - | Create '' | ||
| - | |||
| - | <code php> | ||
| - | <?php | ||
| - | /** | ||
| - | * Mantis auth backend | ||
| - | * | ||
| - | * Uses external Trust mechanism to check against Mantis' | ||
| - | * user cookie. | ||
| - | * | ||
| - | * @author | ||
| - | */ | ||
| - | |||
| - | require_once( MANTIS_ROOT . ' | ||
| - | |||
| - | # | ||
| - | |||
| - | 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 | ||
| - | |||
| - | * @VIEWER 1 | ||
| - | * @REPORTER 2 | ||
| - | * @DEVELOPER 8 | ||
| - | * @MANAGER 8 | ||
| - | * @ADMINISTRATOR 8 | ||
| - | * @ALL 0 | ||
| - | </ | ||
| - | |||
| - | ==== Mantis Syntax Plug-in ==== | ||
| - | |||
| - | This plugin is to be placed in '' | ||
| - | |||
| - | <code php> | ||
| - | <?php | ||
| - | /** | ||
| - | * Mantis Plugin: Hyperlinks references to Mantis Issues | ||
| - | | ||
| - | * @license | ||
| - | * @author | ||
| - | */ | ||
| - | |||
| - | |||
| - | if(!defined(' | ||
| - | if(!defined(' | ||
| - | require_once(DOKU_PLUGIN.' | ||
| - | |||
| - | /** | ||
| - | * A plug-in that hyper links references to Mantis issues. | ||
| - | * to Mantis issues should use the following format: ~~Mantis: | ||
| - | * | ||
| - | * All DokuWiki plugins to extend the parser/ | ||
| - | * need to inherit from this class | ||
| - | */ | ||
| - | class syntax_plugin_mantis extends DokuWiki_Syntax_Plugin { | ||
| - | |||
| - | /** | ||
| - | * return some info | ||
| - | */ | ||
| - | function getInfo(){ | ||
| - | return array( | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * What kind of syntax are we? | ||
| - | */ | ||
| - | function getType(){ | ||
| - | return ' | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * What about paragraphs? | ||
| - | */ | ||
| - | function getPType(){ | ||
| - | return ' | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * Where to sort in? | ||
| - | | ||
| - | function getSort(){ | ||
| - | return 156; | ||
| - | } | ||
| - | |||
| - | |||
| - | /** | ||
| - | * Connect pattern to lexer | ||
| - | */ | ||
| - | function connectTo($mode) { | ||
| - | $this-> | ||
| - | } | ||
| - | |||
| - | |||
| - | /** | ||
| - | * Handle the match | ||
| - | */ | ||
| - | function handle($match, | ||
| - | $match = substr( $match, 9, -2 ); // strip " | ||
| - | return array( strtolower( $match ) ); | ||
| - | } | ||
| - | |||
| - | /** | ||
| - | * Create output | ||
| - | */ | ||
| - | function render($format, | ||
| - | if ( $format == ' | ||
| - | $renderer-> | ||
| - | return true; | ||
| - | } | ||
| - | return false; | ||
| - | } | ||
| - | } | ||
| - | ?> | ||
| - | </ | ||
| - | |||
| - | ===== Mantis Steps ===== | ||
| - | |||
| - | ==== Configuration ==== | ||
| - | |||
| - | Add the following configuration items to '' | ||
| - | |||
| - | <code php> | ||
| - | ##################### | ||
| - | # Wiki Integration | ||
| - | ##################### | ||
| - | |||
| - | # Wiki Integration Enabled? | ||
| - | $g_wiki_enable = OFF; | ||
| - | |||
| - | # 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 . '://' | ||
| - | </ | ||
| - | |||
| - | ==== wiki_api.php ==== | ||
| - | |||
| - | Create '' | ||
| - | |||
| - | <code php> | ||
| - | <?php | ||
| - | # Mantis - a php based bugtracking system | ||
| - | # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org | ||
| - | # Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net | ||
| - | # This program is distributed under the terms and conditions of the GPL | ||
| - | # See the README and LICENSE files for details | ||
| - | |||
| - | # -------------------------------------------------------- | ||
| - | # $Id: $ | ||
| - | # -------------------------------------------------------- | ||
| - | |||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . ' | ||
| - | |||
| - | function wiki_call( $p_function, | ||
| - | $t_function = ' | ||
| - | return call_user_func_array( $t_function, | ||
| - | } | ||
| - | |||
| - | function wiki_is_enabled() { | ||
| - | return config_get( ' | ||
| - | } | ||
| - | |||
| - | function wiki_ensure_enabled() { | ||
| - | if ( !wiki_is_enabled() ) { | ||
| - | access_denied(); | ||
| - | } | ||
| - | } | ||
| - | |||
| - | function wiki_get_url_for_issue( $p_issue_id ) { | ||
| - | return wiki_call( ' | ||
| - | } | ||
| - | |||
| - | function wiki_get_url_for_project( $p_project_id ) { | ||
| - | return wiki_call( ' | ||
| - | } | ||
| - | |||
| - | function wiki_string_display_links( $p_string ) { | ||
| - | if ( !wiki_is_enabled() ) { | ||
| - | return $p_string; | ||
| - | } | ||
| - | |||
| - | return wiki_call( ' | ||
| - | } | ||
| - | ?> | ||
| - | </ | ||
| - | |||
| - | ==== wiki_dokuwiki_api.php ==== | ||
| - | |||
| - | Create '' | ||
| - | |||
| - | <code php> | ||
| - | <?php | ||
| - | # Mantis - a php based bugtracking system | ||
| - | # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org | ||
| - | # Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net | ||
| - | # This program is distributed under the terms and conditions of the GPL | ||
| - | # See the README and LICENSE files for details | ||
| - | |||
| - | # -------------------------------------------------------- | ||
| - | # $Id: $ | ||
| - | # -------------------------------------------------------- | ||
| - | |||
| - | function wiki_dokuwiki_get_url_for_page_id( $p_page_id ) { | ||
| - | $t_root_url = config_get_global( ' | ||
| - | |||
| - | $t_root_namespace = config_get( ' | ||
| - | |||
| - | if ( is_blank( $t_root_namespace ) ) { | ||
| - | $t_page_id = $p_page_id; | ||
| - | } else { | ||
| - | $t_page_id = $t_root_namespace . ':' | ||
| - | } | ||
| - | |||
| - | return $t_root_url . ' | ||
| - | } | ||
| - | |||
| - | function wiki_dokuwiki_get_page_id_for_issue( $p_issue_id ) { | ||
| - | $c_issue_id = db_prepare_int( $p_issue_id ); | ||
| - | |||
| - | $t_project_id = bug_get_field( $p_issue_id, | ||
| - | $t_project_name = project_get_name( $t_project_id ); | ||
| - | |||
| - | # create a namespace for the project to contain all project documentation. | ||
| - | # create within it a namespace for issues. | ||
| - | # file to act as the template for issues belonging to this project. | ||
| - | return $t_project_name . ': | ||
| - | } | ||
| - | |||
| - | function wiki_dokuwiki_get_url_for_issue( $p_issue_id ) { | ||
| - | return wiki_dokuwiki_get_url_for_page_id( wiki_dokuwiki_get_page_id_for_issue( $p_issue_id ) ); | ||
| - | } | ||
| - | |||
| - | function wiki_dokuwiki_get_page_id_for_project( $p_project_id ) { | ||
| - | $t_home = ' | ||
| - | if ( $p_project_id == ALL_PROJECTS ) { | ||
| - | return $t_home; | ||
| - | } else { | ||
| - | $t_project_name = project_get_name( $p_project_id ); | ||
| - | return $t_project_name . ':' | ||
| - | } | ||
| - | } | ||
| - | |||
| - | function wiki_dokuwiki_get_url_for_project( $p_project_id ) { | ||
| - | return wiki_dokuwiki_get_url_for_page_id( wiki_dokuwiki_get_page_id_for_project( $p_project_id ) ); | ||
| - | } | ||
| - | |||
| - | function wiki_dokuwiki_string_display_links( $p_string ) { | ||
| - | # | ||
| - | # | ||
| - | |||
| - | $t_wiki_web = config_get_global( ' | ||
| - | |||
| - | preg_match_all( '/ | ||
| - | $p_string, | ||
| - | $t_result = ''; | ||
| - | |||
| - | foreach ( $t_matches as $t_match ) { | ||
| - | $t_result .= $t_match[1]; | ||
| - | |||
| - | if ( isset( $t_match[2] ) ) { | ||
| - | $t_result .= '<a href="' | ||
| - | } | ||
| - | } | ||
| - | |||
| - | return $t_result; | ||
| - | } | ||
| - | ?> | ||
| - | </ | ||
| - | |||
| - | ==== html_api.php ==== | ||
| - | |||
| - | Add the following with the rest of the includes: | ||
| - | <code php> | ||
| - | require_once( $t_core_dir . ' | ||
| - | </ | ||
| - | |||
| - | In the '' | ||
| - | <code php> | ||
| - | # Project Wiki | ||
| - | if ( wiki_is_enabled() ) { | ||
| - | $t_current_project = helper_get_current_project(); | ||
| - | $t_menu_options[] = '<a href=" | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | Add the following function: | ||
| - | <code php> | ||
| - | # -------------------- | ||
| - | # Print a button to create a wiki page | ||
| - | function html_button_wiki( $p_bug_id ) { | ||
| - | if ( ON == config_get( ' | ||
| - | if ( access_has_bug_level( config_get( ' | ||
| - | html_button( ' | ||
| - | lang_get_defaulted( ' | ||
| - | array( ' | ||
| - | ' | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | Update html_button to the following implementation: | ||
| - | |||
| - | <code php> | ||
| - | # -------------------- | ||
| - | # 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 "</ | ||
| - | } | ||
| - | </ | ||
mantisbt/7075/integration_with_dokuwiki.1147877826.txt.gz · Last modified: (external edit)
