Special developer powers in SpecialMakesysop, different defaults for anons and logged...
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 29 Feb 2004 08:51:15 +0000 (08:51 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 29 Feb 2004 08:51:15 +0000 (08:51 +0000)
includes/SpecialMakesysop.php
includes/SpecialUserlogin.php
includes/User.php
languages/Language.php

index a5f58ef..b9dd2a6 100644 (file)
@@ -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( "<p><font color='red' size='+1'>{$err}</font>\n" );
                }
                $namedesc = wfMsg( "makesysopname" );
+               if ( isset( $wpMakesysopUser ) ) {
+                       $encUser = htmlspecialchars( $wpMakesysopUser );
+               } else {
+                       $encUser = "";
+               }
+
                $wgOut->addHTML( "<p>
                        <form id=\"makesysop\" method=\"post\" action=\"{$action}\">
                        <table border=0>
                        <tr>
                                <td align=right>$namedesc</td>
                                <td align=left>
-                                       <input type=text size=40 name=\"wpMakesysopUser\">
+                                       <input type=text size=40 name=\"wpMakesysopUser\" value=\"$encUser\">
                                </td>
                        </tr>" 
                );
+               /*
                $makeburo = wfMsg( "setbureaucratflag" );
                $wgOut->addHTML(
                        "<tr>
@@ -63,9 +74,31 @@ class MakesysopForm {
                                        <input type=checkbox name=\"wpSetBureaucrat\" value=1>$makeburo
                                </td>
                        </tr>"
-               );
+               );*/
+
+               if ( $wgUser->isDeveloper() ) {
+                       $rights = wfMsg( "rights" );
+                       if ( isset( $wpRights ) ) {
+                               $encRights = htmlspecialchars( $wpRights );
+                       } else {
+                               $encRights = "sysop";
+                       }
 
-               $mss = wfMsg( "makesysopsubmit" );
+                       $wgOut->addHTML( "
+                               <tr>
+                                       <td align=right>$rights</td>
+                                       <td align=left>
+                                               <input type=text size=40 name=\"wpRights\" value=\"$encRights\">
+                                       </td>
+                               </tr>" 
+                       );
+               }
+
+               if ( $wgUser->isDeveloper() ) {
+                       $mss = wfMsg( "set_user_rights" );
+               } else {
+                       $mss = wfMsg( "makesysopsubmit" );
+               }
                $wgOut->addHTML(
                        "<tr>
                                <td>&nbsp;</td><td align=left>
@@ -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 ) );
+               }
        }
 }
 ?>
index bdb389e..8939700 100644 (file)
@@ -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 );
index 7a21052..d53e30c 100644 (file)
@@ -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;
index 6cd3aad..cc687ac 100644 (file)
@@ -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"          => "<b>User '$1' is now a sysop</b>",
-"makesysopfail"                => "<b>User '$1' could not be made into a sysop. (Did you enter the name correctly?)</b>",
+"makesysopok"          => "<b>User \"$1\" is now a sysop</b>",
+"makesysopfail"                => "<b>User \"$1\" could not be made into a sysop. (Did you enter the name correctly?)</b>",
 "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"      => "<b>User rights for \"$1\" updated</b>",
+"set_rights_fail"      => "<b>User rights for \"$1\" could not be set. (Did you enter the name correctly?)</b>",
 
 # 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 ;