Wikka with Simple Machines Forum


This modification is now in testing and development. I'm a novice coder so all help appreciated!

This mod uses the SMF API (smf_api.php) available from SMF which is a tool to facilitate clean integration of SMF into other scripts.

Aims:

  1. Replace the Wikka registration/login system with a bridge to the SMF forum membership system.
  1. Allow registered and logged-in SMF forum users to edit pages in Wikka
  1. Automatically camel-case SMF usernames for use in Wikka

Here's the basics of how it works:

Is user logged in to SMF?
Yes >
Does WikkaUsername exist?
No > User is a guest and can register for the wiki using the registration code (requires registration code mod)
Yes > User logged in to wiki automatically
No >
User is a guest and can't register to edit the Wiki until they are logged in to SMF.

Note: the WikkaUsername is created automatically by taking the SMF username, changing the first letter to uppercase and prefixing with "Wikka", thus making it CamelCase and WikiName friendly.

I also added a new ACL "smf registered users" for which I used the symbol "^". This checks that the user is logged in to SMF but doesn't check whether they have a Wikka account.

TonZijlstra has also created a bridge between Wikka and SMF which works the other way around - i.e. people login to Wikka and this automatically logs them into SMF, see below. (For ease of reading this page I wonder whether these two mods should be seperated onto different pages, as they do slightly different things too).


(TonZijlstra)

We could work the other way around as well:
Aims:
  1. Replace the SMF registration page with a bridge from wikka registration page
  1. Allow registered and logged-in wikka users to use the forum (and none else)

I use a wikkasite where I want to include a SMF forum. So I'd like SMF to use the usernames and pw's from Wikka, and have Wikka log them into the forum when they log into the wiki. (same goes for editing rights in Wordpress weblog admintool)

Possible ways of achieving this:
  1. the two routes as stated above
  1. have Wikka set a cookie for SMF as well, as both rely on cookies for determining logged-in status.


UPDATE:
I've hacked together an extremely crude attempt of making the Wikka Login procedure run through SMF.
I am using it in a platform that is a combination of Wikka, SMF and two Wordpress blogs one of which is only accessible for logged on users. The user tables of these 4 modules already contain the same list of users and pw's. As no-one can register on the platform freely, the number of users is limited to around 20, and only the admin creates accounts it is easy to maintain those tables.

Also the only reason I go through the forum here is because setting the cookies for the forum from the wiki was to tedious and it was easier the other way around. I only wanted to give the users the impression of single sign on.

Next step is deleting all cookies that were set on log-out which is easily done from within wikka itself. Changing passwords is another matter, but as I said, in my case not a big problem, given the closed user group of only a few individuals.

I have altered the login script of SMF Loginout.php after where it says

// Bam!  Cookie set.  A session too, just incase.
	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['ID_MEMBER'], $md5_passwrd);



by adding
// setting cookies for both blogs as well for editing rights and the wiki
// first some variables
$passwordwp=md5(md5($_REQUEST['passwrd']));
$usernamewp=$_REQUEST[user];
$homewp1="http://www.weblogdomain1.com";
$homewp2="http://www.weblogdomain2.com";
$cookiepathwp1= preg_replace('|https?://[^/]+|i', '', $homewp1 . '/' );
$cookiepathwp2= preg_replace('|https?://[^/]+|i', '', $homewp2 . '/' );
$siteurlwp1=$homewp1;
$siteurlwp2=$homewp2;
$cookiehashwp1 = md5($siteurlwp1);
$cookiehashwp2 = md5($siteurlwp2);

// setting the cookies for two wordpress blogs
setcookie('wordpressuser_'. $cookiehashwp1, $usernamewp, time() + 31536000, $cookiepathwp1);
setcookie('wordpresspass_'. $cookiehashwp1, $passwordwp, time() + 31536000, $cookiepathwp1);
setcookie('wordpressuser_'. $cookiehashwp2, $usernamewp, time() + 31536000, $cookiepathwp2);
setcookie('wordpresspass_'. $cookiehashwp2, $passwordwp, time() + 31536000, $cookiepathwp2);

//variables for the wiki-cookies
$name1="wikka_user_name";
$name2="wikka_pass";
$wikiname=$_REQUEST['user'];
$wikipass= md5($_REQUEST['passwrd']);
// setting wikicookies
setcookie($name1, $wikiname, time() + 90 * 24 * 60 * 60, "/");
setcookie($name2, $wikipass, time() + 90 * 24 * 60 * 60, "/");


And a bit further down in the same file I added:

// redirect to wiki if that is where you came from
if (isset($_REQUEST[refer])) 
	   redirectexit('http://yourdomain.com/yourwikipage', false);


before where it says

// Just log you back out if it's in maintenance mode and you AREN'T an admin.


Next I altered usersettings.php in the Wikka actions:

replacing

// check password
			if ($existingUser["password"] == md5($_POST["password"]))
			{
				
							  
							  $this->SetUser($existingUser);
							  $this->Redirect($this->href());
			}


with

// check password
			if ($existingUser["password"] == md5($_POST["password"]))
			{
				
							  
							  $this->SetUser($existingUser);
							 // lets go through the forum
							  $forumurl = "http://yourdomain.com/forum/index.php?action=login2&user=".$_POST['name']."&passwrd=".$_POST['password']."&refer=wiki ";
							  $this->Redirect($forumurl);
							  //$this->Redirect($this->href());
			}


(TonZijlstra)

CategoryUserContributions
Comments
Comment by zylstra-2.demon.nl
2005-09-03 18:57:51
I'd be interested in help think this out (although not an experienced coder, just a user with an urge to tinker). I've been thinking about integrating SMF in a wiki, so was looking for the other way around: how to automatically log people into SMF, when they log into the wiki.
My current attempts were aimed at having Wikka write a cookie for SMF as well (as both rely on cookiesetting to determine if you're logged in.)
Comment by MyTreo
2006-05-08 07:15:55
Hi Ton, I finally had chance to revisit this and got a bridge working. Thanks for your input above - I think the way I have approached this would work for your system too and would give you control over your members in SMF rather than through Wikka. There are many ways to skin a cat though, so if your method works for you then great!
Comment by WillyPs
2008-01-06 17:55:23
I am wondering what versions Wikka and SMF this is for... I tried it and it does not seem to work.
Comment by NilsLindenberg
2008-01-08 06:23:19
Hi Willy, I don't know, which versions. Do you get any error message(s)?
Comment by WillyPs
2008-01-09 19:50:47
No, no errors, but I could still register/login from the wikki login page. Doing so then redirected me to the forum. What I want is to register/login from the forum page as that requires Admin approval and user verification.

I tried it with SMF 1.1.4 (latest version) and Wikka 1.1.6.2

I also have a site with Wikka 1.1.6.3 so I may try with that also. I would like to more integrate than just login, though. My vision is a wikki page heading each topic, with sub topics underneath. I think people would be more comfortable posting in a forum style environment. Then the info could be gathered in the wikki page at the top of the topic.
Comment by NilsLindenberg
2008-01-11 12:41:15
Yes, that idea isn't covered by this code. But you could take a look at older versions of UserRegistration, apply that code and then turn off user-registration for the wiki.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki