/**
 * Called from $wgExtensionFunctions array when initialising extensions
 */
function wfSetupSimpleSecurity()
{
    global $wgSimpleSecurity, $wgSecurityUseDBHook, $wgLoadBalancer, $wgDBtype, $wgOldDBtype;
    # Instantiate the SimpleSecurity singleton now that the environment is prepared
    $wgSimpleSecurity = new SimpleSecurity();
    # If the DB hook couldn't be set up early, do it now
    # - but now the LoadBalancer exists and must have its DB types changed
    if ($wgSecurityUseDBHook) {
        wfSimpleSecurityDBHook();
        if (function_exists('wfGetLBFactory')) {
            wfGetLBFactory()->forEachLB(array('SimpleSecurity', 'updateLB'));
        } elseif (is_object($wgLoadBalancer)) {
            SimpleSecurity::updateLB($wgLoadBalancer);
        } else {
            die("Can't hook in to Database class!");
        }
    }
    # Request a DB connection to ensure the LoadBalancer is initialised,
    # then change back to old DBtype since it won't be used for making connections again but can affect other operations
    # such as $wgContLang->stripForSearch which is called by SearchMySQL::parseQuery
    wfGetDB(DB_MASTER);
    $wgDBtype = $wgOldDBtype;
}
$wgHooks['LanguageGetMagic'][] = 'wfSimpleSecurityLanguageGetMagic';
$wgExtensionCredits['parserhook'][] = array(
	'path'        => __FILE__,
	'name'        => "SimpleSecurity",
	'author'      => "[http://www.organicdesign.co.nz/User:Nad User:Nad]",
	'url'         => "http://www.mediawiki.org/wiki/Extension:SimpleSecurity",
	'version'     => SIMPLESECURITY_VERSION,
	'descriptionmsg' => 'security-desc',
);
$wgHooks['MessagesPreLoad'][] = 'wfSimpleSecurityMessagesPreLoad';

# Instantiate the SimpleSecurity singleton now that the environment is prepared
$wgSimpleSecurity = new SimpleSecurity();

# If using the DBHook, apply it now (must be done from the root scope since it creates classes)
if( $wgSecurityUseDBHook ) SimpleSecurity::applyDatabaseHook();

/**
 * Register magic words
 */
function wfSimpleSecurityLanguageGetMagic( &$magicWords, $langCode = 0 ) {
	global $wgSecurityMagicIf, $wgSecurityMagicGroup;
	$magicWords[$wgSecurityMagicIf]    = array( $langCode, $wgSecurityMagicIf );
	$magicWords[$wgSecurityMagicGroup] = array( $langCode, $wgSecurityMagicGroup );
	return true;
}

function wfSimpleSecurityMessagesPreLoad( $title, &$text ) {
	global $wgSecurityExtraActions, $wgSecurityExtraGroups;

	if( substr( $title, 0, 12 ) == 'Restriction-' ) {
Example #3
0
# Extra group permissions rules
$wgPageRestrictions = array();
# Enable this if you use the RecordAdmin extension and want Record template's
# protection to apply to all instances of that record type
$wgSecurityProtectRecords = true;
# Don't use the DB hook by default since it's voodoo
if (!isset($wgSecurityUseDBHook)) {
    $wgSecurityUseDBHook = false;
}
$wgExtensionCredits['parserhook'][] = array('path' => __FILE__, 'name' => "SimpleSecurity", 'author' => "[http://www.organicdesign.co.nz/User:Nad User:Nad]", 'url' => "http://www.mediawiki.org/wiki/Extension:SimpleSecurity", 'version' => SIMPLESECURITY_VERSION, 'descriptionmsg' => 'security-desc');
$wgHooks['MessagesPreLoad'][] = 'wfSimpleSecurityMessagesPreLoad';
# Instantiate the SimpleSecurity singleton now that the environment is prepared
$wgSimpleSecurity = new SimpleSecurity();
# If using the DBHook, apply it now (must be done from the root scope since it creates classes)
if ($wgSecurityUseDBHook) {
    SimpleSecurity::applyDatabaseHook();
}
function wfSimpleSecurityMessagesPreLoad($title, &$text)
{
    global $wgSecurityExtraActions, $wgSecurityExtraGroups;
    if (substr($title, 0, 12) == 'Restriction-') {
        $key = substr($title, 12);
        if (isset($wgSecurityExtraActions[$key])) {
            $text = empty($wgSecurityExtraActions[$key]) ? ucfirst($key) : $wgSecurityExtraActions[$key];
        }
        return true;
    } elseif (substr($title, 0, 14) == 'Protect-level-') {
        $key = substr($title, 14);
        $type = 'level';
    } elseif (substr($title, 0, 6) == 'Right-') {
        $key = substr($title, 6);