Summary: How to use the user authentification of the UBBThreads forums to control access to a PmWiki installation
Version: 2006.01.30
Prerequisites: Requires at least PmWiki version: 2.1beta20; last tested on PmWiki version: 2.1beta20
Maintainer: Anno
Categories: Integration, CMS, Security


How can I use the user authentification of the UBBThreads forums ( http://www.ubbcentral.com/ubbthreads/ ) to control the access to my pmwiki installation?


This recipe enables all registered users on a UBBThreads forum to edit the wiki pages. The wiki pages in the Site group can only be edited by the users with the status administrator.

The recipe currently requires to edit the pmwiki.php file, as it wouldn't work when included only from the config.php file.

Installation instructions

1. create a file called ubbauth.php with this content:

 //UBBThreads authentication 
 $pos = strpos($_SERVER['REQUEST_URI'], "?action=edit");
 if (is_numeric($pos)){
	$userob = new user;
	$user = $userob -> authenticate();
	if (!$user['U_Username']){
		$html = new html;
		$html->not_right("<br />You have to be registered and logged in
			at the Forums
			in order to edit this wiki document.<br /><br />
			1.) First  <a href='{$config['phpurl']}/login.php' target='_blank'>click here</a> 
			to open a new window where you can log in at the BB,
			(leave that window  open after you logged in)<br />
			2.) Then  <a href='{$_SERVER['REQUEST_URI']}'>click here</a> to edit the wiki 					page.");



to fit your forum.

Copy the file ubbauth.php to the pmwiki 'local' directory.

2. Add this to your config file:

$DefaultPasswords['edit'] = ($user['U_Username']) ? '' : '*';
$DefaultPasswords['admin'] = ($user['U_Status'] == 'Administrator') ? '' : '*';
$Author = $user['U_Username'];

3. Add this to the top of the pmwiki.php file, after <?php :


4. Edit Site.EditForm and

 [=(:input e_author:)=] 





Anno 2006-1-30 Version 1.0


I've used this integration sucessfully, altho with a couple of modifications. As I don't want just anyone to start editing our wiki, I've made ubbauth.php check wherther the user is a member of a group in Ubb. The changes made are the following:

Line8: $user = $userob -> authenticate("U_Groups"); //this makes authenticate lookup the U_Groups field in addition to the usual. Line9: if (!strstr($user['U_Groups'],"-7-")){ //This is checks if the user is a member of group 7.

In addition, I changed the author info in config.php for this:
$Author = ($user['U_Username']);

  Ah, right, this was an error on my part above, thanks, fixed.

See Also


User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.