From: Tim Starling Date: Sun, 1 May 2005 12:59:39 +0000 (+0000) Subject: Moving Special:Userlevels and Special:Grouplevels to Special:Userrights and Special... X-Git-Tag: 1.5.0alpha1~39 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=faef2026c9a1efb66d8eea9a706ba1686f203af8;p=lhc%2Fweb%2Fwiklou.git Moving Special:Userlevels and Special:Grouplevels to Special:Userrights and Special:Groups respectively. --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index e1bb1234b3..3ff08b0811 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1,7 +1,7 @@ execute(); -} - -/** - * A class to manage group levels rights. - * @package MediaWiki - * @subpackage SpecialPage - */ -class GrouplevelsForm extends HTMLForm { - var $mPosted, $mRequest, $mSaveprefs; - /** Escaped local url name*/ - var $action; - - /** Constructor*/ - function GrouplevelsForm ( &$request ) { - $this->mPosted = $request->wasPosted(); - $this->mRequest = $request; - $this->mName = 'grouplevels'; - - $titleObj = Title::makeTitle( NS_SPECIAL, 'Grouplevels' ); - $this->action = $titleObj->escapeLocalURL(); - } - - /** - * Manage forms to be shown according to posted datas. - * 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( ); } - - // 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')); - } - } - } - -// 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. - */ - function saveGroup($newname, $oldname, $description, $rights) { - $newame = trim($newname); - - if($oldname == '') { - // We create a new group - $g = new group(); - $g->addToDatabase(); - } else { - $g = Group::newFromName($oldname); - } - - // save stuff - $g->setName($newname); - $g->setDescription($description); - if(isset($rights)) { $g->setRights( implode(',',$rights) ); } - - $g->save(); - - $log = new LogPage( 'rights' ); - $log->addEntry( 'rights', Title::makeTitle( NS_SPECIAL, $g->getName()) , ' '.$g->getRights() ); - - } - - /** - * The entry form - * It allows a user to edit or eventually add a group - */ - function switchForm() { - global $wgOut; - - // group selection - $wgOut->addHTML( "
action\" method=\"post\">\n" ); - $wgOut->addHTML( $this->fieldset( 'lookup-group', - HTMLSelectGroups($this->mName.'-group-edit', array(0 => $this->mRequest->getVal($this->mName.'-group-edit')) ) . - ' ' . - '
' - )); - $wgOut->addHTML( "
\n" ); - } - - /** - * Edit a group properties and rights. - * @param string $groupname Name of a group to be edited. - */ - function editGroupForm($groupID = 0) { - global $wgOut; - - if($this->mRequest->getVal('seditgroup')) { - // fetch data if we edit a group - $g = Group::newFromID($groupID); - $fieldname = 'editgroup'; - } else { - // default datas when we add a group - $g = new group(); - $fieldname = 'addgroup'; - } - - $gName = $g->getName(); - $gDescription = $g->getDescription(); - - - $wgOut->addHTML( "
action\" method=\"post\">\n". - ''); - $wgOut->addHTML( $this->fieldset( $fieldname, - $this->textbox( 'editgroup-name', $gName ) . - $this->textareabox( 'editgroup-description', $gDescription ) . - '
'. - HTMLSelectRights($g->getRights()). - '
'."\n". - '' - )); - - $wgOut->addHTML( "
\n" ); - } -} // end class GrouplevelsForm -?> \ No newline at end of file diff --git a/includes/SpecialGroups.php b/includes/SpecialGroups.php new file mode 100644 index 0000000000..ce617f1af6 --- /dev/null +++ b/includes/SpecialGroups.php @@ -0,0 +1,150 @@ +execute(); +} + +/** + * A class to manage group levels rights. + * @package MediaWiki + * @subpackage SpecialPage + */ +class GroupsForm extends HTMLForm { + var $mPosted, $mRequest, $mSaveprefs; + /** Escaped local url name*/ + var $action; + + /** Constructor*/ + function GroupsForm ( &$request ) { + $this->mPosted = $request->wasPosted(); + $this->mRequest = $request; + $this->mName = 'groups'; + + $titleObj = Title::makeTitle( NS_SPECIAL, 'Groups' ); + $this->action = $titleObj->escapeLocalURL(); + } + + /** + * Manage forms to be shown according to posted datas. + * 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( ); } + + // 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')); + } + } + } + +// 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. + */ + function saveGroup($newname, $oldname, $description, $rights) { + $newame = trim($newname); + + if($oldname == '') { + // We create a new group + $g = new group(); + $g->addToDatabase(); + } else { + $g = Group::newFromName($oldname); + } + + // save stuff + $g->setName($newname); + $g->setDescription($description); + if(isset($rights)) { $g->setRights( implode(',',$rights) ); } + + $g->save(); + + $log = new LogPage( 'rights' ); + $log->addEntry( 'rights', Title::makeTitle( NS_SPECIAL, $g->getName()) , ' '.$g->getRights() ); + + } + + /** + * The entry form + * It allows a user to edit or eventually add a group + */ + function switchForm() { + global $wgOut; + + // group selection + $wgOut->addHTML( "
action\" method=\"post\">\n" ); + $wgOut->addHTML( $this->fieldset( 'lookup-group', + HTMLSelectGroups($this->mName.'-group-edit', array(0 => $this->mRequest->getVal($this->mName.'-group-edit')) ) . + ' ' . + '
' + )); + $wgOut->addHTML( "
\n" ); + } + + /** + * Edit a group properties and rights. + * @param string $groupname Name of a group to be edited. + */ + function editGroupForm($groupID = 0) { + global $wgOut; + + if($this->mRequest->getVal('seditgroup')) { + // fetch data if we edit a group + $g = Group::newFromID($groupID); + $fieldname = 'editgroup'; + } else { + // default datas when we add a group + $g = new group(); + $fieldname = 'addgroup'; + } + + $gName = $g->getName(); + $gDescription = $g->getDescription(); + + + $wgOut->addHTML( "
action\" method=\"post\">\n". + ''); + $wgOut->addHTML( $this->fieldset( $fieldname, + $this->textbox( 'editgroup-name', $gName ) . + $this->textareabox( 'editgroup-description', $gDescription ) . + '
'. + HTMLSelectRights($g->getRights()). + '
'."\n". + '' + )); + + $wgOut->addHTML( "
\n" ); + } +} // end class GroupsForm +?> diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 3d7cba2e8b..05aabb69db 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -49,29 +49,7 @@ $wgSpecialPages = array( 'Lonelypages' => new SpecialPage( 'Lonelypages' ), 'Uncategorizedpages'=> new SpecialPage( 'Uncategorizedpages' ), 'Uncategorizedcategories'=> new SpecialPage( 'Uncategorizedcategories' ), - 'Unusedimages' => new SpecialPage( 'Unusedimages' ) -); - -global $wgUseValidation ; -if ( $wgUseValidation ) - $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' ); - -global $wgDisableCounters; -if( !$wgDisableCounters ) { - $wgSpecialPages['Popularpages'] = new SpecialPage( 'Popularpages' ); -} - -global $wgDisableInternalSearch; -if( !$wgDisableInternalSearch ) { - $wgSpecialPages['Search'] = new UnlistedSpecialPage( 'Search' ); -} - -global $wgEmailAuthentication; -if( $wgEmailAuthentication ) { - $wgSpecialPages['Confirmemail'] = new UnlistedSpecialPage( 'Confirmemail' ); -} - -$wgSpecialPages = array_merge($wgSpecialPages, array ( + 'Unusedimages' => new SpecialPage( 'Unusedimages' ), 'Wantedpages' => new SpecialPage( 'Wantedpages' ), 'Shortpages' => new SpecialPage( 'Shortpages' ), 'Longpages' => new SpecialPage( 'Longpages' ), @@ -99,9 +77,28 @@ $wgSpecialPages = array_merge($wgSpecialPages, array ( 'Lockdb' => new SpecialPage( 'Lockdb', 'siteadmin' ), 'Unlockdb' => new SpecialPage( 'Unlockdb', 'siteadmin' ), # 'Sitesettings' => new SpecialPage( 'Sitesettings', 'siteadmin' ), - 'Userlevels' => new SpecialPage( 'Userlevels', 'userrights' ), - 'Grouplevels' => new SpecialPage( 'Grouplevels', 'grouprights' ), -)); + 'Userrights' => new SpecialPage( 'Userrights', 'userrights' ), + 'Groups' => new SpecialPage( 'Groups', 'grouprights' ), +); + +global $wgUseValidation ; +if ( $wgUseValidation ) + $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' ); + +global $wgDisableCounters; +if( !$wgDisableCounters ) { + $wgSpecialPages['Popularpages'] = new SpecialPage( 'Popularpages' ); +} + +global $wgDisableInternalSearch; +if( !$wgDisableInternalSearch ) { + $wgSpecialPages['Search'] = new UnlistedSpecialPage( 'Search' ); +} + +global $wgEmailAuthentication; +if( $wgEmailAuthentication ) { + $wgSpecialPages['Confirmemail'] = new UnlistedSpecialPage( 'Confirmemail' ); +} /** * Parent special page class, also static functions for handling the special diff --git a/includes/SpecialUserlevels.php b/includes/SpecialUserlevels.php deleted file mode 100644 index 140634759e..0000000000 --- a/includes/SpecialUserlevels.php +++ /dev/null @@ -1,159 +0,0 @@ -execute(); -} - -/** - * A class to manage user levels rights. - * @package MediaWiki - * @subpackage SpecialPage - */ -class UserlevelsForm extends HTMLForm { - var $mPosted, $mRequest, $mSaveprefs; - /** Escaped local url name*/ - var $action; - - /** Constructor*/ - function UserlevelsForm ( &$request ) { - $this->mPosted = $request->wasPosted(); - $this->mRequest = $request; - $this->mName = 'userlevels'; - - $titleObj = Title::makeTitle( NS_SPECIAL, 'Userlevels' ); - $this->action = $titleObj->escapeLocalURL(); - } - - /** - * Manage forms to be shown according to posted datas. - * 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('ssearchuser')) { - $this->editUserGroupsForm( $this->mRequest->getVal('user-editname')); } - - // 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')); - } - } - } - -// save things !! - /** - * Save user groups changes in the database. - * Datas comes from the editUserGroupsForm() form function - * - * @param string $username Username to apply changes to. - * @param array $removegroup id of groups to be removed. - * @param array $addgroup id of groups to be added. - * - * @todo Log groupname instead of group id. - */ - function saveUserGroups($username,$removegroup,$addgroup) { - $u = User::NewFromName($username); - - if(is_null($u)) { - $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); - return; - } - - if($u->getID() == 0) { - $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); - return; - } - - $groups = $u->getGroups(); - $logcomment = ' '; - // remove then add groups - if(isset($removegroup)) { - $groups = array_diff($groups, $removegroup); - $logcomment .= implode( ' -', $removegroup); - } - if(isset($addgroup)) { - $groups = array_merge($groups, $addgroup); - $logcomment .= implode( ' +', $addgroup ); - } - // save groups in user object and database - $u->setGroups($groups); - $u->saveSettings(); - - $log = new LogPage( 'rights' ); - $log->addEntry( 'rights', Title::makeTitle( NS_USER, $u->getName() ), $logcomment ); - } - - /** - * The entry form - * It allows a user to look for a username and edit its groups membership - */ - function switchForm() { - global $wgOut; - - // user selection - $wgOut->addHTML( "
action\" method=\"post\">\n" ); - $wgOut->addHTML( $this->fieldset( 'lookup-user', - $this->textbox( 'user-editname' ) . - '' - )); - $wgOut->addHTML( "
\n" ); - } - - /** - * Edit user groups membership - * @param string $username Name of the user. - */ - function editUserGroupsForm($username) { - global $wgOut; - - $user = User::newFromName($username); - if(is_null($user)) { - $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); - return; - } - - if($user->getID() == 0) { - $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); - return; - } - - $groups = $user->getGroups(); - - $wgOut->addHTML( "
action\" method=\"post\">\n". - ''); - $wgOut->addHTML( $this->fieldset( 'editusergroup', - wfMsg('editing', $this->mRequest->getVal('user-editname')).".
\n" . - '
'. - HTMLSelectGroups($this->mName.'-groupsmember', $groups,true,6). - ''. - HTMLSelectGroups($this->mName.'-groupsavailable', $groups,true,6,true). - '
'."\n". - '

'.wfMsg('userlevels-groupshelp').'

'."\n". - '' - )); - $wgOut->addHTML( "
\n" ); - } -} // end class UserlevelsForm -?> diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php new file mode 100644 index 0000000000..5e96460732 --- /dev/null +++ b/includes/SpecialUserrights.php @@ -0,0 +1,159 @@ +execute(); +} + +/** + * A class to manage user levels rights. + * @package MediaWiki + * @subpackage SpecialPage + */ +class UserrightsForm extends HTMLForm { + var $mPosted, $mRequest, $mSaveprefs; + /** Escaped local url name*/ + var $action; + + /** Constructor*/ + function UserrightsForm ( &$request ) { + $this->mPosted = $request->wasPosted(); + $this->mRequest = $request; + $this->mName = 'userrights'; + + $titleObj = Title::makeTitle( NS_SPECIAL, 'Userrights' ); + $this->action = $titleObj->escapeLocalURL(); + } + + /** + * Manage forms to be shown according to posted datas. + * 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('ssearchuser')) { + $this->editUserGroupsForm( $this->mRequest->getVal('user-editname')); } + + // 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')); + } + } + } + +// save things !! + /** + * Save user groups changes in the database. + * Datas comes from the editUserGroupsForm() form function + * + * @param string $username Username to apply changes to. + * @param array $removegroup id of groups to be removed. + * @param array $addgroup id of groups to be added. + * + * @todo Log groupname instead of group id. + */ + function saveUserGroups($username,$removegroup,$addgroup) { + $u = User::NewFromName($username); + + if(is_null($u)) { + $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); + return; + } + + if($u->getID() == 0) { + $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); + return; + } + + $groups = $u->getGroups(); + $logcomment = ' '; + // remove then add groups + if(isset($removegroup)) { + $groups = array_diff($groups, $removegroup); + $logcomment .= implode( ' -', $removegroup); + } + if(isset($addgroup)) { + $groups = array_merge($groups, $addgroup); + $logcomment .= implode( ' +', $addgroup ); + } + // save groups in user object and database + $u->setGroups($groups); + $u->saveSettings(); + + $log = new LogPage( 'rights' ); + $log->addEntry( 'rights', Title::makeTitle( NS_USER, $u->getName() ), $logcomment ); + } + + /** + * The entry form + * It allows a user to look for a username and edit its groups membership + */ + function switchForm() { + global $wgOut; + + // user selection + $wgOut->addHTML( "
action\" method=\"post\">\n" ); + $wgOut->addHTML( $this->fieldset( 'lookup-user', + $this->textbox( 'user-editname' ) . + '' + )); + $wgOut->addHTML( "
\n" ); + } + + /** + * Edit user groups membership + * @param string $username Name of the user. + */ + function editUserGroupsForm($username) { + global $wgOut; + + $user = User::newFromName($username); + if(is_null($user)) { + $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); + return; + } + + if($user->getID() == 0) { + $wgOut->addHTML('

'.wfMsg('nosuchusershort',$username).'

'); + return; + } + + $groups = $user->getGroups(); + + $wgOut->addHTML( "
action\" method=\"post\">\n". + ''); + $wgOut->addHTML( $this->fieldset( 'editusergroup', + wfMsg('editing', $this->mRequest->getVal('user-editname')).".
\n" . + '
'. + HTMLSelectGroups($this->mName.'-groupsmember', $groups,true,6). + ''. + HTMLSelectGroups($this->mName.'-groupsavailable', $groups,true,6,true). + '
'."\n". + '

'.wfMsg('userrights-groupshelp').'

'."\n". + '' + )); + $wgOut->addHTML( "
\n" ); + } +} // end class UserrightsForm +?> diff --git a/languages/Language.php b/languages/Language.php index 05e7ca32d8..3417b99dcd 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -890,29 +890,29 @@ See [[Project:User preferences help]] for help deciphering the options.", # # switching pan -'grouplevels-lookup-group' => 'Manage group rights', -'grouplevels-group-edit' => 'Existing groups: ', +'groups-lookup-group' => 'Manage group rights', +'groups-group-edit' => 'Existing groups: ', 'editgroup' => 'Edit Group', 'addgroup' => 'Add Group', -'userlevels-lookup-user' => 'Manage user groups', -'userlevels-user-editname' => 'Enter a username: ', +'userrights-lookup-user' => 'Manage user groups', +'userrights-user-editname' => 'Enter a username: ', 'editusergroup' => 'Edit User Groups', # group editing -'grouplevels-editgroup' => 'Edit group', -'grouplevels-addgroup' => 'Add group', -'grouplevels-editgroup-name' => 'Group name: ', -'grouplevels-editgroup-description' => 'Group description (max 255 characters):
', +'groups-editgroup' => 'Edit group', +'groups-addgroup' => 'Add group', +'groups-editgroup-name' => 'Group name: ', +'groups-editgroup-description' => 'Group description (max 255 characters):
', 'savegroup' => 'Save Group', # user groups editing # -'userlevels-editusergroup' => 'Edit user groups', +'userrights-editusergroup' => 'Edit user groups', 'saveusergroups' => 'Save User Groups', -'userlevels-groupsmember' => 'Member of:', -'userlevels-groupsavailable' => 'Available groups:', -'userlevels-groupshelp' => 'Select groups you want the user to be removed from or added to. +'userrights-groupsmember' => 'Member of:', +'userrights-groupsavailable' => 'Available groups:', +'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', # Recent changes @@ -1140,8 +1140,8 @@ in active use.

', 'booksources' => 'Book sources', 'categoriespagetext' => 'The following categories exist in the wiki.', 'data' => 'Data', -'userlevels' => 'User rights management', -'grouplevels' => 'User group management', +'userrights' => 'User rights management', +'groups' => 'User groups', # FIXME: Other sites, of course, may have affiliate relations with the booksellers list 'booksourcetext' => "Below is a list of links to other sites that