Auth_xphpBB

RSS

Well, it's been a while since I've blogged on here, due to getting snowed under with coding, but I've now got something you might find useful.

If you run a user interactive site, you might well use phpbb as your bulletin board software, and MediaWiki for your user generated documentation. (Well, at least I've run a site or two doing this).

There's already a nice extension here that allows MediaWiki to use phpBB login credentials, so you don't have to keep shuffling two sets of users around, but I thought it would be nice to go one further and use the actual phpBB API. This is the result.

This extension requires PHP5.2, MediaWiki 1.11+ and phpBB3. To get this working, you'll need to do the following:

  1. Because MediaWiki and PHPBB both make prominent use of a class called 'user', and because PHP 5.2 doesn't provide a nice way of using include or require and yanking the whole lot into a separate namespace, you'll have to modify one codebase or the other to avoid conflicing class names. I recommend changing phpBB, and renaming user to phpbbuser. You will need to change the class definition and constructor in includes/session.php and the single instantiation point in common.php.
  2. Download the source here, unpack it and put it in the extensions subdirectory where you've installed MediaWiki.
  3. Add the following code to the bottom of LocalSettings.php:
    
    require_once './extensions/Auth_xphpBB.php';
    
    $wgAuth_Config = array();
    // Name of your PHPBB group
    // users need to be a member
    // of to use the wiki. (i.e. wiki)
    // This can also be set to an array 
    // of group names to use more then 
    // one. (ie. 
    // $wgAuth_Config['WikiGroupName'][] = 'Wiki';
    // $wgAuth_Config['WikiGroupName'][] = 'Wiki2';
    // or
    // $wgAuth_Config['WikiGroupName'] = array('Wiki', 'Wiki2');
    // )
    $wgAuth_Config['WikiGroupName'] = 'Wiki';
     
    // This tells the Plugin to require
    // a user to be a member of the above
    // phpBB group. (ie. wiki) Setting
    // this to false will let any phpBB
    // user edit the wiki.
    
    $wgAuth_Config['UseWikiGroup'] = true;
    // Path from this file to your phpBB install.
    $wgAuth_Config['PathToPHPBB']    = '../phpbb3/';
     
    // Localize the messages
    $wgAuth_Config['LoginMessage']   =
    'You need a phpBB account to login.';
    $wgAuth_Config['NoWikiError']    =
    'You are not a member of the required phpBB group.';
     
    $wgAuth = new Auth_phpBB($wgAuth_Config);
    
    These settings should be familiar if you've used the Auth_phpBB.php extension, though you'll notice there are a lot less options.

    Any thoughts, comments, praise to the skies or flamewars, do let me know!

Monday, 04 May 2009
Categories : Code 

Comments

Johnny (Saturday, 29 August 2009 20:12)
Ritchie,

This seems like a useful extension. I have tried to install it but I seem to be too much of an amateur!

What is a 'class definition and constructor', and where can I find it? I managed to change the instantiation point in common.php, and am able to install the rest of the extension, but I can't work out which bits to change in includes/session.php without getting an error.

Thanks a lot, I hope I'm not asking it to be dumbed-down too much!

Ritchie Swann (Monday, 28 September 2009 22:12)
Sorry for the rather belated response.

The specific lines of code on my (slightly tweaked) phpbb 3.0.5 installation that I changed were includes/session.php lines 1439 and 1461, and common.php line 203 - in all cases renaming 'user' to 'phpbbuser'.

The article assumes you know a bit about OO programming and concepts - for a brief overview, as good as place as any is http://en.wikipedia.org/wiki/Object-oriented_programming. The constructor is easy to spot because in php it's a function with the same name as its class - which is an idea pinched wholesale from C++.

Johnny (Tuesday, 29 September 2009 18:59)
Don't worry - I wouldn't expect you to keep a close eye on every one of your comments threads!

Many thanks for your help, it turns out my includes/session.php file was an out-of-date one, with only a single reference on line 1262. I have fixed this and now have it working fine on my site. I'll have to look into updating includes/session.php ASAP.

Thanks again!

Add a comment
Name (required)
Website
Comment

Archives: