Major changes to user groups:
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 1 May 2005 18:24:20 +0000 (18:24 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 1 May 2005 18:24:20 +0000 (18:24 +0000)
* Added "static groups" feature to remove memcached/DB load time
* Added i18n support, allowing names and descriptions to be optionally drawn from wfMsg/wfMsgForContent
* Fixed Special:Groups, it is now half-decent. Too many changes to list here.

includes/DefaultSettings.php
includes/Group.php
includes/HTMLForm.php
includes/LogPage.php
includes/SpecialGroups.php
includes/SpecialPage.php
includes/SpecialUserrights.php
includes/User.php
languages/Language.php
maintenance/archives/patch-userlevels-defaultgroups.sql

index 859f549..47ea2bd 100644 (file)
@@ -541,6 +541,14 @@ $wgBlockExpiryOptions = "2 hours,1 day,3 days,1 week,2 weeks,1 month,3 months,6
 
 $wgAutoblockExpiry             = 86400; # Number of seconds before autoblock entries expire
 
+/**
+ * Static user groups serialized record
+ * To avoid database access, you can set this to a user groups record as returned 
+ * by Special:Groups with the magic parameter showrecord=1. This will however mean 
+ * that you won't be able to edit them at runtime.
+ */
+$wgStaticGroups = false;
+
 # Proxy scanner settings
 #
 
index 88b5166..0377616 100644 (file)
@@ -41,40 +41,74 @@ class Group {
        function loadFromDatabase() {
                global $wgCommandLineMode;
                $fname = 'Group::loadFromDatabase';
+
+               // See if it's already loaded
                if ( $this->dataLoaded || $wgCommandLineMode ) {
                        return;
                }
 
+               // If we're using static groups, don't touch the database, use the 
+               // internal arrays
+               $staticGroups =& Group::getStaticGroups();
+               if ( $staticGroups ) {
+                       if ( $this->id ) {
+                               $this = $staticGroups[$this->id];
+                       } else {
+                               $this->id = Group::idFromName( $this->name );
+                               $this = $staticGroups[$this->id];
+                       }
+                       return;
+               }
+
+               // Now go for the database
+
                // be sure it's an integer
                $this->id = IntVal($this->id);
                
                if($this->id) {
+                       // By ID
                        $dbr =& wfGetDB( DB_SLAVE );
                        $r = $dbr->selectRow('group',
                                array('group_id', 'group_name', 'group_description', 'group_rights'),
                                array( 'group_id' => $this->id ),
                                $fname );
-                       $this->id = $r->group_id;
-                       $this->name = $r->group_name;
-                       $this->description = $r->group_description;
-                       $this->rights = $r->group_rights;
-                       $this->dataLoaded = true;
+                       if ( $r ) {
+                               $this->loadFromRow( $r );
+                       } else {
+                               $this->id = 0;
+                               $this->dataLoaded = true;
+                       }
                } else {
+                       // By name
                        $dbr =& wfGetDB( DB_SLAVE );
                        $r = $dbr->selectRow('group',
                                array('group_id', 'group_name', 'group_description', 'group_rights'),
                                array( 'group_name' => $this->name ),
                                $fname );
-                       $this->id = $r->group_id;
-                       $this->name = $r->group_name;
-                       $this->description = $r->group_description;
-                       $this->rights = $r->group_rights;
-                       $this->dataLoaded = true;
+                       if ( $r ) {
+                               $this->loadFromRow( $r );
+                       } else {
+                               $this->id = 0;
+                               $this->dataLoaded = true;
+                       }
                }
        }
+
+       /** Initialise from a result row */
+       function loadFromRow( &$row ) {
+               $this->id = $row->group_id;
+               $this->name = $row->group_name;
+               $this->description = $row->group_description;
+               $this->rights = $row->group_rights;
+               $this->dataLoaded = true;
+       }               
        
        /** Initialise a new row in the database */
        function addToDatabase() {
+               if ( Group::getStaticGroups() ) {
+                       wfDebugDieBacktrace( "Can't modify groups in static mode" );
+               }
+
                $fname = 'Group::addToDatabase';
                $dbw =& wfGetDB( DB_MASTER );
                $dbw->insert( 'group',
@@ -89,9 +123,12 @@ class Group {
 
        /** Save the group datas into database */
        function save() {
-               $fname = 'Group::save';
+               if ( Group::getStaticGroups() ) {
+                       wfDebugDieBacktrace( "Can't modify groups in static mode" );
+               }
                if($this->id == 0) { return; }
-
+               
+               $fname = 'Group::save';
                $dbw =& wfGetDB( DB_MASTER );
                
                $dbw->update( 'group',
@@ -104,6 +141,23 @@ class Group {
                        ), $fname
                );              
        }
+
+       /** Delete a group */
+       function delete() {
+               if ( Group::getStaticGroups() ) {
+                       wfDebugDieBacktrace( "Can't modify groups in static mode" );
+               }
+               if($this->id == 0) { return; }
+               
+               $fname = 'Group::delete';
+               $dbw =& wfGetDB( DB_MASTER );
+
+               // First remove all users from the group
+               $dbw->delete( 'user_group', array( 'ug_group' => $this->id ), $fname );
+
+               // Now delete the group
+               $dbw->delete( 'group', array( 'group_id' => $this->id ), $fname );
+       }
        
 // Factories
        /**
@@ -114,27 +168,31 @@ class Group {
                global $wgMemc, $wgDBname;
                $fname = 'Group::newFromId';
                
+               $staticGroups =& Group::getStaticGroups();
+               if ( $staticGroups ) {
+                       if ( array_key_exists( $id, $staticGroups ) ) {
+                               return $staticGroups[$id];
+                       } else {
+                               return null;
+                       }
+               }
+
                $key = "$wgDBname:groups:id:$id";
                if( $group = $wgMemc->get( $key ) ) {
                        wfDebug( "$fname loaded group $id from cache\n" );
                        return $group;
                }
                
-               $g = new Group();
-               $name = $g->nameFromId(IntVal($id));
+               $group = new Group();
+               $group->id = $id;
+               $group->loadFromDatabase();
 
-               if($name == '') {
+               if ( !$group->id ) {
                        wfDebug( "$fname can't find group $id\n" );
                        return null;
                } else {
-                       $group = $g->newFromName($name);
-                       if( $group ) {
-                               wfDebug( "$fname caching group $id (name $name)\n" );
-                               $group->loadFromDatabase();
-                               $wgMemc->add( $key, $group, 3600 );
-                       } else {
-                               wfDebug( "$fname failed to laod group id $d (name $name)\n" );
-                       }
+                       wfDebug( "$fname caching group $id (name {$group->name})\n" );
+                       $wgMemc->add( $key, $group, 3600 );
                        return $group;
                }
        }
@@ -144,30 +202,77 @@ class Group {
        function newFromName($name) {
                $fname = 'Group::newFromName';
                $g = new Group();
-               
-               $g->setId( $g->idFromName($name) );
+               $g->name = $name;
+               $g->loadFromDatabase();
+
                if( $g->getId() != 0 ) {
                        return $g;
                } else { 
-                       return;
+                       return null;
                }
        }
 
+       /**
+        * Get an array of Group objects, one for each valid group
+        * 
+        * @static
+        */
+       function &getAllGroups() {
+               $staticGroups =& Group::getStaticGroups();
+               if ( $staticGroups ) {
+                       return $staticGroups;
+               }
+
+               $fname = 'Group::getAllGroups';
+               wfProfileIn( $fname );
+
+               $dbr =& wfGetDB( DB_SLAVE );
+               $groupTable = $dbr->tableName( 'group' );
+               $sql = "SELECT group_id, group_name, group_description, group_rights FROM $groupTable";
+               $res = $dbr->query($sql, $fname);
+
+               $groups = array();
+
+               while($row = $dbr->fetchObject( $res ) ) {
+                       $group = new Group;
+                       $group->loadFromRow( $row );
+                       $groups[$row->group_id] = $group;
+               }
+
+               wfProfileOut( $fname );
+               return $groups;
+       }
+
+       /** 
+        * Get static groups, if they have been defined in LocalSettings.php
+        * 
+        * @static
+        */
+       function &getStaticGroups() {
+               global $wgStaticGroups;
+               if ( $wgStaticGroups === false ) {
+                       return $wgStaticGroups;
+               }
+
+               if ( !is_array( $wgStaticGroups ) ) {
+                       $wgStaticGroups = unserialize( $wgStaticGroups );
+               }
+
+               return $wgStaticGroups;
+       }
+
+
 // Converters
        /**
         * @param integer $id Group database id
         * @return string Group database name
         */
        function nameFromId($id) {
-               $fname = 'Group::nameFromId';
-               $dbr =& wfGetDB( DB_SLAVE );
-               $r = $dbr->selectRow( 'group', array( 'group_name' ), array( 'group_id' => $id ), $fname );
-               if ($dbr == null)
-                       return;         
-               if($r === false) {
+               $group = Group::newFromId( $id );
+               if ( is_null( $group ) ) {
                        return '';
                } else {
-                       return $r->group_name;
+                       return $group->getName();
                }
        }
 
@@ -177,6 +282,18 @@ class Group {
         */
        function idFromName($name) {
                $fname = 'Group::idFromName';
+
+               $staticGroups =& Group::getStaticGroups();
+               if ( $staticGroups ) {
+                       foreach( $staticGroups as $id => $group ) {
+                               if ( $group->getName() === $name ) {
+                                       return $group->getID();
+                               }
+                       }
+                       return 0;
+               }
+
+
                $dbr =& wfGetDB( DB_SLAVE );
                $r = $dbr->selectRow( 'group', array( 'group_id' ), array( 'group_name' => $name ), $fname );
 
@@ -191,7 +308,18 @@ class Group {
        function getName() {
                $this->loadFromDatabase();
                return $this->name;
-               }
+       }
+
+       function getExpandedName() { 
+               $this->loadFromDatabase();
+               return $this->getMessage( $this->name );
+       }
+       
+       function getNameForContent() {
+               $this->loadFromDatabase();
+               return $this->getMessageForContent( $this->name );
+       }
+
        function setName($name) {
                $this->loadFromDatabase();
                $this->name = $name;
@@ -201,9 +329,16 @@ class Group {
        function setId($id) {
                $this->id = IntVal($id);
                $this->dataLoaded = false;
-               }
+       }
        
-       function getDescription() { return $this->description; }
+       function getDescription() { 
+               return $this->description;
+       }
+
+       function getExpandedDescription() {
+               return $this->getMessage( $this->description );
+       }
+
        function setDescription($desc) {
                $this->loadFromDatabase();
                $this->description = $desc;
@@ -214,5 +349,28 @@ class Group {
                $this->loadFromDatabase();
                $this->rights = $rights;
        }
+
+       /** 
+        * Gets a message if the text starts with a colon, otherwise returns the text itself
+        */
+       function getMessage( $text ) {
+               if ( strlen( $text ) && $text{0} == ':' ) {
+                       return wfMsg( substr( $text, 1 ) );
+               } else {
+                       return $text;
+               }
+       }
+
+       /**
+        * As for getMessage but for content
+        */
+       function getMessageForContent( $text ) {
+               if ( strlen( $text ) && $text{0} == ':' ) {
+                       return wfMsgForContent( substr( $text, 1 ) );
+               } else {
+                       return $text;
+               }
+       }
+
 }
-?>
\ No newline at end of file
+?>
index 3ff08b0..54bbb81 100644 (file)
@@ -95,34 +95,33 @@ class HTMLForm {
 } // end class
 
 
-/** Build a select with all existent groups
+// functions used by SpecialUserrights.php and SpecialGroups.php
+
+/** Build a select with all defined groups
  * @param string $selectname Name of this element. Name of form is automaticly prefixed.
  * @param array $selected Array of element selected when posted. Multiples will only show them.
  * @param boolean $multiple A multiple elements select.
  * @param integer $size Number of element to be shown ignored for non multiple (default 6).
  * @param boolean $reverse If true, multiple select will hide selected elements (default false).
 */
-function HTMLSelectGroups($selectname, $selected=array(), $multiple=false, $size=6, $reverse=false) {
-       $dbr =& wfGetDB( DB_SLAVE );
-       $group = $dbr->tableName( 'group' );
-       $sql = "SELECT group_id, group_name FROM $group";
-       $res = $dbr->query($sql,'wfSpecialAdmin');
+function HTMLSelectGroups($selectname, $selectmsg, $selected=array(), $multiple=false, $size=6, $reverse=false) {
+       $groups =& Group::getAllGroups();
        
-       $out = wfMsg($selectname);
+       $out = wfMsg($selectmsg);
        $out .= '<select name="'.$selectname;
        if($multiple) { $out.='[]" multiple="multiple" size="'.$size; }
        $out.= "\">\n";
        
-       while($g = $dbr->fetchObject( $res ) ) {
+       foreach ( $groups as $id => $g ) {
                if($multiple) {
                        // for multiple will only show the things we want
-                       if(in_array($g->group_id, $selected) xor $reverse) { 
-                               $out .= '<option value="'.$g->group_id.'">'.$g->group_name."</option>\n";
+                       if(in_array($id, $selected) xor $reverse) { 
+                               $out .= '<option value="'.$id.'">'.$g->getExpandedName()."</option>\n";
                        }
                } else {
                        $out .= '<option ';
-                       if(in_array($g->group_id, $selected)) { $out .= 'selected="selected" '; }
-                       $out .= 'value="'.$g->group_id.'">'.$g->group_name."</option>\n";
+                       if(in_array($id, $selected)) { $out .= 'selected="selected" '; }
+                       $out .= 'value="'.$id.'">'.$g->getExpandedName()."</option>\n";
                }
        }
        $out .= "</select>\n";
index a94f965..1345503 100644 (file)
@@ -149,6 +149,9 @@ class LogPage {
                        'protect/protect' => 'protectedarticle',
                        'protect/unprotect' => 'unprotectedarticle',
                        'rights/rights' => 'bureaucratlogentry',
+            'rights/addgroup' => 'addgrouplogentry',
+            'rights/rngroup' => 'renamegrouplogentry',
+            'rights/chgroup' => 'changegrouplogentry',
                        'delete/delete' => 'deletedarticle',
                        'delete/restore' => 'undeletedarticle',
                        'upload/upload' => 'uploadedimage',
@@ -200,8 +203,6 @@ class LogPage {
         * @param array $params Parameters passed later to wfMsg.* functions
         */
        function addEntry( $action, &$target, $comment, $params = array() ) {
-               global $wgLang, $wgUser;
-               
                if ( !is_array( $params ) ) {
                        $params = array( $params );
                }
index ce617f1..cf49628 100644 (file)
@@ -25,18 +25,41 @@ function wfSpecialGroups($par=null) {
  * @subpackage SpecialPage
  */
 class GroupsForm extends HTMLForm {
-       var $mPosted, $mRequest, $mSaveprefs;
+       var $mPosted, $mRequest, $mSaveprefs, $mChangeAllowed;
+       var $mNewName, $mDescription, $mOldName, $mRights, $mId;
+       var $mAdd, $mEdit;
+       
        /** Escaped local url name*/
-       var $action;
+       var $action, $location;
 
        /** Constructor*/
        function GroupsForm ( &$request ) {
+               global $wgUser;
+               
                $this->mPosted = $request->wasPosted();
                $this->mRequest = $request;
                $this->mName = 'groups';
-               
+
+               $this->mNewName = trim( $request->getText('editgroup-name') );
+               $this->mOldName = trim( $request->getText('editgroup-oldname' ) );
+               $this->mDescription = trim( $request->getText( 'editgroup-description' ) );
+               $this->mRights = $request->getArray( 'editgroup-getrights' );
+               $this->mId = $this->mRequest->getInt('id');
+               $this->mEdit = $request->getCheck('edit');
+               $this->mAdd = $request->getCheck('add');
+
+
                $titleObj = Title::makeTitle( NS_SPECIAL, 'Groups' );
                $this->action = $titleObj->escapeLocalURL();
+               if ( $this->mAdd ) {
+                       $this->location = $titleObj->getLocalURL( "add=1&id={$this->mId}" );
+               } elseif ( $this->mEdit ) {
+                       $this->location = $titleObj->getLocalURL( "edit=1&id={$this->mId}" );
+               } else {
+                       $this->location = $this->action;
+               }
+
+               $this->mChangeAllowed = $wgUser->isAllowed( 'grouprights' ) && !Group::getStaticGroups();
        }
 
        /**
@@ -44,55 +67,99 @@ class GroupsForm extends HTMLForm {
         * Depending on the submit button used : Call a form or a saving function.
         */
        function execute() {
-               // show the general form
-               $this->switchForm();
-               if ( $this->mPosted ) {
-                       // show some more forms
-                       if($this->mRequest->getCheck('seditgroup')) {
-                               $this->editGroupForm( $this->mRequest->getVal($this->mName.'-group-edit') ); }
-                       if($this->mRequest->getCheck('saddgroup')) {
-                               $this->editGroupForm( ); }
+               global $wgOut;
 
+               if ( $this->mRequest->getBool( 'showrecord' ) ) {
+                       $this->showRecord();
+               } elseif ( $this->mPosted && $this->mChangeAllowed && $this->mRequest->getCheck('savegroup') ) {
                        // save settings
-                       if($this->mRequest->getCheck('savegroup')) {
-                               $this->saveGroup($this->mRequest->getVal('editgroup-name'),
-                                                $this->mRequest->getVal('editgroup-oldname'),
-                                                $this->mRequest->getVal('editgroup-description'),
-                                                                $this->mRequest->getArray('editgroup-getrights'));
+                       $this->saveGroup();
+               } elseif ( $this->mEdit ) {
+                       if ( $this->mPosted ) {
+                               $wgOut->redirect( $this->location );
+                       } else {                        
+                               $this->switchForm();
+                               $this->editGroupForm( $this->mId ); 
+                       }
+               } elseif ( $this->mAdd ) {
+                       if ( $this->mPosted ) {
+                               $wgOut->redirect( $this->location );
+                       } else {
+                               $this->switchForm();
+                               $this->editGroupForm( ); 
+                       }
+               } else {
+                       $this->showAllGroups();
+                       if ( $this->mChangeAllowed ) {
+                               $this->switchForm();
                        }
                }
        }
 
-// save things !!
        /**
         * Save a group
-        * @param string $newname Group name.
-        * @param string $oldname Old (current) group name.
-        * @param string $description Group description.
-        *
-        * @todo FIXME : doesnt validate anything. Log is incorrect.
+        * @todo FIXME : Log is incorrect.
         */
-       function saveGroup($newname, $oldname, $description, $rights) {
-               $newame = trim($newname);
+       function saveGroup() {
+               global $wgOut;
+
+               $this->mNewName = trim($this->mNewName);
        
-               if($oldname == '') {
-               // We create a new group
+               if ( $this->mNewName == '' ) {
+                       $this->editGroupForm( $this->mGroupID, 'groups-noname' );
+                       return false;
+               }
+
+               if($this->mOldName == '') {
+                       // Check if the group already exists
+                       $add = true;
+                       $g = Group::newFromName( $this->mNewName );
+                       if ( $g ) {
+                               $this->editGroupForm( 0, 'groups-already-exists' );
+                               return;
+                       }
+
+                       // Create a new group
                        $g = new group();
                        $g->addToDatabase();
                } else {
-                       $g = Group::newFromName($oldname);
+                       $add = false;
+                       $g = Group::newFromName($this->mOldName);
+                       if ( !$g ) {
+                               $this->editGroupForm( 0, 'groups-noname' );
+                               return;
+                       }
                }
                
                // save stuff
-               $g->setName($newname);
-               $g->setDescription($description);
-               if(isset($rights)) { $g->setRights( implode(',',$rights) ); }
+               $g->setName($this->mNewName);
+               $g->setDescription($this->mDescription);
+               if( is_array( $this->mRights ) ) { 
+                       $g->setRights( implode(',',$this->mRights) ); 
+               }
                
                $g->save();
-
+               
+               // Make the log entry
                $log = new LogPage( 'rights' );
-               $log->addEntry( 'rights', Title::makeTitle( NS_SPECIAL, $g->getName()) , ' '.$g->getRights() );
+               $dummyTitle = Title::makeTitle( 0, '' );
+               if ( $add ) {
+                       $log->addEntry( 'addgroup', $dummyTitle, '', array( $g->getNameForContent() ) );
+               } else {
+                       if ( $this->mOldName != $this->mNewName ) {
+                               // Abbreviated action name, must be less than 10 bytes
+                               $log->addEntry( 'rngroup', $dummyTitle, '', array( Group::getMessageForContent( $this->mOldName ), 
+                               $g->getNameForContent() ) );
+                       } else {
+                               $log->addEntry( 'chgroup', $dummyTitle, '', array( $g->getNameForContent() ) );
+                       }
+               }
 
+               // Success, go back to all groups page
+               $titleObj = Title::makeTitle( NS_SPECIAL, 'Groups' );
+               $url = $titleObj->getLocalURL();
+
+               $wgOut->redirect( $url );
        }
 
        /**
@@ -105,9 +172,9 @@ class GroupsForm extends HTMLForm {
                // group selection              
                $wgOut->addHTML( "<form name=\"ulgroup\" action=\"$this->action\" method=\"post\">\n" );
                $wgOut->addHTML( $this->fieldset( 'lookup-group',
-                               HTMLSelectGroups($this->mName.'-group-edit', array(0 => $this->mRequest->getVal($this->mName.'-group-edit')) ) .
-                               ' <input type="submit" name="seditgroup" value="'.wfMsg('editgroup').'" />' .
-                               '<br /><input type="submit" name="saddgroup" value="'.wfMsg('addgroup').'" />'
+                               HTMLSelectGroups('id', $this->mName.'-group-edit', array(0 => $this->mRequest->getVal('id')) ) .
+                               ' <input type="submit" name="edit" value="'.wfMsg('editgroup').'" />' .
+                               '<br /><input type="submit" name="add" value="'.wfMsg('addgroup').'" />'
                        ));
                $wgOut->addHTML( "</form>\n" );
        }
@@ -115,11 +182,17 @@ class GroupsForm extends HTMLForm {
        /**
         * Edit a group properties and rights.
         * @param string $groupname Name of a group to be edited.
+        * @param string $error message name of the error to display
         */
-       function editGroupForm($groupID = 0) {
+       function editGroupForm($groupID = 0, $error = '') {
                global $wgOut;
 
-               if($this->mRequest->getVal('seditgroup')) {
+               if ( $error ) {
+                       $errText = wfMsg( $error );
+                       $wgOut->addHTML( "<p class='error'>$errText</p>" );
+               }
+
+               if($this->mRequest->getVal('edit')) {
                // fetch data if we edit a group
                        $g = Group::newFromID($groupID);
                        $fieldname = 'editgroup';
@@ -134,8 +207,10 @@ class GroupsForm extends HTMLForm {
 
 
                $wgOut->addHTML( "<form name=\"editGroup\" action=\"$this->action\" method=\"post\">\n".
-                               '<input type="hidden" name="editgroup-oldname" value="'.$gName.'" />');
+                               '<input type="hidden" name="editgroup-oldname" value="'.$gName."\" />\n" );
+
                $wgOut->addHTML( $this->fieldset( $fieldname,
+                       '<p>' . wfMsg( 'groups-editgroup-preamble' ) . "</p>\n" .
                        $this->textbox( 'editgroup-name', $gName ) .
                        $this->textareabox( 'editgroup-description', $gDescription ) .
                        '<br /><table border="0" align="center"><tr><td>'.
@@ -146,5 +221,45 @@ class GroupsForm extends HTMLForm {
 
                $wgOut->addHTML( "</form>\n" );
        }
+
+       function showAllGroups() {
+               global $wgOut;
+               $groups =& Group::getAllGroups();
+
+               $groupsExisting = wfMsg( 'groups-existing' );
+               $groupsHeader = wfMsg( 'groups-tableheader' );
+
+               $s = "{| border=1
+|+'''$groupsExisting'''
+|-
+!$groupsHeader
+";
+               foreach ( $groups as $group ) {
+                       $s .= "|-\n| " . $group->getId() . ' || ' .
+                               $group->getExpandedName() . ' || ' .
+                               $group->getExpandedDescription() . ' || '. 
+                               // Insert spaces to make it wrap
+                               str_replace( ',', ', ', $group->getRights() ) . "\n";
+               }
+               $s .= "|}\n";
+               $wgOut->addWikiText( $s );
+       }
+               
+       function showRecord() {
+               global $wgOut;
+               
+               $groups =& Group::getAllGroups();
+               $rec = serialize( $groups );
+               // Escape it for PHP
+               $rec = str_replace( array( '\\', "'" ), array( '\\\\', "\\'" ), $rec );
+               // Escape it for HTML
+               $rec = htmlspecialchars( $rec );
+               $s = "<p>Copy the following into LocalSettings.php:</p>\n" .
+                 "<textarea readonly rows=20>\n" .
+                 "\$wgStaticGroups = '$rec';\n" .
+                 "</textarea>";
+               $wgOut->addHTML( $s );
+       }
+
 } // end class GroupsForm
 ?>
index 05aabb6..7c2cb87 100644 (file)
@@ -78,7 +78,7 @@ $wgSpecialPages = array(
        'Unlockdb'              => new SpecialPage( 'Unlockdb', 'siteadmin' ),
 #      'Sitesettings'  => new SpecialPage( 'Sitesettings', 'siteadmin' ),
        'Userrights'    => new SpecialPage( 'Userrights', 'userrights' ),
-       'Groups'                => new SpecialPage( 'Groups', 'grouprights' ),
+       'Groups'                => new SpecialPage( 'Groups' ),
 );
 
 global $wgUseValidation ;
index 5e96460..c04c3e9 100644 (file)
@@ -56,8 +56,8 @@ class UserrightsForm extends HTMLForm {
                        // save settings
                        if($this->mRequest->getCheck('saveusergroups')) {
                                $this->saveUserGroups($this->mRequest->getVal('user-editname'),
-                                                     $this->mRequest->getArray($this->mName.'-groupsmember'),
-                                                     $this->mRequest->getArray($this->mName.'-groupsavailable'));
+                                                     $this->mRequest->getArray('member'),
+                                                     $this->mRequest->getArray('available'));
                        }
                }
        }
@@ -146,9 +146,9 @@ class UserrightsForm extends HTMLForm {
                $wgOut->addHTML( $this->fieldset( 'editusergroup',
                        wfMsg('editing', $this->mRequest->getVal('user-editname')).".<br />\n" .
                        '<table border="0" align="center"><tr><td>'.
-                       HTMLSelectGroups($this->mName.'-groupsmember', $groups,true,6).
+                       HTMLSelectGroups('member', $this->mName.'-groupsmember', $groups,true,6).
                        '</td><td>'.
-                       HTMLSelectGroups($this->mName.'-groupsavailable', $groups,true,6,true).
+                       HTMLSelectGroups('available', $this->mName.'-groupsavailable', $groups,true,6,true).
                        '</td></tr></table>'."\n".
                        '<p>'.wfMsg('userrights-groupshelp').'</p>'."\n".
                        '<input type="submit" name="saveusergroups" value="'.wfMsg('saveusergroups').'" />'
index 69a8fae..35cfca3 100644 (file)
@@ -806,10 +806,6 @@ class User {
         */
        function isBot() {
                $this->loadFromDatabase();
-
-               # Why was this here? I need a UID=0 conversion script [TS]
-               # if ( 0 == $this->mId ) { return false; }
-
                return in_array( 'bot', $this->mRights );
        }
 
index 3417b99..e1f5947 100644 (file)
@@ -900,11 +900,21 @@ See [[Project:User preferences help]] for help deciphering the options.",
 'editusergroup' => 'Edit User Groups',
 
 # group editing
-'groups-editgroup' => 'Edit group',
-'groups-addgroup' => 'Add group',
-'groups-editgroup-name' => 'Group name: ',
+'groups-editgroup'          => 'Edit group',
+'groups-addgroup'           => 'Add group',
+'groups-editgroup-preamble' => 'If the name or description starts with a colon, the 
+remainder will be treated as a message name, and hence the text will be localised 
+using the MediaWiki namespace',
+'groups-editgroup-name'     => 'Group name: ',
 'groups-editgroup-description' => 'Group description (max 255 characters):<br />',
-'savegroup' => 'Save Group',
+'savegroup'                 => 'Save Group',
+'groups-tableheader'        => 'ID || Name || Description || Rights',
+'groups-existing'           => 'Existing groups',
+'groups-noname'             => 'Please specify a valid group name',
+'groups-already-exists'     => 'A group of that name already exists',
+'addgrouplogentry'          => 'Added group $2',
+'changegrouplogentry'       => 'Changed group $2',
+'renamegrouplogentry'       => 'Renamed group $2 to $3',
 
 # user groups editing
 #
@@ -915,6 +925,20 @@ See [[Project:User preferences help]] for help deciphering the options.",
 'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to.
 Unselected groups will not be changed. You can deselect a group with CTRL + Left Click',
 
+# Default group names and descriptions
+# 
+'group-anon-name'       => 'Anonymous',
+'group-anon-desc'       => 'Anonymous users',
+'group-loggedin-name'   => 'Logged in',
+'group-loggedin-desc'   => 'General logged in users',
+'group-admin-name'      => 'Administrator',
+'group-admin-desc'      => 'Trusted users able to block users and delete articles',
+'group-bureaucrat-name' => 'Bureaucrat',
+'group-bureaucrat-desc' => 'The bureaucrat group is able to make sysops',
+'group-steward-name'    => 'Steward',
+'group-steward-desc'    => 'Full access',
+
+
 # Recent changes
 #
 'changes' => 'changes',
index c4edb8e..ef1ef68 100644 (file)
@@ -5,26 +5,26 @@
 
 INSERT INTO /*$wgDBprefix*/`group` (group_id,group_name,group_description,group_rights)
        VALUES (
-               1,'Anonymous','Anonymous users',
+               1,':group-anon-name',':group-anon-desc',
                'read,edit,createaccount'
        );
 INSERT INTO /*$wgDBprefix*/`group` (group_id,group_name,group_description,group_rights)
        VALUES (
-               2,'Logged in','General logged in users',
+               2,':group-loggedin-name',':group-loggedin-desc',
                'read,edit,move,upload,validate,createaccount'
        );
 INSERT INTO /*$wgDBprefix*/`group` (group_id,group_name,group_description,group_rights)
        VALUES (
-               3,'Administrator','Trusted users able to block users and delete articles',
+               3,':group-admin-name',':group-loggedin-desc',
                'read,edit,move,upload,validate,createaccount,delete,undelete,protect,block,upload,asksql,rollback,patrol,editinterface,import,sysop'
        );
 INSERT INTO /*$wgDBprefix*/`group` (group_id,group_name,group_description,group_rights)
        VALUES (
-               4,'Bureaucrat','The bureaucrat group is able to make sysops. They have no other rights.',
+               4,':group-bureaucrat-name',':group-bureaucrat-desc',
                'read,edit,move,upload,validate,createaccount,delete,undelete,protect,block,upload,asksql,rollback,patrol,editinterface,import,sysop,makesysop'
        );
 INSERT INTO /*$wgDBprefix*/`group` (group_id,group_name,group_description,group_rights)
        VALUES (
-               5,'Steward','Full access',
+               5,':group-steward-name',':group-steward-desc',
                'read,edit,move,upload,validate,createaccount,delete,undelete,protect,block,upload,asksql,rollback,patrol,editinterface,import,sysop,makesysop,userrights,grouprights,siteadmin'
        );