Merge "mediawiki.ui: Add @activeColor argument to the .button-colors() mixin"
[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 $wgAuth->updateExternalDBGroups( $user, $add, $remove );
273
274 wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
275 wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
276 Hooks::run( 'UserRights', array( &$user, $add, $remove ) );
277
278 if ( $newGroups != $oldGroups ) {
279 $this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
280 }
281
282 return array( $add, $remove );
283 }
284
285 /**
286 * Add a rights log entry for an action.
287 * @param User $user
288 * @param array $oldGroups
289 * @param array $newGroups
290 * @param array $reason
291 */
292 function addLogEntry( $user, $oldGroups, $newGroups, $reason ) {
293 $logEntry = new ManualLogEntry( 'rights', 'rights' );
294 $logEntry->setPerformer( $this->getUser() );
295 $logEntry->setTarget( $user->getUserPage() );
296 $logEntry->setComment( $reason );
297 $logEntry->setParameters( array(
298 '4::oldgroups' => $oldGroups,
299 '5::newgroups' => $newGroups,
300 ) );
301 $logid = $logEntry->insert();
302 $logEntry->publish( $logid );
303 }
304
305 /**
306 * Edit user groups membership
307 * @param string $username Name of the user.
308 */
309 function editUserGroupsForm( $username ) {
310 $status = $this->fetchUser( $username );
311 if ( !$status->isOK() ) {
312 $this->getOutput()->addWikiText( $status->getWikiText() );
313
314 return;
315 } else {
316 $user = $status->value;
317 }
318
319 $groups = $user->getGroups();
320
321 $this->showEditUserGroupsForm( $user, $groups );
322
323 // This isn't really ideal logging behavior, but let's not hide the
324 // interwiki logs if we're using them as is.
325 $this->showLogFragment( $user, $this->getOutput() );
326 }
327
328 /**
329 * Normalize the input username, which may be local or remote, and
330 * return a user (or proxy) object for manipulating it.
331 *
332 * Side effects: error output for invalid access
333 * @param string $username
334 * @return Status
335 */
336 public function fetchUser( $username ) {
337 $parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
338 if ( count( $parts ) < 2 ) {
339 $name = trim( $username );
340 $database = '';
341 } else {
342 list( $name, $database ) = array_map( 'trim', $parts );
343
344 if ( $database == wfWikiID() ) {
345 $database = '';
346 } else {
347 if ( !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
348 return Status::newFatal( 'userrights-no-interwiki' );
349 }
350 if ( !UserRightsProxy::validDatabase( $database ) ) {
351 return Status::newFatal( 'userrights-nodatabase', $database );
352 }
353 }
354 }
355
356 if ( $name === '' ) {
357 return Status::newFatal( 'nouserspecified' );
358 }
359
360 if ( $name[0] == '#' ) {
361 // Numeric ID can be specified...
362 // We'll do a lookup for the name internally.
363 $id = intval( substr( $name, 1 ) );
364
365 if ( $database == '' ) {
366 $name = User::whoIs( $id );
367 } else {
368 $name = UserRightsProxy::whoIs( $database, $id );
369 }
370
371 if ( !$name ) {
372 return Status::newFatal( 'noname' );
373 }
374 } else {
375 $name = User::getCanonicalName( $name );
376 if ( $name === false ) {
377 // invalid name
378 return Status::newFatal( 'nosuchusershort', $username );
379 }
380 }
381
382 if ( $database == '' ) {
383 $user = User::newFromName( $name );
384 } else {
385 $user = UserRightsProxy::newFromName( $database, $name );
386 }
387
388 if ( !$user || $user->isAnon() ) {
389 return Status::newFatal( 'nosuchusershort', $username );
390 }
391
392 return Status::newGood( $user );
393 }
394
395 function makeGroupNameList( $ids ) {
396 if ( empty( $ids ) ) {
397 return $this->msg( 'rightsnone' )->inContentLanguage()->text();
398 } else {
399 return implode( ', ', $ids );
400 }
401 }
402
403 /**
404 * Make a list of group names to be stored as parameter for log entries
405 *
406 * @deprecated since 1.21; use LogFormatter instead.
407 * @param array $ids
408 * @return string
409 */
410 function makeGroupNameListForLog( $ids ) {
411 wfDeprecated( __METHOD__, '1.21' );
412
413 if ( empty( $ids ) ) {
414 return '';
415 } else {
416 return $this->makeGroupNameList( $ids );
417 }
418 }
419
420 /**
421 * Output a form to allow searching for a user
422 */
423 function switchForm() {
424 $this->getOutput()->addModules( 'mediawiki.userSuggest' );
425
426 $this->getOutput()->addHTML(
427 Html::openElement(
428 'form',
429 array(
430 'method' => 'get',
431 'action' => wfScript(),
432 'name' => 'uluser',
433 'id' => 'mw-userrights-form1'
434 )
435 ) .
436 Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
437 Xml::fieldset( $this->msg( 'userrights-lookup-user' )->text() ) .
438 Xml::inputLabel(
439 $this->msg( 'userrights-user-editname' )->text(),
440 'user',
441 'username',
442 30,
443 str_replace( '_', ' ', $this->mTarget ),
444 array(
445 'autofocus' => '',
446 'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
447 )
448 ) . ' ' .
449 Xml::submitButton( $this->msg( 'editusergroup' )->text() ) .
450 Html::closeElement( 'fieldset' ) .
451 Html::closeElement( 'form' ) . "\n"
452 );
453 }
454
455 /**
456 * Go through used and available groups and return the ones that this
457 * form will be able to manipulate based on the current user's system
458 * permissions.
459 *
460 * @param array $groups List of groups the given user is in
461 * @return array Tuple of addable, then removable groups
462 */
463 protected function splitGroups( $groups ) {
464 list( $addable, $removable, $addself, $removeself ) = array_values( $this->changeableGroups() );
465
466 $removable = array_intersect(
467 array_merge( $this->isself ? $removeself : array(), $removable ),
468 $groups
469 ); // Can't remove groups the user doesn't have
470 $addable = array_diff(
471 array_merge( $this->isself ? $addself : array(), $addable ),
472 $groups
473 ); // Can't add groups the user does have
474
475 return array( $addable, $removable );
476 }
477
478 /**
479 * Show the form to edit group memberships.
480 *
481 * @param User|UserRightsProxy $user User or UserRightsProxy you're editing
482 * @param array $groups Array of groups the user is in
483 */
484 protected function showEditUserGroupsForm( $user, $groups ) {
485 $list = array();
486 $membersList = array();
487 foreach ( $groups as $group ) {
488 $list[] = self::buildGroupLink( $group );
489 $membersList[] = self::buildGroupMemberLink( $group );
490 }
491
492 $autoList = array();
493 $autoMembersList = array();
494 if ( $user instanceof User ) {
495 foreach ( Autopromote::getAutopromoteGroups( $user ) as $group ) {
496 $autoList[] = self::buildGroupLink( $group );
497 $autoMembersList[] = self::buildGroupMemberLink( $group );
498 }
499 }
500
501 $language = $this->getLanguage();
502 $displayedList = $this->msg( 'userrights-groupsmember-type' )
503 ->rawParams(
504 $language->listToText( $list ),
505 $language->listToText( $membersList )
506 )->escaped();
507 $displayedAutolist = $this->msg( 'userrights-groupsmember-type' )
508 ->rawParams(
509 $language->listToText( $autoList ),
510 $language->listToText( $autoMembersList )
511 )->escaped();
512
513 $grouplist = '';
514 $count = count( $list );
515 if ( $count > 0 ) {
516 $grouplist = $this->msg( 'userrights-groupsmember' )
517 ->numParams( $count )
518 ->params( $user->getName() )
519 ->parse();
520 $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
521 }
522
523 $count = count( $autoList );
524 if ( $count > 0 ) {
525 $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto' )
526 ->numParams( $count )
527 ->params( $user->getName() )
528 ->parse();
529 $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
530 }
531
532 $userToolLinks = Linker::userToolLinks(
533 $user->getId(),
534 $user->getName(),
535 false, /* default for redContribsWhenNoEdits */
536 Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
537 );
538
539 $this->getOutput()->addHTML(
540 Xml::openElement(
541 'form',
542 array(
543 'method' => 'post',
544 'action' => $this->getPageTitle()->getLocalURL(),
545 'name' => 'editGroup',
546 'id' => 'mw-userrights-form2'
547 )
548 ) .
549 Html::hidden( 'user', $this->mTarget ) .
550 Html::hidden( 'wpEditToken', $this->getUser()->getEditToken( $this->mTarget ) ) .
551 Html::hidden(
552 'conflictcheck-originalgroups',
553 implode( ',', $user->getGroups() )
554 ) . // Conflict detection
555 Xml::openElement( 'fieldset' ) .
556 Xml::element(
557 'legend',
558 array(),
559 $this->msg( 'userrights-editusergroup', $user->getName() )->text()
560 ) .
561 $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
562 ->rawParams( $userToolLinks )->parse() .
563 $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
564 $grouplist .
565 $this->groupCheckboxes( $groups, $user ) .
566 Xml::openElement( 'table', array( 'id' => 'mw-userrights-table-outer' ) ) .
567 "<tr>
568 <td class='mw-label'>" .
569 Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) .
570 "</td>
571 <td class='mw-input'>" .
572 Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ),
573 array( 'id' => 'wpReason', 'maxlength' => 255 ) ) .
574 "</td>
575 </tr>
576 <tr>
577 <td></td>
578 <td class='mw-submit'>" .
579 Xml::submitButton( $this->msg( 'saveusergroups' )->text(),
580 array( 'name' => 'saveusergroups' ) +
581 Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
582 ) .
583 "</td>
584 </tr>" .
585 Xml::closeElement( 'table' ) . "\n" .
586 Xml::closeElement( 'fieldset' ) .
587 Xml::closeElement( 'form' ) . "\n"
588 );
589 }
590
591 /**
592 * Format a link to a group description page
593 *
594 * @param string $group
595 * @return string
596 */
597 private static function buildGroupLink( $group ) {
598 return User::makeGroupLinkHtml( $group, User::getGroupName( $group ) );
599 }
600
601 /**
602 * Format a link to a group member description page
603 *
604 * @param string $group
605 * @return string
606 */
607 private static function buildGroupMemberLink( $group ) {
608 return User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) );
609 }
610
611 /**
612 * Returns an array of all groups that may be edited
613 * @return array Array of groups that may be edited.
614 */
615 protected static function getAllGroups() {
616 return User::getAllGroups();
617 }
618
619 /**
620 * Adds a table with checkboxes where you can select what groups to add/remove
621 *
622 * @todo Just pass the username string?
623 * @param array $usergroups Groups the user belongs to
624 * @param User $user
625 * @return string XHTML table element with checkboxes
626 */
627 private function groupCheckboxes( $usergroups, $user ) {
628 $allgroups = $this->getAllGroups();
629 $ret = '';
630
631 // Put all column info into an associative array so that extensions can
632 // more easily manage it.
633 $columns = array( 'unchangeable' => array(), 'changeable' => array() );
634
635 foreach ( $allgroups as $group ) {
636 $set = in_array( $group, $usergroups );
637 // Should the checkbox be disabled?
638 $disabled = !(
639 ( $set && $this->canRemove( $group ) ) ||
640 ( !$set && $this->canAdd( $group ) ) );
641 // Do we need to point out that this action is irreversible?
642 $irreversible = !$disabled && (
643 ( $set && !$this->canAdd( $group ) ) ||
644 ( !$set && !$this->canRemove( $group ) ) );
645
646 $checkbox = array(
647 'set' => $set,
648 'disabled' => $disabled,
649 'irreversible' => $irreversible
650 );
651
652 if ( $disabled ) {
653 $columns['unchangeable'][$group] = $checkbox;
654 } else {
655 $columns['changeable'][$group] = $checkbox;
656 }
657 }
658
659 // Build the HTML table
660 $ret .= Xml::openElement( 'table', array( 'class' => 'mw-userrights-groups' ) ) .
661 "<tr>\n";
662 foreach ( $columns as $name => $column ) {
663 if ( $column === array() ) {
664 continue;
665 }
666 // Messages: userrights-changeable-col, userrights-unchangeable-col
667 $ret .= Xml::element(
668 'th',
669 null,
670 $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text()
671 );
672 }
673
674 $ret .= "</tr>\n<tr>\n";
675 foreach ( $columns as $column ) {
676 if ( $column === array() ) {
677 continue;
678 }
679 $ret .= "\t<td style='vertical-align:top;'>\n";
680 foreach ( $column as $group => $checkbox ) {
681 $attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
682
683 $member = User::getGroupMember( $group, $user->getName() );
684 if ( $checkbox['irreversible'] ) {
685 $text = $this->msg( 'userrights-irreversible-marker', $member )->text();
686 } else {
687 $text = $member;
688 }
689 $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
690 "wpGroup-" . $group, $checkbox['set'], $attr );
691 $ret .= "\t\t" . ( $checkbox['disabled']
692 ? Xml::tags( 'span', array( 'class' => 'mw-userrights-disabled' ), $checkboxHtml )
693 : $checkboxHtml
694 ) . "<br />\n";
695 }
696 $ret .= "\t</td>\n";
697 }
698 $ret .= Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' );
699
700 return $ret;
701 }
702
703 /**
704 * @param string $group The name of the group to check
705 * @return bool Can we remove the group?
706 */
707 private function canRemove( $group ) {
708 // $this->changeableGroups()['remove'] doesn't work, of course. Thanks, PHP.
709 $groups = $this->changeableGroups();
710
711 return in_array(
712 $group,
713 $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] )
714 );
715 }
716
717 /**
718 * @param string $group The name of the group to check
719 * @return bool Can we add the group?
720 */
721 private function canAdd( $group ) {
722 $groups = $this->changeableGroups();
723
724 return in_array(
725 $group,
726 $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] )
727 );
728 }
729
730 /**
731 * Returns $this->getUser()->changeableGroups()
732 *
733 * @return array Array(
734 * 'add' => array( addablegroups ),
735 * 'remove' => array( removablegroups ),
736 * 'add-self' => array( addablegroups to self ),
737 * 'remove-self' => array( removable groups from self )
738 * )
739 */
740 function changeableGroups() {
741 return $this->getUser()->changeableGroups();
742 }
743
744 /**
745 * Show a rights log fragment for the specified user
746 *
747 * @param User $user User to show log for
748 * @param OutputPage $output OutputPage to use
749 */
750 protected function showLogFragment( $user, $output ) {
751 $rightsLogPage = new LogPage( 'rights' );
752 $output->addHTML( Xml::element( 'h2', null, $rightsLogPage->getName()->text() ) );
753 LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage() );
754 }
755
756 protected function getGroupName() {
757 return 'users';
758 }
759 }