差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
tech:mantisdokuwiki [2008/02/26 15:57] – 建立 jonathan | tech:mantisdokuwiki [2009/03/03 01:00] (目前版本) – jonathan | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== Mantis 與 Dokuwiki 整合作法 ====== | ||
+ | ===== - dokuwiki 部份 ===== | ||
+ | - 先安裝好 dokuwiki,可參考 **[[tech: | ||
+ | - 安裝完成後的 dokuwiki 環境假設網址是 http:// | ||
+ | - 更改 dokuwiki 系統設定檔 / | ||
+ | <?php | ||
+ | /* for intergrating with Mantis */ | ||
+ | define( ' | ||
+ | define( ' | ||
+ | ?> | ||
+ | </ | ||
+ | - 建立 mantis 認證程式碼 / | ||
+ | <?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(); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Retrieves the user data of the user identified by | ||
+ | * username $user. This is used, e.g., by dokuwiki' | ||
+ | * email notification feature. | ||
+ | */ | ||
+ | function getUserData( $user ) { | ||
+ | $userData = false; | ||
+ | $mantis_uid = user_get_id_by_name( $user ); | ||
+ | if ( $mantis_uid ) { | ||
+ | $userData[' | ||
+ | $userData[' | ||
+ | |||
+ | $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( ' | ||
+ | |||
+ | $userData[' | ||
+ | } | ||
+ | |||
+ | return $userData; | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
+ | - 修改權限檔 / | ||
+ | : | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | * | ||
+ | </ | ||
+ | - 增加 Mantis Syntax Plug-in / | ||
+ | cd / | ||
+ | vi syntax.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; | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | </ | ||
+ | - 透過 dokuwiki 原本設定介面來更動 / | ||
+ | - Use access control lists -> 打勾(應該已經打勾) | ||
+ | - Authentication backend -> mantis(上面的步驟完成才會出現 mantis 選項) | ||
+ | - Default group -> VIEWER | ||
+ | - Superuser -> @ADMINISTRATOR | ||
+ | - 確認 / | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | $conf[' | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | 經過以上的設定,只要在 mantis 內登入, dokuwiki 也會依據 mantis 的身份權限出現在 dokuwiki 系統內 | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== - mantis 部份 ===== | ||
+ | - Mantis 設定檔啟用 dokuwiki 整合定義 / | ||
+ | : | ||
+ | : | ||
+ | ##################### | ||
+ | # 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 . '://' | ||
+ | </ | ||
+ | - 其餘相關檔案 / | ||
+ | |||
+ | < | ||
+ | 經過這樣的設定,Mantis 的檢視 Bug 頁面就會出現 wiki 可以直接連結整合的項目 | ||
+ | {{tech: | ||
+ | </ | ||
+ | |||
+ | ===== 參考資料 ===== | ||
+ | * http:// | ||
+ | |||
+ | {{tag> |