====== Mantis 與 Dokuwiki 整合作法 ======
===== - dokuwiki 部份 =====
- 先安裝好 dokuwiki,可參考 **[[tech:dokuwiki]]**
- 安裝完成後的 dokuwiki 環境假設網址是 http://192.168.11.250/dokuwiki 實體路徑 /var/www/html/dokuwiki
- 更改 dokuwiki 系統設定檔 /var/www/html/dokuwiki/conf/local.protected.php (如果改 local.php 透過網頁介面更改就會不見)
- 建立 mantis 認證程式碼 /var/www/html/dokuwiki/inc/auth/mantis.class.php
cando['external'] = true;
}
/**
* Authenticates the user using Mantis APIs.
*/
function trustExternal($user,$pass,$sticky=false){
global $USERINFO;
global $conf;
if ( auth_is_user_authenticated() ) {
// okay we're logged in - set the globals
$USERINFO['pass'] = current_user_get_field( 'password' );
$USERINFO['name'] = current_user_get_field( 'username' );
$USERINFO['mail'] = current_user_get_field( 'email' );
$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( 'access_levels_enum_string' ), $t_access_level ) );
$USERINFO['grps'] = array( $t_access_level_string );
$_SERVER['REMOTE_USER'] = $USERINFO['name'];
$_SESSION[$conf['title']]['auth']['user'] = $USERINFO['name'];
$_SESSION[$conf['title']]['auth']['info'] = $USERINFO;
return true;
}
// to be sure
auth_logoff();
return false;
}
/**
* Logout from Mantis
*/
function logOff(){
auth_logout();
}
/**
* Retrieves the user data of the user identified by
* username $user. This is used, e.g., by dokuwiki's
* email notification feature.
*/
function getUserData( $user ) {
$userData = false;
$mantis_uid = user_get_id_by_name( $user );
if ( $mantis_uid ) {
$userData['username'] = user_get_field( $mantis_uid, 'username' );
$userData['mail'] = user_get_field( $mantis_uid, 'email' );
$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 , $mantis_uid );
$t_access_level_string = strtoupper( get_enum_to_string( config_get( 'access_levels_enum_string' ), $t_access_level ) );
$userData['grps'] = array( $t_access_level_string );
}
return $userData;
}
}
?>
- 修改權限檔 /var/www/html/dokuwiki/conf/acl.auth.php
:
* @ALL 0
* @VIEWER 1
* @REPORTER 2
* @DEVELOPER 8
* @MANAGER 8
* @ADMINISTRATOR 8
- 增加 Mantis Syntax Plug-in /var/www/html/dokuwiki/lib/plugins/mantis/syntax.php mkdir /var/www/html/dokuwiki/lib/plugins/mantis
cd /var/www/html/dokuwiki/lib/plugins/mantis
vi syntax.php
'Victor Boctor',
'email' => 'vboctor at users . sourceforge . net',
'date' => '2006-05-18',
'name' => 'Mantis Issues Plugin',
'desc' => 'Support References to Mantis Issues',
'url' => 'http://www.futureware.biz',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition'; # typo is intentional
}
/**
* What about paragraphs?
*/
function getPType(){
return 'normal';
}
/**
* Where to sort in?
*/
function getSort(){
return 156;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern('~~Mantis:[0-9]+~~', $mode, 'plugin_mantis');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
$match = substr( $match, 9, -2 ); // strip "~~Mantis:" from start and "~~" from end
return array( strtolower( $match ) );
}
/**
* Create output
*/
function render($format, &$renderer, $data) {
if ( $format == 'xhtml' ) {
$renderer->externallink( MANTIS_URL . 'view.php?id=' . $data[0], $data[0] );
return true;
}
return false;
}
}
?>
- 透過 dokuwiki 原本設定介面來更動 /var/www/html/dokuwiki/conf/local.php
- Use access control lists -> 打勾(應該已經打勾)
- Authentication backend -> mantis(上面的步驟完成才會出現 mantis 選項)
- Default group -> VIEWER
- Superuser -> @ADMINISTRATOR
- 確認 /var/www/html/dokuwiki/conf/local.php 內應該要出現以下的設定值
$conf['useacl'] = 1;
$conf['authtype'] = 'mantis';
$conf['defaultgroup'] = 'VIEWER';
$conf['superuser'] = '@ADMINISTRATOR';
經過以上的設定,只要在 mantis 內登入, dokuwiki 也會依據 mantis 的身份權限出現在 dokuwiki 系統內
===== - mantis 部份 =====
- Mantis 設定檔啟用 dokuwiki 整合定義 /var/www/html/mantis/config_inc.php
:
:
#####################
# Wiki Integration
#####################
# Wiki Integration Enabled?
$g_wiki_enable = ON;
# Wiki Engine
$g_wiki_engine = 'dokuwiki';
# Wiki namespace to be used as root for all pages relating to this mantis installation.
$g_wiki_root_namespace = 'mantis';
# URL under which the wiki engine is hosted. Must be on the same server.
$g_wiki_engine_url = $t_protocol . '://' . $t_host . '/%wiki_engine%/';
- 其餘相關檔案 /var/www/html/mantis/core/wiki_api.php、wiki_dokuwiki_api.php、html_api.php 以及 /var/www/html/mantis/wiki.php 在 1.1.1 版本已經包含在內,不需要自己額外再建立
經過這樣的設定,Mantis 的檢視 Bug 頁面就會出現 wiki 可以直接連結整合的項目
{{tech:mantis_wiki.png|}}
===== 參考資料 =====
* http://www.mantisbt.org/wiki/doku.php/mantisbt:issue:7075:integration_with_dokuwiki
{{tag>mantis dokuwiki 密技}}