MyBB Community Forums

Full Version: MyBB Mediawiki
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Read carefully the instructions present in my post, i posted some code to add in LocalSettings.php
I know, but what do I need to download besides the Authmybb.php?
MediaWiki script.
Hello, sorry, I forgot to update you.
Modifying the related queries like this:

$query = mysql_query("SELECT username FROM {$this->table_prefix}users WHERE username='".$this->escape_string($username)."' OR username='".$this->escape_string(str_replace(' ','_',$username))."'", $this->db);

seems to solve the problem.
If you look at my implementation you'll see that this fix is already present. Smile

	function fixUserName($username)
	{
		if(strpos($username, " ") === false)
			return $username;
		$db = &$this->db;
		$query = $db->simple_select("users", "username", "username='$username' OR username='" . str_replace(" ", "_", $username) . "'", array('order_by' => 'regdate', 'order_dir' => 'ASC', 'limit' => 1));
		$result = $db->fetch_array($query);
		$user = $result['username'];
		if($user)
			return $user;
		else
			return $username;
	}
Thanks, flash.tato, for the new script version!

I noticed the script won't work, if a user has multiple underscores in his/her name, though - as MediaWiki seems to combine these into one. Two consecutive underscores can be fixed easily by adding the following in the function fixUserName, before $query = ...

$username = str_replace(" ", "__", $username);

However, a more generic (and elegant Rolleyes) solution would be nice...
I found a small, but serious bug from flash.tato's code

This piece of code

    function fixUserName($username)
    {
        if(strpos($username, " ") === false)
        ...

Should be:

    function fixUserName($username)
    {
        if(strpos($username, "_") === false)
        ...

So, in the beginning, the string is searched for an underscore - not space. With the current code, usernames with spaces in them don't seem to work - at least if the user has already successfully created an account for the wiki.
Here's an updated version of Chris's plugin to work with the latest MediaWiki release.

You will need to configure the url to your forum in the source code of the attached file.
I updated the attachment in the post above with a few bug fixes
thanks ryan exactly what i was searching for Wink
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20