Index: trunk/phase3/includes/SpecialUserrights.php |
— | — | @@ -153,11 +153,23 @@ |
154 | 154 | return; |
155 | 155 | } |
156 | 156 | |
| 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 ) { |
157 | 169 | 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 ); |
162 | 174 | } |
163 | 175 | |
164 | 176 | /** |
— | — | @@ -165,11 +177,12 @@ |
166 | 178 | * |
167 | 179 | * @todo make all CSS-y and semantic |
168 | 180 | * @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 |
171 | 182 | */ |
172 | | - private function showEditUserGroupsForm( $username, $addable, $removable ) { |
| 183 | + protected function showEditUserGroupsForm( $username, $groups ) { |
173 | 184 | global $wgOut, $wgUser; |
| 185 | + |
| 186 | + list( $addable, $removable ) = $this->splitGroups( $groups ); |
174 | 187 | |
175 | 188 | $wgOut->addHTML( |
176 | 189 | Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->action, 'name' => 'editGroup' ) ) . |