Revision [14167]

This is an old revision of WikkaWithSMF made by MyTreo on 2006-05-08 06:59:52.

 

Wikka with Simple Machines Forum


This is still in the idea stage, although I am already testing some hacks on my local machine.

All help appreciated!

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

Possible ways of acheiving this:

  1. Either using a similar hack to WikkaWithphpBB, or
  1. use the API (smf_api.php) that is supplied with SMF that allows us to call some standard routines like checking whether a user is logged in and return their username.

I am currently favouring method 2, which will probably be slightly more difficult but I think it will offer greater flexibility and tighter integration, we'll see...

Update (8 May 2006)

I have finally had time to revisit this and managed to get some kind of bridge working as per 2) above. I will document the changes shortly (there are very few changes actually!)

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
There are 6 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki