Enable users to watch category membership changes #2
[lhc/web/wiklou.git] / includes / specials / SpecialUserrights.php
1 <?php
2 /**
3 * Implements Special:Userrights
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * Special page to allow managing user group membership
26 *
27 * @ingroup SpecialPage
28 */
29 class UserrightsPage extends SpecialPage {
30 # The target of the local right-adjuster's interest. Can be gotten from
31 # either a GET parameter or a subpage-style parameter, so have a member
32 # variable for it.
33 protected $mTarget;
34 protected $isself = false;
35
36 public function __construct() {
37 parent::__construct( 'Userrights' );
38 }
39
40 public function isRestricted() {
41 return true;
42 }
43
44 public function userCanExecute( User $user ) {
45 return $this->userCanChangeRights( $user, false );
46 }
47
48 /**
49 * @param User $user
50 * @param bool $checkIfSelf
51 * @return bool
52 */
53 public function userCanChangeRights( $user, $checkIfSelf = true ) {
54 $available = $this->changeableGroups();
55 if ( $user->getId() == 0 ) {
56 return false;
57 }
58
59 return !empty( $available['add'] )
60 || !empty( $available['remove'] )
61 || ( ( $this->isself || !$checkIfSelf ) &&
62 ( !empty( $available['add-self'] )
63 || !empty( $available['remove-self'] ) ) );
64 }
65
66 /**
67 * Manage forms to be shown according to posted data.
68 * Depending on the submit button used, call a form or a save function.
69 *
70 * @param string|null $par String if any subpage provided, else null
71 * @throws UserBlockedError|PermissionsError
72 */
73 public function execute( $par ) {
74 // If the visitor doesn't have permissions to assign or remove
75 // any groups, it's a bit silly to give them the user search prompt.
76
77 $user = $this->getUser();
78
79 /*
80 * If the user is blocked and they only have "partial" access
81 * (e.g. they don't have the userrights permission), then don't
82 * allow them to use Special:UserRights.
83 */
84 if ( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
85 throw new UserBlockedError( $user->getBlock() );
86 }
87
88 $request = $this->getRequest();
89
90 if ( $par !== null ) {
91 $this->mTarget = $par;
92 } else {
93 $this->mTarget = $request->getVal( 'user' );
94 }
95
96 $available = $this->changeableGroups();
97
98 if ( $this->mTarget === null ) {
99 /*
100 * If the user specified no target, and they can only
101 * edit their own groups, automatically set them as the
102 * target.
103 */
104 if ( !count( $available['add'] ) && !count( $available['remove'] ) ) {
105 $this->mTarget = $user->getName();
106 }
107 }
108
109 if ( $this->mTarget !== null && User::getCanonicalName( $this->mTarget ) === $user->getName() ) {
110 $this->isself = true;
111 }
112
113 if ( !$this->userCanChangeRights( $user, true ) ) {
114 if ( $this->isself && $request->getCheck( 'success' ) ) {
115 // bug 48609: if the user just removed its own rights, this would
116 // leads it in a "permissions error" page. In that case, show a
117 // message that it can't anymore use this page instead of an error
118 $this->setHeaders();
119 $out = $this->getOutput();
120 $out->wrapWikiMsg( "<div class=\"successbox\">\n$1\n</div>", 'userrights-removed-self' );
121 $out->returnToMain();
122
123 return;
124 }
125
126 // @todo FIXME: There may be intermediate groups we can mention.
127 $msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
128 throw new PermissionsError( null, array( array( $msg ) ) );
129 }
130
131 $this->checkReadOnly();
132
133 $this->setHeaders();
134 $this->outputHeader();
135
136 $out = $this->getOutput();
137 $out->addModuleStyles( 'mediawiki.special' );
138 $this->addHelpLink( 'Help:Assigning permissions' );
139
140 // show the general form
141 if ( count( $available['add'] ) || count( $available['remove'] ) ) {
142 $this->switchForm();
143 }
144
145 if (
146 $request->wasPosted() &&
147 $request->getCheck( 'saveusergroups' ) &&
148 $this->mTarget !== null &&
149 $user->matchEditToken( $request->getVal( 'wpEditToken' ), $this->mTarget )
150 ) {
151 // save settings
152 $status = $this->fetchUser( $this->mTarget );
153 if ( !$status->isOK() ) {
154 $this->getOutput()->addWikiText( $status->getWikiText() );
155
156 return;
157 }
158
159 $targetUser = $status->value;
160 if ( $targetUser instanceof User ) { // UserRightsProxy doesn't have this method (bug 61252)
161 $targetUser->clearInstanceCache(); // bug 38989
162 }
163
164 if ( $request->getVal( 'conflictcheck-originalgroups' )
165 !== implode( ',', $targetUser->getGroups() )
166 ) {
167 $out->addWikiMsg( 'userrights-conflict' );
168 } else {
169 $this->saveUserGroups(
170 $this->mTarget,
171 $request->getVal( 'user-reason' ),
172 $targetUser
173 );
174
175 $out->redirect( $this->getSuccessURL() );
176
177 return;
178 }
179 }
180
181 // show some more forms
182 if ( $this->mTarget !== null ) {
183 $this->editUserGroupsForm( $this->mTarget );
184 }
185 }
186
187 function getSuccessURL() {
188 return $this->getPageTitle( $this->mTarget )->getFullURL( array( 'success' => 1 ) );
189 }
190
191 /**
192 * Save user groups changes in the database.
193 * Data comes from the editUserGroupsForm() form function
194 *
195 * @param string $username Username to apply changes to.
196 * @param string $reason Reason for group change
197 * @param User|UserRightsProxy $user Target user object.
198 * @return null
199 */
200 function saveUserGroups( $username, $reason, $user ) {
201 $allgroups = $this->getAllGroups();
202 $addgroup = array();
203 $removegroup = array();
204
205 // This could possibly create a highly unlikely race condition if permissions are changed between
206 // when the form is loaded and when the form is saved. Ignoring it for the moment.
207 foreach ( $allgroups as $group ) {
208 // We'll tell it to remove all unchecked groups, and add all checked groups.
209 // Later on, this gets filtered for what can actually be removed
210 if ( $this->getRequest()->getCheck( "wpGroup-$group" ) ) {
211 $addgroup[] = $group;
212 } else {
213 $removegroup[] = $group;
214 }
215 }
216
217 $this->doSaveUserGroups( $user, $addgroup, $removegroup, $reason );
218 }
219
220 /**
221 * Save user groups changes in the database.
222 *
223 * @param User|UserRightsProxy $user
224 * @param array $add Array of groups to add
225 * @param array $remove Array of groups to remove
226 * @param string $reason Reason for group change
227 * @return array Tuple of added, then removed groups
228 */
229 function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
230 global $wgAuth;
231
232 // Validate input set...
233 $isself = $user->getName() == $this->getUser()->getName();
234 $groups = $user->getGroups();
235 $changeable = $this->changeableGroups();
236 $addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() );
237 $removable = array_merge( $changeable['remove'], $isself ? $changeable['remove-self'] : array() );
238
239 $remove = array_unique(
240 array_intersect( (array)$remove, $removable, $groups ) );
241 $add = array_unique( array_diff(
242 array_intersect( (array)$add, $addable ),
243 $groups )
244 );
245
246 $oldGroups = $user->getGroups();
247 $newGroups = $oldGroups;
248
249 // Remove then add groups
250 if ( $remove ) {
251 foreach ( $remove as $index => $group ) {
252 if ( !$user->removeGroup( $group ) ) {
253 unset( $remove[$index] );
254 }
255 }
256 $newGroups = array_diff( $newGroups, $remove );
257 }
258 if ( $add ) {
259 foreach ( $add as $index => $group ) {
260 if ( !$user->addGroup( $group ) ) {
261 unset( $add[$index] );
262 }
263 }
264 $newGroups = array_merge( $newGroups, $add );
265 }
266 $newGroups = array_unique( $newGroups );
267
268 // Ensure that caches are cleared
269 $user->invalidateCache();
270
271 // update groups in external authentication database
272 Hooks::run( 'UserGroupsChanged', array( $user, $add, $remove, $this->getUser() ) );
273 $wgAuth->updateExternalDBGroups( $user, $add, $remove );
274
275 wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
276 wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
277 // Deprecated in favor of UserGroupsChanged hook
278 Hooks::run( 'UserRights', array( &$user, $add, $remove ), '1.26' );
279
280 if ( $newGroups != $oldGroups ) {
281 $this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
282 }
283
284 return array( $add, $remove );
285 }
286
287 /**
288 * Add a rights log entry for an action.
289 * @param User $user
290 * @param array $oldGroups
291 * @param array $newGroups
292 * @param array $reason
293 */
294 function addLogEntry( $user, $oldGroups, $newGroups, $reason ) {
295 $logEntry = new ManualLogEntry( 'rights', 'rights' );
296 $logEntry->setPerformer( $this->getUser() );
297 $logEntry->setTarget( $user->getUserPage() );
298 $logEntry->setComment( $reason );
299 $logEntry->setParameters( array(
300 '4::oldgroups' => $oldGroups,
301 '5::newgroups' => $newGroups,
302 ) );
303 $logid = $logEntry->insert();
304 $logEntry->publish( $logid );
305 }
306
307 /**
308 * Edit user groups membership
309 * @param string $username Name of the user.
310 */
311 function editUserGroupsForm( $username ) {
312 $status = $this->fetchUser( $username );
313 if ( !$status->isOK() ) {
314 $this->getOutput()->addWikiText( $status->getWikiText() );
315
316 return;
317 } else {
318 $user = $status->value;
319 }
320
321 $groups = $user->getGroups();
322
323 $this->showEditUserGroupsForm( $user, $groups );
324
325 // This isn't really ideal logging behavior, but let's not hide the
326 // interwiki logs if we're using them as is.
327 $this->showLogFragment( $user, $this->getOutput() );
328 }
329
330 /**
331 * Normalize the input username, which may be local or remote, and
332 * return a user (or proxy) object for manipulating it.
333 *
334 * Side effects: error output for invalid access
335 * @param string $username
336 * @return Status
337 */
338 public function fetchUser( $username ) {
339 $parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
340 if ( count( $parts ) < 2 ) {
341 $name = trim( $username );
342 $database = '';
343 } else {
344 list( $name, $database ) = array_map( 'trim', $parts );
345
346 if ( $database == wfWikiID() ) {
347 $database = '';
348 } else {
349 if ( !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
350 return Status::newFatal( 'userrights-no-interwiki' );
351 }
352 if ( !UserRightsProxy::validDatabase( $database ) ) {
353 return Status::newFatal( 'userrights-nodatabase', $database );
354 }
355 }
356 }
357
358 if ( $name === '' ) {
359 return Status::newFatal( 'nouserspecified' );
360 }
361
362 if ( $name[0] == '#' ) {
363 // Numeric ID can be specified...
364 // We'll do a lookup for the name internally.
365 $id = intval( substr( $name, 1 ) );
366
367 if ( $database == '' ) {
368 $name = User::whoIs( $id );
369 } else {
370 $name = UserRightsProxy::whoIs( $database, $id );
371 }
372
373 if ( !$name ) {
374 return Status::newFatal( 'noname' );
375 }
376 } else {
377 $name = User::getCanonicalName( $name );
378 if ( $name === false ) {
379 // invalid name
380 return Status::newFatal( 'nosuchusershort', $username );
381 }
382 }
383
384 if ( $database == '' ) {
385 $user = User::newFromName( $name );
386 } else {
387 $user = UserRightsProxy::newFromName( $database, $name );
388 }
389
390 if ( !$user || $user->isAnon() ) {
391 return Status::newFatal( 'nosuchusershort', $username );
392 }
393
394 return Status::newGood( $user );
395 }
396
397 function makeGroupNameList( $ids ) {
398 if ( empty( $ids ) ) {
399 return $this->msg( 'rightsnone' )->inContentLanguage()->text();
400 } else {
401 return implode( ', ', $ids );
402 }
403 }
404
405 /**
406 * Make a list of group names to be stored as parameter for log entries
407 *
408 * @deprecated since 1.21; use LogFormatter instead.
409 * @param array $ids
410 * @return string
411 */
412 function makeGroupNameListForLog( $ids ) {
413 wfDeprecated( __METHOD__, '1.21' );
414
415 if ( empty( $ids ) ) {
416 return '';
417 } else {
418 return $this->makeGroupNameList( $ids );
419 }
420 }
421
422 /**
423 * Output a form to allow searching for a user
424 */
425 function switchForm() {
426 $this->getOutput()->addModules( 'mediawiki.userSuggest' );
427
428 $this->getOutput()->addHTML(
429 Html::openElement(
430 'form',
431 array(
432 'method' => 'get',
433 'action' => wfScript(),
434 'name' => 'uluser',
435 'id' => 'mw-userrights-form1'
436 )
437 ) .
438 Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
439 Xml::fieldset( $this->msg( 'userrights-lookup-user' )->text() ) .
440 Xml::inputLabel(
441 $this->msg( 'userrights-user-editname' )->text(),
442 'user',
443 'username',
444 30,
445 str_replace( '_', ' ', $this->mTarget ),
446 array(
447 'autofocus' => '',
448 'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
449 )
450 ) . ' ' .
451 Xml::submitButton( $this->msg( 'editusergroup' )->text() ) .
452 Html::closeElement( 'fieldset' ) .
453 Html::closeElement( 'form' ) . "\n"
454 );
455 }
456
457 /**
458 * Go through used and available groups and return the ones that this
459 * form will be able to manipulate based on the current user's system
460 * permissions.
461 *
462 * @param array $groups List of groups the given user is in
463 * @return array Tuple of addable, then removable groups
464 */
465 protected function splitGroups( $groups ) {
466 list( $addable, $removable, $addself, $removeself ) = array_values( $this->changeableGroups() );
467
468 $removable = array_intersect(
469 array_merge( $this->isself ? $removeself : array(), $removable ),
470 $groups
471 ); // Can't remove groups the user doesn't have
472 $addable = array_diff(
473 array_merge( $this->isself ? $addself : array(), $addable ),
474 $groups
475 ); // Can't add groups the user does have
476
477 return array( $addable, $removable );
478 }
479
480 /**
481 * Show the form to edit group memberships.
482 *
483 * @param User|UserRightsProxy $user User or UserRightsProxy you're editing
484 * @param array $groups Array of groups the user is in
485 */
486 protected function showEditUserGroupsForm( $user, $groups ) {
487 $list = array();
488 $membersList = array();
489 foreach ( $groups as $group ) {
490 $list[] = self::buildGroupLink( $group );
491 $membersList[] = self::buildGroupMemberLink( $group );
492 }
493
494 $autoList = array();
495 $autoMembersList = array();
496 if ( $user instanceof User ) {
497 foreach ( Autopromote::getAutopromoteGroups( $user ) as $group ) {
498 $autoList[] = self::buildGroupLink( $group );
499 $autoMembersList[] = self::buildGroupMemberLink( $group );
500 }
501 }
502
503 $language = $this->getLanguage();
504 $displayedList = $this->msg( 'userrights-groupsmember-type' )
505 ->rawParams(
506 $language->listToText( $list ),
507 $language->listToText( $membersList )
508 )->escaped();
509 $displayedAutolist = $this->msg( 'userrights-groupsmember-type' )
510 ->rawParams(
511 $language->listToText( $autoList ),
512 $language->listToText( $autoMembersList )
513 )->escaped();
514
515 $grouplist = '';
516 $count = count( $list );
517 if ( $count > 0 ) {
518 $grouplist = $this->msg( 'userrights-groupsmember' )
519 ->numParams( $count )
520 ->params( $user->getName() )
521 ->parse();
522 $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
523 }
524
525 $count = count( $autoList );
526 if ( $count > 0 ) {
527 $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto' )
528 ->numParams( $count )
529 ->params( $user->getName() )
530 ->parse();
531 $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
532 }
533
534 $userToolLinks = Linker::userToolLinks(
535 $user->getId(),
536 $user->getName(),
537 false, /* default for redContribsWhenNoEdits */
538 Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
539 );
540
541 $this->getOutput()->addHTML(
542 Xml::openElement(
543 'form',
544 array(
545 'method' => 'post',
546 'action' => $this->getPageTitle()->getLocalURL(),
547 'name' => 'editGroup',
548 'id' => 'mw-userrights-form2'
549 )
550 ) .
551 Html::hidden( 'user', $this->mTarget ) .
552 Html::hidden( 'wpEditToken', $this->getUser()->getEditToken( $this->mTarget ) ) .
553 Html::hidden(
554 'conflictcheck-originalgroups',
555 implode( ',', $user->getGroups() )
556 ) . // Conflict detection
557 Xml::openElement( 'fieldset' ) .
558 Xml::element(
559 'legend',
560 array(),
561 $this->msg( 'userrights-editusergroup', $user->getName() )->text()
562 ) .
563 $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
564 ->rawParams( $userToolLinks )->parse() .
565 $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
566 $grouplist .
567 $this->groupCheckboxes( $groups, $user ) .
568 Xml::openElement( 'table', array( 'id' => 'mw-userrights-table-outer' ) ) .
569 "<tr>
570 <td class='mw-label'>" .
571 Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) .
572 "</td>
573 <td class='mw-input'>" .
574 Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ),
575 array( 'id' => 'wpReason', 'maxlength' => 255 ) ) .
576 "</td>
577 </tr>
578 <tr>
579 <td></td>
580 <td class='mw-submit'>" .
581 Xml::submitButton( $this->msg( 'saveusergroups' )->text(),
582 array( 'name' => 'saveusergroups' ) +
583 Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
584 ) .
585 "</td>
586 </tr>" .
587 Xml::closeElement( 'table' ) . "\n" .
588 Xml::closeElement( 'fieldset' ) .
589 Xml::closeElement( 'form' ) . "\n"
590 );
591 }
592
593 /**
594 * Format a link to a group description page
595 *
596 * @param string $group
597 * @return string
598 */
599 private static function buildGroupLink( $group ) {
600 return User::makeGroupLinkHtml( $group, User::getGroupName( $group ) );
601 }
602
603 /**
604 * Format a link to a group member description page
605 *
606 * @param string $group
607 * @return string
608 */
609 private static function buildGroupMemberLink( $group ) {
610 return User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) );
611 }
612
613 /**
614 * Returns an array of all groups that may be edited
615 * @return array Array of groups that may be edited.
616 */
617 protected static function getAllGroups() {
618 return User::getAllGroups();
619 }
620
621 /**
622 * Adds a table with checkboxes where you can select what groups to add/remove
623 *
624 * @todo Just pass the username string?
625 * @param array $usergroups Groups the user belongs to
626 * @param User $user
627 * @return string XHTML table element with checkboxes
628 */
629 private function groupCheckboxes( $usergroups, $user ) {
630 $allgroups = $this->getAllGroups();
631 $ret = '';
632
633 // Put all column info into an associative array so that extensions can
634 // more easily manage it.
635 $columns = array( 'unchangeable' => array(), 'changeable' => array() );
636
637 foreach ( $allgroups as $group ) {
638 $set = in_array( $group, $usergroups );
639 // Should the checkbox be disabled?
640 $disabled = !(
641 ( $set && $this->canRemove( $group ) ) ||
642 ( !$set && $this->canAdd( $group ) ) );
643 // Do we need to point out that this action is irreversible?
644 $irreversible = !$disabled && (
645 ( $set && !$this->canAdd( $group ) ) ||
646 ( !$set && !$this->canRemove( $group ) ) );
647
648 $checkbox = array(
649 'set' => $set,
650 'disabled' => $disabled,
651 'irreversible' => $irreversible
652 );
653
654 if ( $disabled ) {
655 $columns['unchangeable'][$group] = $checkbox;
656 } else {
657 $columns['changeable'][$group] = $checkbox;
658 }
659 }
660
661 // Build the HTML table
662 $ret .= Xml::openElement( 'table', array( 'class' => 'mw-userrights-groups' ) ) .
663 "<tr>\n";
664 foreach ( $columns as $name => $column ) {
665 if ( $column === array() ) {
666 continue;
667 }
668 // Messages: userrights-changeable-col, userrights-unchangeable-col
669 $ret .= Xml::element(
670 'th',
671 null,
672 $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text()
673 );
674 }
675
676 $ret .= "</tr>\n<tr>\n";
677 foreach ( $columns as $column ) {
678 if ( $column === array() ) {
679 continue;
680 }
681 $ret .= "\t<td style='vertical-align:top;'>\n";
682 foreach ( $column as $group => $checkbox ) {
683 $attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
684
685 $member = User::getGroupMember( $group, $user->getName() );
686 if ( $checkbox['irreversible'] ) {
687 $text = $this->msg( 'userrights-irreversible-marker', $member )->text();
688 } else {
689 $text = $member;
690 }
691 $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
692 "wpGroup-" . $group, $checkbox['set'], $attr );
693 $ret .= "\t\t" . ( $checkbox['disabled']
694 ? Xml::tags( 'span', array( 'class' => 'mw-userrights-disabled' ), $checkboxHtml )
695 : $checkboxHtml
696 ) . "<br />\n";
697 }
698 $ret .= "\t</td>\n";
699 }
700 $ret .= Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' );
701
702 return $ret;
703 }
704
705 /**
706 * @param string $group The name of the group to check
707 * @return bool Can we remove the group?
708 */
709 private function canRemove( $group ) {
710 // $this->changeableGroups()['remove'] doesn't work, of course. Thanks, PHP.
711 $groups = $this->changeableGroups();
712
713 return in_array(
714 $group,
715 $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] )
716 );
717 }
718
719 /**
720 * @param string $group The name of the group to check
721 * @return bool Can we add the group?
722 */
723 private function canAdd( $group ) {
724 $groups = $this->changeableGroups();
725
726 return in_array(
727 $group,
728 $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] )
729 );
730 }
731
732 /**
733 * Returns $this->getUser()->changeableGroups()
734 *
735 * @return array Array(
736 * 'add' => array( addablegroups ),
737 * 'remove' => array( removablegroups ),
738 * 'add-self' => array( addablegroups to self ),
739 * 'remove-self' => array( removable groups from self )
740 * )
741 */
742 function changeableGroups() {
743 return $this->getUser()->changeableGroups();
744 }
745
746 /**
747 * Show a rights log fragment for the specified user
748 *
749 * @param User $user User to show log for
750 * @param OutputPage $output OutputPage to use
751 */
752 protected function showLogFragment( $user, $output ) {
753 $rightsLogPage = new LogPage( 'rights' );
754 $output->addHTML( Xml::element( 'h2', null, $rightsLogPage->getName()->text() ) );
755 LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage() );
756 }
757
758 protected function getGroupName() {
759 return 'users';
760 }
761 }