View Issue Details

IDProjectCategoryView StatusLast Update
0008858mantisbtintegrationpublic2008-06-17 02:44
Reportertody Assigned Tovboctor  
PrioritynormalSeveritytweakReproducibilityalways
Status closedResolutionfixed 
Product Version1.1.0rc3 
Fixed in Version1.1.2 
Summary0008858: DokuWiki integration: EMail notification on wiki page changes not working
Description

Using the DokuWiki integration as described here:
http://www.mantisbt.org/wiki/doku.php/mantisbt:issue:7075:integration_with_dokuwiki
does not allow dokuwiki's email notification feature for wiki page changes to be used.

Steps To Reproduce

Just open a wiki page and subscribe for email notification.

Additional Information

The issue is caused by the fact that class "auth_mantis" derives the function "getUserData" from class "auth_basic", instead of implementing an own variant.

Attached to this issue report, there is a suggestion for a patched version of the file "dokuwiki/auth/mantis.class.php", implementing above mentioned function.

Feel free to (re-)use whatever might be suitable.

TagsNo tags attached.
Attached Files
mantis.class.php (2,634 bytes)   
<?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' );

#dbg($GLOBALS);

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;
  }

}
?>
mantis.class.php (2,634 bytes)   
mantis_class_v2.php (2,656 bytes)   
<?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' );

#dbg($GLOBALS);

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;
  }
}
?>
mantis_class_v2.php (2,656 bytes)   

Activities

vboctor

vboctor

2008-02-09 21:31

manager   ~0016995

Updated the DokuWiki integration wiki page to include your patched version.