Extension:VBulletin/Users Integration

Working Example
I have taken Kai Backman's MediaWiki authentication plugin idea, fixed coding errors, and expanded greatly on it.

Working on: vBulletin 3.5.4 and MediaWiki 1.6.3

Features:
 * Allows you to run MediaWiki with your vBulletin user database
 * Disallows users with invalid username characters
 * Disallows users who are not part of specified usergroups
 * Sets users to sysop status in MediaWiki if they are part of a specified admin usergroup
 * Removes users from sysop status in MediaWiki if they no longer are a part of a specified admin usergroup
 * For same-database setups, allows easy installation

Possible Future Features
''These are possible features for inclusion in the how-to in the future. They have not been investigated for their feasibility, but are here to let you know they have been requested and I am thinking about them. If you know how to add the features, please let us know.''
 * No-login required (automatic) integration
 * Option: User profile field points to, or has option to link to vBulletin profile
 * To register, link the user to vBulletin's registration script on the login pages

How To
If you are running vBulletin and MediaWiki in the same database, then it already uses the connection information. If you are not running vBulletin and MediaWiki in the same database, please change the strings to reflect your vBulletin database information. In either case, the last value is whatever your vBulletin table prefix is. This prevents people from registering new accounts on the wiki, requiring people to register on vBulletin. It also prevents anonymous edits. This code may only work on MediaWiki 1.5.x and above, but I am unsure.
 * Install Reynaldovb's Restrict usernames to alphanumeric and underscore plugin, and disallow both spaces and underscores (vbulletin 3.7+ use the admincp / Options / Username Regular Expression field to ensure the username conforms to a certain format).
 * Optional: On boards that already have existing users, somehow have their usernames changed so that they are only alphanumeric. This is required if you wish your users to be able to login and edit the wiki using their vBulletin username.  The reason you have to do this is because MediaWiki has some Restrictions on what can go in a page title, and as usernames have to be passed as page titles, they also have to adhere to the same restrictions.  If you do not change the usernames, I have included a check to not allow users to login if their username contains non-alphanumeric characters.
 * Open your wiki/LocalSettings.php file
 * Insert the following code at the end of the file, before the ?>:
 * Insert this code below the require_once( "includes/DefaultSettings.php" ); at the top of the LocalSettings.php file:
 * Copy this AuthPlugin_vBulletin.php file and put it in your main wiki directory, ie: /wiki/AuthPlugin_vBulletin.php

Anonymous / Guest Visitors
In vB, a nice feature is to track the non-registered visitors. You can see how many members AND GUESTS on presently at the site... even down to the thread level.

It occurs to me that whenever someone goes to MW, it triggers a vB session and/or logs them in if there is a cookie. The reason is that some, actually more and more, people are going directly to the MW. I would like to make sure that the site stats as to who has been to the domain are maintained site-wide.

Login

 * If attempt is made to perform a function that requires login, redirect to vB to login.
 * Afterward, return user to page from where he came from.
 * Files to modify

Registration

 * Redirect user to vB for registration.
 * Use the following details to create a MW user (with link back to vB)
 * vB:userid
 * vB:username
 * vB:timezoneoffset
 * vB:salt
 * email authentification. Handled through vB.
 * vB:usergroupid. Need to validate that user has had email authenticated. Decision to only allow validated users to update wiki pages.
 * vB:email? Maybe not because all email will be done using vB email address.
 * vB:field? Disable e-mail from other users. See (http://www.noblood.org/forum/profile.php?do=editoptions)
 * Real Name: If user has entered their real name, use that or else default to vB username
 * MW:Nickname = vB:username
 * Ignore MW password, use vB only
 * vB:membergroupids, this contains the groups that the user is a member of. We need to map these to MW:user_groups
 * vB:usergroup, this contains the NAME of the groups that will be mapped to the MW:user_groups
 * Files to modify

Passwords

 * Only use vB

Authentication Method
Here is some base code for authenticating. This is not a working example, it is only a starting point.

This code needs to be modified to accommodate MediaWiki's needs by setting cookies. The query also may need to be enhanced to to look for things MediaWiki uses in its cookies/sessions. Thanks to Alfarin over at vb.com for this start.

Preferences

 * Default switches ON for:
 * Send me an email on page changes
 * Send me an email when my user talk page is changed
 * Need to disable certain options (preferences) that are now handled by vB
 * User dialog: Real name, email, nickname, raw signature, language
 * Password dialog: disable all, Use vB instead
 * Email dialog: Disable e-mail from other users (Use vB switch for that)
 * Skin dialog: Disable all (default to MonoBook)
 * Time zone dialog: Disable, use vB

Email User

 * Link in MW toolbox: Special:Emailuser/ to link to vB's function (vB/sendmessage.php?do=mailmember&u=#####) for this.
 * OR since email addresses are synchronized with MW, make no change.

Email Notifications

 * Use the email from MW since email addresses are synchronized.

Links back to vB

 * MW User: page to provide (in header, right-justified) a link automatically to vB user profile and link to email or PM.
 * In localsettings.php, provide for user defined icon path to define vB user profile link AND one for link to vB/MW email function
 * In preferences, user data dialog: Add link to vB user control panel (profile)

MW Special Pages

 * Special:Listusers: We need to add a link/icon next to each listed user to their vB profile.

Useful Extension Proposals

 * username=johndoe;fld=userTblFieldName Return vB user table field value
 * username=johndoe Return site defined icon that links to vB email user feature.

Skin/Style Issues

 * Question: Make MW the entry point with link to vB OR make vB the entry point to site?
 * If MW is the entry point..
 * Need to add key userCP type menu options
 * Need (IMHO) to present key vB type info on front page such as Who's Online!!!! Since MW caches pages, where/how to inject some real-time info into page? Turn off caching? Insert 'live' content AFTER footer? :(

vB Functions That Affect MW

 * User updates password
 * User changes email
 * User toggles switch to accept emails from others
 * User changes timezoneoffset
 * User changes real name fields
 * User changes homepage, or other fields

Sessions

 * Need to keep vB sessions alive so that we can see who's online whether they are in MW or in vB

Integration Issues
The largest problem with integrating vBulletin and MediaWiki is the use of characters not allowed in the MediaWiki namespace. In MediaWiki, the characters allowed in a username are the same that are allowed in a page name, and you can find those on the Help:Page name page.

There are two easy possibilities, which I have not explored or found information on:
 * If you have a small vB membership, renaming people's usernames so that they do not have the unwanted characters. In this case you will also want to edit vBulletin's registration function to disallow unwanted characters as well.
 * Making any links to a user's page link to their user page on vBulletin. Theoretically, this would allow people to keep their usernames intact, while not interfering with the MediaWiki namespace.