From: Roan Kattouw Date: Wed, 21 Nov 2007 20:15:35 +0000 (+0000) Subject: APIEDIT BRANCH MERGE: X-Git-Tag: 1.31.0-rc.0~50757 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=e40349e829c98a26316dcb12ade8f4ce00f2d25c;p=lhc%2Fweb%2Fwiklou.git APIEDIT BRANCH MERGE: * Splitting DB code from UserrightsForm::saveUserGroups() to UserrightsForm:doSaveUserGroups() * Making UserrightsForm::changeableGroups() public so the API module can call it --- diff --git a/includes/SpecialUserrights.php b/includes/SpecialUserrights.php index b9815fd4d4..a2a877bd69 100644 --- a/includes/SpecialUserrights.php +++ b/includes/SpecialUserrights.php @@ -64,30 +64,15 @@ class UserrightsForm extends HTMLForm { } } - /** - * Save user groups changes in the database. - * Data 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. - * @param string $reason Reason for group change - * + /** Back-end for saveUserGroups() + * @param User $u + * @param array $removegroup + * @param array $addgroup + * @param string $reason */ - function saveUserGroups( $username, $removegroup, $addgroup, $reason = '' ) { - global $wgOut; - $u = User::newFromName($username); - - if(is_null($u)) { - $wgOut->addWikiText( wfMsg( 'nosuchusershort', htmlspecialchars( $username ) ) ); - return; - } - - if($u->getID() == 0) { - $wgOut->addWikiText( wfMsg( 'nosuchusershort', htmlspecialchars( $username ) ) ); - return; - } + function doSaveUserGroups($u, $removegroup, $addgroup, $reason) + { $oldGroups = $u->getGroups(); $newGroups = $oldGroups; // remove then add groups @@ -118,6 +103,29 @@ class UserrightsForm extends HTMLForm { $this->makeGroupNameList( $newGroups ) ) ); } + /** + * Save user groups changes in the database. + * Data 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. + * @param string $reason Reason for group change + * + */ + function saveUserGroups( $username, $removegroup, $addgroup, $reason = '' ) { + global $wgOut; + $u = User::newFromName($username); + if(is_null($u)) { + $wgOut->addWikiText( wfMsg( 'nosuchusershort', htmlspecialchars( $username ) ) ); + } + if($u->getID() == 0) { + $wgOut->addWikiText( wfMsg( 'nosuchusershort', htmlspecialchars( $username ) ) ); + } + + $this->doSaveUserGroups($u, $removegroup, $addgroup, $reason); + } + function makeGroupNameList( $ids ) { return implode( ', ', $ids ); } @@ -318,7 +326,7 @@ class UserrightsForm extends HTMLForm { * * @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) ) */ - private function changeableGroups() { + function changeableGroups() { global $wgUser; $groups = array( 'add' => array(), 'remove' => array() );