Use Revision for individual message loads; not using it for bulk load just now; need...
[lhc/web/wiklou.git] / includes / SpecialMakesysop.php
index 15fa120..96b8763 100644 (file)
@@ -1,15 +1,30 @@
 <?php
+/**
+ * File is replaced by SpecialUserlevels. It is kept here for migration purposes
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ * @deprecated
+ */
+
+die('Use SpecialUserlevels instead !!'); // [av]
+
+
+/**
+ *
+ */
 require_once( "LinksUpdate.php" );
 
-function wfSpecialMakesysop()
-{
+/**
+ * Constructor
+ */
+function wfSpecialMakesysop() {
        global $wgUser, $wgOut, $wgRequest;
 
-       if ( 0 == $wgUser->getID() or $wgUser->isBlocked() ) {
+       if ( $wgUser->isAnon() or $wgUser->isBlocked() ) {
                $wgOut->errorpage( "movenologin", "movenologintext" );
                return;
        }
-       if (! $wgUser->isBureaucrat() && ! $wgUser->isDeveloper() ){
+       if (! $wgUser->isAllowed('userrights') ) {
                $wgOut->errorpage( "bureaucrattitle", "bureaucrattext" );
                return;
        }
@@ -24,15 +39,19 @@ function wfSpecialMakesysop()
        if ( $f->mSubmit ) { 
                $f->doSubmit(); 
        } else { 
-               $f->showForm( "" ); 
+               $f->showForm( '' ); 
        }
 }
 
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 class MakesysopForm {
        var $mTarget, $mAction, $mRights, $mUser, $mSubmit;
 
-       function MakesysopForm( &$request ) 
-       {
+       function MakesysopForm( &$request ) {
                $this->mAction = $request->getText( 'action' );
                $this->mRights = $request->getVal( 'wpRights' );
                $this->mUser = $request->getText( 'wpMakesysopUser' );
@@ -40,8 +59,7 @@ class MakesysopForm {
                $this->mBuro = $request->getBool( 'wpSetBureaucrat' );
        }
 
-       function showForm( $err = "")
-       {
+       function showForm( $err = '') {
                global $wgOut, $wgUser, $wgLang;
 
                if ( $wgUser->isDeveloper() ) {
@@ -119,8 +137,7 @@ class MakesysopForm {
 
        }
 
-       function doSubmit()
-       {
+       function doSubmit() {
                global $wgOut, $wgUser, $wgLang;
                global $wgDBname, $wgMemc, $wgLocalDatabases;
 
@@ -147,10 +164,9 @@ class MakesysopForm {
                }
                if ( $username{0} == "#" ) {
                        $id = intval( substr( $username, 1 ) );
-                       $sql = "SELECT user_id,user_rights FROM $user_rights WHERE user_id=$id FOR UPDATE";
+                       $sql = "SELECT ur_user,ur_rights FROM $user_rights WHERE ur_user=$id FOR UPDATE";
                } else {
-                       $encName = $dbw->strencode( $username );
-                       $sql = "SELECT u.user_id, user_rights FROM $usertable u LEFT JOIN $user_rights r ON u.user_id=r.user_id WHERE user_name = '{$username}' FOR UPDATE";
+                       $sql = "SELECT ur_user, ur_rights FROM $usertable LEFT JOIN $user_rights ON user_id=ur_user WHERE user_name = '{$username}' FOR UPDATE";
                }
                
                $prev = $dbw->ignoreErrors( TRUE );
@@ -163,15 +179,15 @@ class MakesysopForm {
                }
 
                $row = $dbw->fetchObject( $res );
-               $id = intval( $row->user_id );
+               $id = intval( $row->ur_user );
                $rightsNotation = array();
 
                if ( $wgUser->isDeveloper() ) {
                        $newrights = (string)$this->mRights;
                        $rightsNotation[] = "=$this->mRights";
                } else {
-                       if( $row->user_rights ){
-                               $rights = explode(",", $row->user_rights );
+                       if( $row->ur_rights ){
+                               $rights = explode(",", $row->ur_rights );
                                if(! in_array("sysop", $rights ) ){
                                        $rights[] = "sysop";
                                        $rightsNotation[] = "+sysop ";
@@ -196,8 +212,8 @@ class MakesysopForm {
                } else {
                        #$sql = "UPDATE $user_rights SET user_rights = '{$newrights}' WHERE user_id = $id LIMIT 1";
                        #$dbw->query($sql);
-                       $dbw->replace( $user_rights, array( array( 'user_id', 'user_rights' )),
-                               array( 'user_id' => $id, 'user_rights' => $newrights ) , $fname );
+                       $dbw->replace( $user_rights, array( array( 'ur_user', 'ur_rights' )),
+                               array( 'ur_user' => $id, 'ur_rights' => $newrights ) , $fname );
                        $wgMemc->delete( "$dbName:user:id:$id" );
                        
                        $log = new LogPage( 'rights' );
@@ -208,8 +224,7 @@ class MakesysopForm {
                }
        }
 
-       function showSuccess()
-       {
+       function showSuccess() {
                global $wgOut, $wgUser;
 
                $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) );
@@ -225,8 +240,7 @@ class MakesysopForm {
 
        }
 
-       function showFail()
-       {
+       function showFail() {
                global $wgOut, $wgUser;
 
                $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) );