<?php /** * Mantis auth backend * * Uses external Trust mechanism to check against Mantis' * user cookie. * * @author Victor Boctor (http://www.futureware.biz) */ require_once( MANTIS_ROOT . 'core.php' ); class auth_mantis extends auth_basic { /** * Constructor. * * Sets additional capabilities and config strings */ function auth_mantis(){ $this->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; } } ?>
: * @ALL 0 * @VIEWER 1 * @REPORTER 2 * @DEVELOPER 8 * @MANAGER 8 * @ADMINISTRATOR 8
mkdir /var/www/html/dokuwiki/lib/plugins/mantis cd /var/www/html/dokuwiki/lib/plugins/mantis vi syntax.php
<?php /** * Mantis Plugin: Hyperlinks references to Mantis Issues * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Victor Boctor (http://www.futureware.biz) */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * A plug-in that hyper links references to Mantis issues. References * to Mantis issues should use the following format: ~~Mantis:123~~. * * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_mantis extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => '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; } } ?>
$conf['useacl'] = 1; $conf['authtype'] = 'mantis'; $conf['defaultgroup'] = 'VIEWER'; $conf['superuser'] = '@ADMINISTRATOR';
: : ##################### # 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%/';