Created
October 23, 2012 22:43
-
-
Save dbolser/3942240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('VBULL_EXTENSION_VERSION', '2.1.2'); | |
# if we're not in the mediawiki framework just die | |
if ( !defined( 'MEDIAWIKI' ) ) die(); | |
# extension credits | |
$wgExtensionCredits['other'][] = array( | |
'path' => __FILE__, | |
'name' => 'MMOG Wiki', | |
'author' => 'Paul Stout', | |
'url' => 'http://www.mymmogames.net/', | |
'description' => 'Single Sign On from vBulletin', | |
'version' => '2.1.2', | |
); | |
# The only var needed | |
$wgVBull_VB_SYSTEM_PATH = ''; | |
# Set up | |
$wgHooks['PersonalUrls'][] = 'set_personal_urls'; | |
$wgHooks['UserLoadFromSession'][] = 'vBSSOAutoAuth'; | |
# INITIALIZE VBULLETIN SUBSYSTEM | |
if ( !defined( 'CWD' ) ) | |
define( 'CWD', ( $wgVBull_VB_SYSTEM_PATH ) ); | |
define('THIS_SCRIPT', 'wiki'); | |
require_once( CWD . '/global.php'); | |
require_once( CWD . '/includes/functions.php'); | |
$vBDonor = FALSE; | |
if ( is_member_of( $vbulletin->userinfo, 11 ) ) { | |
$vBDonor = TRUE; | |
} | |
# END VBULLETIN SUBSYSTEM | |
function vBSSOAutoAuth(&$user) { | |
global $wgRequest; | |
global $vbulletin; | |
global $wgUser; | |
if ( $user != null ) { | |
# user is authenticated (by another hook) | |
if ( !$user->isAnon() ) { | |
# User is not anonymous. | |
# Check for the existence of a valid vB userid. If we | |
# don't have one, log the old user out. | |
if ( $vbulletin->userinfo['userid'] == 0 ) { | |
$user->logout(); | |
} | |
# Check NoLogin groups. If they're logged in and shouldn't | |
# be, log them out! | |
$mmog_nologin = explode( ',', str_replace( ' ', '', | |
$vbulletin->options['mmog_wiki_nologin_ug'] ) ); | |
foreach ( $mmog_nologin as $nologin ) { | |
if ( is_member_of( $vbulletin->userinfo, $nologin ) ) { | |
$user->logout(); | |
break; | |
} | |
} | |
return true; | |
} | |
} | |
if ( $vbulletin->userinfo['userid'] ) { | |
# Check Nologin Groups - if they're a member then do not log | |
# them in. | |
$mmog_nologin = explode( ',', str_replace( ' ', '', | |
$vbulletin->options['mmog_wiki_nologin_ug'] ) ); | |
foreach ( $mmog_nologin as $nologin ) { | |
if ( is_member_of( $vbulletin->userinfo, $nologin ) ) | |
return true; | |
} | |
$username = $vbulletin->userinfo['username']; | |
if ( $username ) { | |
$u = User::newFromName( $username ); | |
if ( $u->getID() == 0 ) { | |
$u->addToDatabase(); | |
$u->setToken(); | |
} | |
else { | |
$u->clearInstanceCache( 'id' ); | |
$u->load(); | |
} | |
$user = $u; | |
$user->setOption( 'rememberpassword', 1 ); | |
wfSetupSession(); | |
$user->setCookies(); | |
$user->invalidateCache(); | |
$user->saveSettings(); | |
# Check Sysop Groups | |
$mmog_sysopgroup = explode( ',', str_replace( ' ', '', | |
$vbulletin->options['mmog_wiki_sysop_ug'] ) ); | |
foreach( $mmog_sysopgroup as $sysopgroup ) { | |
if ( is_member_of( $vbulletin->userinfo, $sysopgroup ) ) { | |
$user->addGroup( 'sysop' ); | |
break; | |
} | |
} | |
$mmog_bureaugroup = explode( ',', str_replace( ' ', '', | |
$vbulletin->options['mmog_wiki_bureaucrat_ug'] ) ); | |
foreach ( $mmog_bureaugroup as $bureaugroup ) { | |
if ( is_member_of( $vbulletin->userinfo, $bureaugroup ) ) { | |
$user->addGroup( 'bureaucrat' ); | |
break; | |
} | |
} | |
} | |
} | |
else | |
$user->logout(); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment