Limited developer version of Special:Makesysop to a given list of databases
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 1 Mar 2004 00:31:08 +0000 (00:31 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 1 Mar 2004 00:31:08 +0000 (00:31 +0000)
includes/DefaultSettings.php
includes/SpecialMakesysop.php

index 6084e06..331d668 100644 (file)
@@ -49,6 +49,10 @@ $wgDBtransactions    = false; # Set to true if using InnoDB tables
 $wgDBmysql4                    = false; # Set to true to use enhanced fulltext search
 $wgSqlTimeout          = 30;
 
+# Other wikis on this site, can be administered from a single developer account
+# Array, interwiki prefix => database name
+$wgLocalDatabases   = array();
+
 # Database load balancer
 $wgDBservers           = false; # e.g. array("larousse", "pliny")
 $wgDBloads                     = false; # e.g. array(0.6, 0.4);
index b9dd2a6..7ab506f 100644 (file)
@@ -112,20 +112,25 @@ class MakesysopForm {
        function doSubmit()
        {
                global $wgOut, $wgUser, $wgLang, $wpMakesysopUser, $wpSetBureaucrat;
-               global $wgDBname, $wgMemc, $wpRights;
+               global $wgDBname, $wgMemc, $wpRights, $wgLocalDatabases;
                
                $parts = explode( "@", $wpMakesysopUser );
                if( count( $parts ) == 2 && $wgUser->isDeveloper() ){
-                       $username = addslashes( $parts[0] );
-                       $usertable = $parts[1] . "wiki.user";
-                       $dbName = $parts[1] . "wiki";
+                       $username = wfStrencode( $parts[0] );
+                       if ( array_key_exists( $parts[1], $wgLocalDatabases ) ) {
+                               $dbName = $wgLocalDatabases[$parts[1]];
+                               $usertable = $dbName . ".user";
+                       } else {
+                               $this->showFail();
+                               return;
+                       }
                } else {
-                       $username = addslashes( $wpMakesysopUser );
+                       $username = wfStrencode( $wpMakesysopUser );
                        $usertable = "user";
                        $dbName = $wgDBname;
                }
                $prev = wfIgnoreSQLErrors( TRUE );
-               $res = wfQuery("SELECT user_id, user_rights FROM user WHERE user_name = '{$username}'", DB_WRITE);
+               $res = wfQuery("SELECT user_id, user_rights FROM $usertable WHERE user_name = '{$username}'", DB_WRITE);
                wfIgnoreSQLErrors( $prev );
 
                if( wfLastErrno() || ! $username || wfNumRows( $res ) == 0 ){
@@ -165,9 +170,9 @@ class MakesysopForm {
                if ( count( $rightsNotation ) == 0 ) {
                        $this->showFail();
                } else {
-                       $sql = "UPDATE user SET user_rights = '{$newrights}' WHERE user_id = $id LIMIT 1";
+                       $sql = "UPDATE $usertable SET user_rights = '{$newrights}' WHERE user_id = $id LIMIT 1";
                        wfQuery($sql, DB_WRITE);
-                       $wgMemc->delete( "$wgDBname:user:id:$id" );
+                       $wgMemc->delete( "$dbName:user:id:$id" );
                        
                        $bureaucratLog = wfMsg( "bureaucratlog" );
                        $action = wfMsg( "bureaucratlogentry", $wpMakesysopUser, implode( " ", $rightsNotation ) );