patch: DokuWiki showuseras = username

Post modules, themes or any other code you want to share with the community.

Moderator: Developers

totallag
Posts: 4
Joined: Mon Mar 04, 2013 7:46 pm

patch: DokuWiki showuseras = username

Postby totallag » Sat Apr 06, 2013 3:49 pm

DokuWiki is unsupported, but this is for anyone who wants to use the community_modules and have noticed that the "Last Modified by" always showed up as the currently logged in user and not the actual editor when using $conf['showuseras'] = 'username';

In DokuWiki's inc/common.php:
You have to add a GO lookup to the editorinfo() function under case 'username'.

Code: Select all

/**
 * Return the users realname or e-mail address for use
 * in page footer and recent changes pages
 *
 * @author Andy Webber <dokuwiki AT andywebber DOT com>
 */
function editorinfo($username) {
    global $conf;
    global $auth;

    switch($conf['showuseras']) {
        case 'username':
+++            return hsc(GO_Base_Model_User::model()->findSingleByAttribute('username', $username)->name);
        case 'email':
        case 'email_link':
            if($auth) $info = $auth->getUserData($username);
            break;
        default:
            return hsc($username);
    }

    if(isset($info) && $info) {
        switch($conf['showuseras']) {
            case 'username':
                return hsc($info['name']);
            case 'email':
                return obfuscate($info['mail']);
            case 'email_link':
                $mail = obfuscate($info['mail']);
                return '<a href="mailto:'.$mail.'">'.$mail.'</a>';
            default:
                return hsc($username);
        }
    } else {
        return hsc($username);
    }
}
rosetta
Group-Office Expert
Group-Office Expert
Posts: 546
Joined: Tue Jul 14, 2009 2:25 pm
Location: Norway
Contact:

Re: patch: DokuWiki showuseras = username

Postby rosetta » Sun Apr 07, 2013 1:25 pm

Thanks a lot, totallag!

We commissioned the development of the DokuWiki module in the first place, and the strange thing is that it used to work fine before.

But recently I have noticed (as you) that it always showed "Last modified by" as the current logged in user. Not only that, but revision history was also broken, with all revisions showed as made by the currently logged in user.

Your fix solves it all.

Thank you!
totallag
Posts: 4
Joined: Mon Mar 04, 2013 7:46 pm

Re: patch: DokuWiki showuseras = username

Postby totallag » Mon Apr 08, 2013 8:36 pm

No problem! Thank YOU for commissioning it! I really love the integration and backing up dokuwiki is a breeze!

Although not critical to functionality, I've also fixed an aesthetic issue where it says "Logged in as $User_ID ($User_ID)" at the top.

Also in inc/common.php just encapsulate with editorinfo():

Code: Select all

        // if some outside auth were used only REMOTE_USER is set
        if(!$info['userinfo']['name']) {
---            $info['userinfo']['name'] = $_SERVER['REMOTE_USER'];
+++            $info['userinfo']['name'] = editorinfo($_SERVER['REMOTE_USER']);
        }
defender
Posts: 3
Joined: Sat May 04, 2013 12:46 pm

Re: patch: DokuWiki showuseras = username

Postby defender » Tue May 07, 2013 4:32 am

Where can I get the DokuWiki Module?
rosetta
Group-Office Expert
Group-Office Expert
Posts: 546
Joined: Tue Jul 14, 2009 2:25 pm
Location: Norway
Contact:

Re: patch: DokuWiki showuseras = username

Postby rosetta » Tue May 07, 2013 6:39 am


Return to “Contributed development”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest