Limited developer version of Special:Makesysop to a given list of databases

This commit is contained in:
Tim Starling 2004-03-01 00:31:08 +00:00
parent 57662e79d4
commit 2c34ad2fc0
2 changed files with 17 additions and 8 deletions

View 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);

View 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 ) );