r23503 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23502‎ | r23503 | r23504 >
Date:13:42, 28 June 2007
Author:brion
Status:old
Tags:
Comment:
Tweak API change which broke Makesysop extension. Same functionality, now in compatible API.
* use protected, not private, so subclass can still call showEditUserGroupsForm()
* restore compatible parameters to showEditUserGroupsForm()
* encapsulate the filtering of available groups into splitGroups(), so caller doesn't have to do it
Modified paths:
  • /trunk/phase3/includes/SpecialUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUserrights.php
@@ -153,11 +153,23 @@
154154 return;
155155 }
156156
 157+ $this->showEditUserGroupsForm( $username, $user->getGroups() );
 158+ }
 159+
 160+ /**
 161+ * Go through used and available groups and return the ones that this
 162+ * form will be able to manipulate based on the current user's system
 163+ * permissions.
 164+ *
 165+ * @param $groups Array: list of groups the given user is in
 166+ * @return Array: Tuple of addable, then removable groups
 167+ */
 168+ protected function splitGroups( $groups ) {
157169 list($addable, $removable) = array_values( $this->changeableGroups() );
158 - $removable = array_intersect($removable, $user->getGroups()); // Can't remove groups the user doesn't have
159 - $addable = array_diff( $addable, $user->getGroups()); // Can't add groups the user does have
160 -
161 - $this->showEditUserGroupsForm( $username, $addable, $removable );
 170+ $removable = array_intersect($removable, $groups ); // Can't remove groups the user doesn't have
 171+ $addable = array_diff( $addable, $groups ); // Can't add groups the user does have
 172+
 173+ return array( $addable, $removable );
162174 }
163175
164176 /**
@@ -165,11 +177,12 @@
166178 *
167179 * @todo make all CSS-y and semantic
168180 * @param $username String: Name of user you're editing
169 - * @param $addable Array: Array of groups that can be added
170 - * @param $removable Array: Array of groups that can be removed
 181+ * @param $groups Array: Array of groups the user is in
171182 */
172 - private function showEditUserGroupsForm( $username, $addable, $removable ) {
 183+ protected function showEditUserGroupsForm( $username, $groups ) {
173184 global $wgOut, $wgUser;
 185+
 186+ list( $addable, $removable ) = $this->splitGroups( $groups );
174187
175188 $wgOut->addHTML(
176189 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->action, 'name' => 'editGroup' ) ) .

Follow-up revisions

RevisionCommit summaryAuthorDate
r23504Merge r23460:r23503 from trunkrobchurch14:00, 28 June 2007
r23581Merged revisions 23406-23580 via svnmerge from...david04:50, 30 June 2007

Status & tagging log