From 8e55334aef1c4573b987c3cbd7c6d26ef36e761e Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 29 Feb 2004 08:51:15 +0000 Subject: [PATCH] Special developer powers in SpecialMakesysop, different defaults for anons and logged in users, plus some bits and pieces --- includes/SpecialMakesysop.php | 112 ++++++++++++++++++++++++---------- includes/SpecialUserlogin.php | 3 +- includes/User.php | 8 ++- languages/Language.php | 26 ++++++-- 4 files changed, 111 insertions(+), 38 deletions(-) diff --git a/includes/SpecialMakesysop.php b/includes/SpecialMakesysop.php index a5f58ef72d..b9dd2a63b8 100644 --- a/includes/SpecialMakesysop.php +++ b/includes/SpecialMakesysop.php @@ -9,7 +9,7 @@ function wfSpecialMakesysop() $wgOut->errorpage( "movenologin", "movenologintext" ); return; } - if (! $wgUser->isBureaucrat()){ + if (! $wgUser->isBureaucrat() && ! $wgUser->isDeveloper() ){ $wgOut->errorpage( "bureaucrattitle", "bureaucrattext" ); return; } @@ -32,9 +32,13 @@ class MakesysopForm { function showForm( $err = "") { global $wgOut, $wgUser, $wgLang; - global $wpNewTitle, $wpOldTitle, $wpMovetalk, $target; + global $wpNewTitle, $wpOldTitle, $wpMovetalk, $target, $wpRights, $wpMakesysopUser; - $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) ); + if ( $wgUser->isDeveloper() ) { + $wgOut->setPageTitle( wfMsg( "set_user_rights" ) ); + } else { + $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) ); + } $wgOut->addWikiText( wfMsg( "makesysoptext" ) ); @@ -46,16 +50,23 @@ class MakesysopForm { $wgOut->addHTML( "

{$err}\n" ); } $namedesc = wfMsg( "makesysopname" ); + if ( isset( $wpMakesysopUser ) ) { + $encUser = htmlspecialchars( $wpMakesysopUser ); + } else { + $encUser = ""; + } + $wgOut->addHTML( "

" ); + /* $makeburo = wfMsg( "setbureaucratflag" ); $wgOut->addHTML( " @@ -63,9 +74,31 @@ class MakesysopForm { $makeburo " - ); + );*/ + + if ( $wgUser->isDeveloper() ) { + $rights = wfMsg( "rights" ); + if ( isset( $wpRights ) ) { + $encRights = htmlspecialchars( $wpRights ); + } else { + $encRights = "sysop"; + } - $mss = wfMsg( "makesysopsubmit" ); + $wgOut->addHTML( " + + + + " + ); + } + + if ( $wgUser->isDeveloper() ) { + $mss = wfMsg( "set_user_rights" ); + } else { + $mss = wfMsg( "makesysopsubmit" ); + } $wgOut->addHTML( "
$namedesc - +
$rights + +
  @@ -79,18 +112,18 @@ class MakesysopForm { function doSubmit() { global $wgOut, $wgUser, $wgLang, $wpMakesysopUser, $wpSetBureaucrat; - global $wgDBname, $wgMemc; - /* + global $wgDBname, $wgMemc, $wpRights; + $parts = explode( "@", $wpMakesysopUser ); - if( count( $parts ) == 2){ + if( count( $parts ) == 2 && $wgUser->isDeveloper() ){ $username = addslashes( $parts[0] ); $usertable = $parts[1] . "wiki.user"; $dbName = $parts[1] . "wiki"; - } else {*/ - $username = addslashes( $wpMakesysopUser ); + } else { + $username = addslashes( $wpMakesysopUser ); $usertable = "user"; $dbName = $wgDBname; - #} + } $prev = wfIgnoreSQLErrors( TRUE ); $res = wfQuery("SELECT user_id, user_rights FROM user WHERE user_name = '{$username}'", DB_WRITE); wfIgnoreSQLErrors( $prev ); @@ -104,23 +137,28 @@ class MakesysopForm { $id = intval( $row->user_id ); $rightsNotation = array(); - if( $row->user_rights ){ - $rights = explode(",", $row->user_rights ); - if(! in_array("sysop", $rights ) ){ - $rights[] = "sysop"; - $rightsNotation[] = "+sysop "; - } - if ( $wpSetBureaucrat && !in_array( "bureaucrat", $rights ) ) { - $rights[] = "bureaucrat"; - $rightsNotation[] = "+bureaucrat "; - } - $newrights = addslashes( implode( ",", $rights ) ); + if ( $wgUser->isDeveloper() ) { + $newrights = (string)$wpRights; + $rightsNotation[] = "=$wpRights"; } else { - $newrights = "sysop"; - $rightsNotation[] = "+sysop"; - if ( $wpSetBureaucrat ) { - $rightsNotation[] = "+bureaucrat"; - $newrights .= ",bureaucrat"; + if( $row->user_rights ){ + $rights = explode(",", $row->user_rights ); + if(! in_array("sysop", $rights ) ){ + $rights[] = "sysop"; + $rightsNotation[] = "+sysop "; + } + if ( $wpSetBureaucrat && !in_array( "bureaucrat", $rights ) ) { + $rights[] = "bureaucrat"; + $rightsNotation[] = "+bureaucrat "; + } + $newrights = addslashes( implode( ",", $rights ) ); + } else { + $newrights = "sysop"; + $rightsNotation[] = "+sysop"; + if ( $wpSetBureaucrat ) { + $rightsNotation[] = "+bureaucrat"; + $newrights .= ",bureaucrat"; + } } } @@ -143,10 +181,16 @@ class MakesysopForm { function showSuccess() { - global $wgOut, $wpMakesysopUser; + global $wgOut, $wpMakesysopUser, $wgUser; $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) ); - $text = wfMsg( "makesysopok", $wpMakesysopUser ); + + if ( $wgUser->isDeveloper() ) { + $text = wfMsg( "user_rights_set", $wpMakesysopUser ); + } else { + $text = wfMsg( "makesysopok", $wpMakesysopUser ); + } + $text .= "\n\n"; $wgOut->addWikiText( $text ); $this->showForm(); @@ -154,10 +198,14 @@ class MakesysopForm { function showFail() { - global $wgOut, $wpMakesysopUser; + global $wgOut, $wpMakesysopUser, $wgUser; $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) ); - $this->showForm( wfMsg( "makesysopfail", $wpMakesysopUser ) ); + if ( $wgUser->isDeveloper() ) { + $this->showForm( wfMsg( "set_rights_fail", $wpMakesysopUser ) ); + } else { + $this->showForm( wfMsg( "makesysopfail", $wpMakesysopUser ) ); + } } } ?> diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index bdb389ebcc..8939700a5f 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -121,11 +121,12 @@ function wfSpecialUserlogin() return; } $u = User::newFromName( $wpName ); - + if ( 0 != $u->idForName() ) { mainLoginForm( wfMsg( "userexists" ) ); return; } + $u->loadDefaultUserOptions(); $u->addToDatabase(); $u->setPassword( $wpPassword ); $u->setEmail( $wpEmail ); diff --git a/includes/User.php b/includes/User.php index 7a21052abf..d53e30c012 100644 --- a/includes/User.php +++ b/includes/User.php @@ -78,7 +78,7 @@ class User { $this->mEmail = ""; $this->mPassword = $this->mNewpassword = ""; $this->mRights = array(); - $defOpt = $wgLang->getDefaultUserOptions() ; + $defOpt = $wgLang->getDefaultAnonOptions() ; foreach ( $defOpt as $oname => $val ) { $this->mOptions[$oname] = $val; } @@ -92,6 +92,12 @@ class User { $this->cookiePassword = ""; } + function loadDefaultUserOptions() + { + global $wgLang; + $this->mOptions = $wgLang->getDefaultUserOptions(); + } + /* private */ function getBlockedStatus() { global $wgIP, $wgBlockCache; diff --git a/languages/Language.php b/languages/Language.php index 6cd3aad895..cc687acb76 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -59,6 +59,11 @@ if($wgMetaNamespace === FALSE) 7 => "Image_talk", 8 => "MediaWiki", 9 => "MediaWiki_talk" + + # Temporarily commented out: + /*, + 10 => "Template", + 11 => "Template_talk"*/ ); /* private */ $wgDefaultUserOptionsEn = array( @@ -72,6 +77,10 @@ if($wgMetaNamespace === FALSE) "date" => 0 ); +/* private */ $wgDefaultAnonOptionsEn = array( + "editsection" => 0 +); + /* private */ $wgQuickbarSettingsEn = array( "None", "Fixed left", "Fixed right", "Floating left" ); @@ -1311,11 +1320,15 @@ this function sparingly.", Type the name of the user in the box and press the button to make the user an administrator", "makesysopname" => "Name of the user:", "makesysopsubmit" => "Make this user into a sysop", -"makesysopok" => "User '$1' is now a sysop", -"makesysopfail" => "User '$1' could not be made into a sysop. (Did you enter the name correctly?)", +"makesysopok" => "User \"$1\" is now a sysop", +"makesysopfail" => "User \"$1\" could not be made into a sysop. (Did you enter the name correctly?)", "setbureaucratflag" => "Set bureaucrat flag", "bureaucratlog" => "Bureaucrat_log", -"bureaucratlogentry" => " set $1: $2", +"bureaucratlogentry" => "Rights for user \"$1\" set \"$2\"", +"rights" => "Rights:", +"set_user_rights" => "Set user rights", +"user_rights_set" => "User rights for \"$1\" updated", +"set_rights_fail" => "User rights for \"$1\" could not be set. (Did you enter the name correctly?)", # Move page # @@ -1412,8 +1425,13 @@ class Language { function getDefaultUserOptions () { global $wgDefaultUserOptionsEn ; return $wgDefaultUserOptionsEn ; - } + } + function getDefaultAnonOptions() { + global $wgDefaultAnonOptionsEn; + return $wgDefaultAnonOptionsEn + $this->getDefaultUserOptions(); + } + function getBookstoreList () { global $wgBookstoreListEn ; return $wgBookstoreListEn ; -- 2.20.1