MediaWiki  REL1_31
SpecialUserrights.php
Go to the documentation of this file.
1 <?php
29 class UserrightsPage extends SpecialPage {
36  protected $mTarget;
37  /*
38  * @var null|User $mFetchedUser The user object of the target username or null.
39  */
40  protected $mFetchedUser = null;
41  protected $isself = false;
42 
43  public function __construct() {
44  parent::__construct( 'Userrights' );
45  }
46 
47  public function doesWrites() {
48  return true;
49  }
50 
60  public function userCanChangeRights( $targetUser, $checkIfSelf = true ) {
61  $isself = $this->getUser()->equals( $targetUser );
62 
63  $available = $this->changeableGroups();
64  if ( $targetUser->getId() == 0 ) {
65  return false;
66  }
67 
68  return !empty( $available['add'] )
69  || !empty( $available['remove'] )
70  || ( ( $isself || !$checkIfSelf ) &&
71  ( !empty( $available['add-self'] )
72  || !empty( $available['remove-self'] ) ) );
73  }
74 
82  public function execute( $par ) {
83  $user = $this->getUser();
84  $request = $this->getRequest();
85  $session = $request->getSession();
86  $out = $this->getOutput();
87 
88  $out->addModules( [ 'mediawiki.special.userrights' ] );
89 
90  if ( $par !== null ) {
91  $this->mTarget = $par;
92  } else {
93  $this->mTarget = $request->getVal( 'user' );
94  }
95 
96  if ( is_string( $this->mTarget ) ) {
97  $this->mTarget = trim( $this->mTarget );
98  }
99 
100  if ( $this->mTarget !== null && User::getCanonicalName( $this->mTarget ) === $user->getName() ) {
101  $this->isself = true;
102  }
103 
104  $fetchedStatus = $this->fetchUser( $this->mTarget, true );
105  if ( $fetchedStatus->isOK() ) {
106  $this->mFetchedUser = $fetchedStatus->value;
107  if ( $this->mFetchedUser instanceof User ) {
108  // Set the 'relevant user' in the skin, so it displays links like Contributions,
109  // User logs, UserRights, etc.
110  $this->getSkin()->setRelevantUser( $this->mFetchedUser );
111  }
112  }
113 
114  // show a successbox, if the user rights was saved successfully
115  if (
116  $session->get( 'specialUserrightsSaveSuccess' ) &&
117  $this->mFetchedUser !== null
118  ) {
119  // Remove session data for the success message
120  $session->remove( 'specialUserrightsSaveSuccess' );
121 
122  $out->addModuleStyles( 'mediawiki.notification.convertmessagebox.styles' );
123  $out->addHTML(
125  'div',
126  [
127  'class' => 'mw-notify-success successbox',
128  'id' => 'mw-preferences-success',
129  'data-mw-autohide' => 'false',
130  ],
132  'p',
133  [],
134  $this->msg( 'savedrights', $this->mFetchedUser->getName() )->text()
135  )
136  )
137  );
138  }
139 
140  $this->setHeaders();
141  $this->outputHeader();
142 
143  $out->addModuleStyles( 'mediawiki.special' );
144  $this->addHelpLink( 'Help:Assigning permissions' );
145 
146  $this->switchForm();
147 
148  if (
149  $request->wasPosted() &&
150  $request->getCheck( 'saveusergroups' ) &&
151  $this->mTarget !== null &&
152  $user->matchEditToken( $request->getVal( 'wpEditToken' ), $this->mTarget )
153  ) {
154  /*
155  * If the user is blocked and they only have "partial" access
156  * (e.g. they don't have the userrights permission), then don't
157  * allow them to change any user rights.
158  */
159  if ( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
160  throw new UserBlockedError( $user->getBlock() );
161  }
162 
163  $this->checkReadOnly();
164 
165  // save settings
166  if ( !$fetchedStatus->isOK() ) {
167  $this->getOutput()->addWikiText( $fetchedStatus->getWikiText() );
168 
169  return;
170  }
171 
172  $targetUser = $this->mFetchedUser;
173  if ( $targetUser instanceof User ) { // UserRightsProxy doesn't have this method (T63252)
174  $targetUser->clearInstanceCache(); // T40989
175  }
176 
177  if ( $request->getVal( 'conflictcheck-originalgroups' )
178  !== implode( ',', $targetUser->getGroups() )
179  ) {
180  $out->addWikiMsg( 'userrights-conflict' );
181  } else {
182  $status = $this->saveUserGroups(
183  $this->mTarget,
184  $request->getVal( 'user-reason' ),
185  $targetUser
186  );
187 
188  if ( $status->isOK() ) {
189  // Set session data for the success message
190  $session->set( 'specialUserrightsSaveSuccess', 1 );
191 
192  $out->redirect( $this->getSuccessURL() );
193  return;
194  } else {
195  // Print an error message and redisplay the form
196  $out->addWikiText( '<div class="error">' . $status->getWikiText() . '</div>' );
197  }
198  }
199  }
200 
201  // show some more forms
202  if ( $this->mTarget !== null ) {
203  $this->editUserGroupsForm( $this->mTarget );
204  }
205  }
206 
207  function getSuccessURL() {
208  return $this->getPageTitle( $this->mTarget )->getFullURL();
209  }
210 
217  public function canProcessExpiries() {
218  return true;
219  }
220 
230  public static function expiryToTimestamp( $expiry ) {
231  if ( wfIsInfinity( $expiry ) ) {
232  return null;
233  }
234 
235  $unix = strtotime( $expiry );
236 
237  if ( !$unix || $unix === -1 ) {
238  return false;
239  }
240 
241  // @todo FIXME: Non-qualified absolute times are not in users specified timezone
242  // and there isn't notice about it in the ui (see ProtectionForm::getExpiry)
243  return wfTimestamp( TS_MW, $unix );
244  }
245 
255  protected function saveUserGroups( $username, $reason, $user ) {
256  $allgroups = $this->getAllGroups();
257  $addgroup = [];
258  $groupExpiries = []; // associative array of (group name => expiry)
259  $removegroup = [];
260  $existingUGMs = $user->getGroupMemberships();
261 
262  // This could possibly create a highly unlikely race condition if permissions are changed between
263  // when the form is loaded and when the form is saved. Ignoring it for the moment.
264  foreach ( $allgroups as $group ) {
265  // We'll tell it to remove all unchecked groups, and add all checked groups.
266  // Later on, this gets filtered for what can actually be removed
267  if ( $this->getRequest()->getCheck( "wpGroup-$group" ) ) {
268  $addgroup[] = $group;
269 
270  if ( $this->canProcessExpiries() ) {
271  // read the expiry information from the request
272  $expiryDropdown = $this->getRequest()->getVal( "wpExpiry-$group" );
273  if ( $expiryDropdown === 'existing' ) {
274  continue;
275  }
276 
277  if ( $expiryDropdown === 'other' ) {
278  $expiryValue = $this->getRequest()->getVal( "wpExpiry-$group-other" );
279  } else {
280  $expiryValue = $expiryDropdown;
281  }
282 
283  // validate the expiry
284  $groupExpiries[$group] = self::expiryToTimestamp( $expiryValue );
285 
286  if ( $groupExpiries[$group] === false ) {
287  return Status::newFatal( 'userrights-invalid-expiry', $group );
288  }
289 
290  // not allowed to have things expiring in the past
291  if ( $groupExpiries[$group] && $groupExpiries[$group] < wfTimestampNow() ) {
292  return Status::newFatal( 'userrights-expiry-in-past', $group );
293  }
294 
295  // if the user can only add this group (not remove it), the expiry time
296  // cannot be brought forward (T156784)
297  if ( !$this->canRemove( $group ) &&
298  isset( $existingUGMs[$group] ) &&
299  ( $existingUGMs[$group]->getExpiry() ?: 'infinity' ) >
300  ( $groupExpiries[$group] ?: 'infinity' )
301  ) {
302  return Status::newFatal( 'userrights-cannot-shorten-expiry', $group );
303  }
304  }
305  } else {
306  $removegroup[] = $group;
307  }
308  }
309 
310  $this->doSaveUserGroups( $user, $addgroup, $removegroup, $reason, [], $groupExpiries );
311 
312  return Status::newGood();
313  }
314 
328  function doSaveUserGroups( $user, $add, $remove, $reason = '', $tags = [],
329  $groupExpiries = []
330  ) {
331  // Validate input set...
332  $isself = $user->getName() == $this->getUser()->getName();
333  $groups = $user->getGroups();
334  $ugms = $user->getGroupMemberships();
335  $changeable = $this->changeableGroups();
336  $addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : [] );
337  $removable = array_merge( $changeable['remove'], $isself ? $changeable['remove-self'] : [] );
338 
339  $remove = array_unique(
340  array_intersect( (array)$remove, $removable, $groups ) );
341  $add = array_intersect( (array)$add, $addable );
342 
343  // add only groups that are not already present or that need their expiry updated,
344  // UNLESS the user can only add this group (not remove it) and the expiry time
345  // is being brought forward (T156784)
346  $add = array_filter( $add,
347  function ( $group ) use ( $groups, $groupExpiries, $removable, $ugms ) {
348  if ( isset( $groupExpiries[$group] ) &&
349  !in_array( $group, $removable ) &&
350  isset( $ugms[$group] ) &&
351  ( $ugms[$group]->getExpiry() ?: 'infinity' ) >
352  ( $groupExpiries[$group] ?: 'infinity' )
353  ) {
354  return false;
355  }
356  return !in_array( $group, $groups ) || array_key_exists( $group, $groupExpiries );
357  } );
358 
359  Hooks::run( 'ChangeUserGroups', [ $this->getUser(), $user, &$add, &$remove ] );
360 
361  $oldGroups = $groups;
362  $oldUGMs = $user->getGroupMemberships();
363  $newGroups = $oldGroups;
364 
365  // Remove groups, then add new ones/update expiries of existing ones
366  if ( $remove ) {
367  foreach ( $remove as $index => $group ) {
368  if ( !$user->removeGroup( $group ) ) {
369  unset( $remove[$index] );
370  }
371  }
372  $newGroups = array_diff( $newGroups, $remove );
373  }
374  if ( $add ) {
375  foreach ( $add as $index => $group ) {
376  $expiry = isset( $groupExpiries[$group] ) ? $groupExpiries[$group] : null;
377  if ( !$user->addGroup( $group, $expiry ) ) {
378  unset( $add[$index] );
379  }
380  }
381  $newGroups = array_merge( $newGroups, $add );
382  }
383  $newGroups = array_unique( $newGroups );
384  $newUGMs = $user->getGroupMemberships();
385 
386  // Ensure that caches are cleared
387  $user->invalidateCache();
388 
389  // update groups in external authentication database
390  Hooks::run( 'UserGroupsChanged', [ $user, $add, $remove, $this->getUser(),
391  $reason, $oldUGMs, $newUGMs ] );
393  'updateExternalDBGroups', [ $user, $add, $remove ]
394  );
395 
396  wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
397  wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
398  wfDebug( 'oldUGMs: ' . print_r( $oldUGMs, true ) . "\n" );
399  wfDebug( 'newUGMs: ' . print_r( $newUGMs, true ) . "\n" );
400  // Deprecated in favor of UserGroupsChanged hook
401  Hooks::run( 'UserRights', [ &$user, $add, $remove ], '1.26' );
402 
403  // Only add a log entry if something actually changed
404  if ( $newGroups != $oldGroups || $newUGMs != $oldUGMs ) {
405  $this->addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags, $oldUGMs, $newUGMs );
406  }
407 
408  return [ $add, $remove ];
409  }
410 
418  protected static function serialiseUgmForLog( $ugm ) {
419  if ( !$ugm instanceof UserGroupMembership ) {
420  return null;
421  }
422  return [ 'expiry' => $ugm->getExpiry() ];
423  }
424 
435  protected function addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags,
436  $oldUGMs, $newUGMs
437  ) {
438  // make sure $oldUGMs and $newUGMs are in the same order, and serialise
439  // each UGM object to a simplified array
440  $oldUGMs = array_map( function ( $group ) use ( $oldUGMs ) {
441  return isset( $oldUGMs[$group] ) ?
442  self::serialiseUgmForLog( $oldUGMs[$group] ) :
443  null;
444  }, $oldGroups );
445  $newUGMs = array_map( function ( $group ) use ( $newUGMs ) {
446  return isset( $newUGMs[$group] ) ?
447  self::serialiseUgmForLog( $newUGMs[$group] ) :
448  null;
449  }, $newGroups );
450 
451  $logEntry = new ManualLogEntry( 'rights', 'rights' );
452  $logEntry->setPerformer( $this->getUser() );
453  $logEntry->setTarget( $user->getUserPage() );
454  $logEntry->setComment( $reason );
455  $logEntry->setParameters( [
456  '4::oldgroups' => $oldGroups,
457  '5::newgroups' => $newGroups,
458  'oldmetadata' => $oldUGMs,
459  'newmetadata' => $newUGMs,
460  ] );
461  $logid = $logEntry->insert();
462  if ( count( $tags ) ) {
463  $logEntry->setTags( $tags );
464  }
465  $logEntry->publish( $logid );
466  }
467 
473  $status = $this->fetchUser( $username, true );
474  if ( !$status->isOK() ) {
475  $this->getOutput()->addWikiText( $status->getWikiText() );
476 
477  return;
478  } else {
479  $user = $status->value;
480  }
481 
482  $groups = $user->getGroups();
483  $groupMemberships = $user->getGroupMemberships();
484  $this->showEditUserGroupsForm( $user, $groups, $groupMemberships );
485 
486  // This isn't really ideal logging behavior, but let's not hide the
487  // interwiki logs if we're using them as is.
488  $this->showLogFragment( $user, $this->getOutput() );
489  }
490 
500  public function fetchUser( $username, $writing = true ) {
501  $parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
502  if ( count( $parts ) < 2 ) {
503  $name = trim( $username );
504  $database = '';
505  } else {
506  list( $name, $database ) = array_map( 'trim', $parts );
507 
508  if ( $database == wfWikiID() ) {
509  $database = '';
510  } else {
511  if ( $writing && !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
512  return Status::newFatal( 'userrights-no-interwiki' );
513  }
514  if ( !UserRightsProxy::validDatabase( $database ) ) {
515  return Status::newFatal( 'userrights-nodatabase', $database );
516  }
517  }
518  }
519 
520  if ( $name === '' ) {
521  return Status::newFatal( 'nouserspecified' );
522  }
523 
524  if ( $name[0] == '#' ) {
525  // Numeric ID can be specified...
526  // We'll do a lookup for the name internally.
527  $id = intval( substr( $name, 1 ) );
528 
529  if ( $database == '' ) {
530  $name = User::whoIs( $id );
531  } else {
532  $name = UserRightsProxy::whoIs( $database, $id );
533  }
534 
535  if ( !$name ) {
536  return Status::newFatal( 'noname' );
537  }
538  } else {
540  if ( $name === false ) {
541  // invalid name
542  return Status::newFatal( 'nosuchusershort', $username );
543  }
544  }
545 
546  if ( $database == '' ) {
548  } else {
549  $user = UserRightsProxy::newFromName( $database, $name );
550  }
551 
552  if ( !$user || $user->isAnon() ) {
553  return Status::newFatal( 'nosuchusershort', $username );
554  }
555 
556  if ( $user instanceof User &&
557  $user->isHidden() &&
558  !$user->isAllowed( 'hideuser' )
559  ) {
560  // Cannot see hidden users, pretend they don't exist
561  return Status::newFatal( 'nosuchusershort', $username );
562  }
563 
564  return Status::newGood( $user );
565  }
566 
574  public function makeGroupNameList( $ids ) {
575  if ( empty( $ids ) ) {
576  return $this->msg( 'rightsnone' )->inContentLanguage()->text();
577  } else {
578  return implode( ', ', $ids );
579  }
580  }
581 
585  function switchForm() {
586  $this->getOutput()->addModules( 'mediawiki.userSuggest' );
587 
588  $this->getOutput()->addHTML(
590  'form',
591  [
592  'method' => 'get',
593  'action' => wfScript(),
594  'name' => 'uluser',
595  'id' => 'mw-userrights-form1'
596  ]
597  ) .
598  Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
599  Xml::fieldset( $this->msg( 'userrights-lookup-user' )->text() ) .
601  $this->msg( 'userrights-user-editname' )->text(),
602  'user',
603  'username',
604  30,
605  str_replace( '_', ' ', $this->mTarget ),
606  [
607  'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
608  ] + (
609  // Set autofocus on blank input and error input
610  $this->mFetchedUser === null ? [ 'autofocus' => '' ] : []
611  )
612  ) . ' ' .
614  $this->msg( 'editusergroup' )->text()
615  ) .
616  Html::closeElement( 'fieldset' ) .
617  Html::closeElement( 'form' ) . "\n"
618  );
619  }
620 
630  protected function showEditUserGroupsForm( $user, $groups, $groupMemberships ) {
631  $list = $membersList = $tempList = $tempMembersList = [];
632  foreach ( $groupMemberships as $ugm ) {
633  $linkG = UserGroupMembership::getLink( $ugm, $this->getContext(), 'html' );
634  $linkM = UserGroupMembership::getLink( $ugm, $this->getContext(), 'html',
635  $user->getName() );
636  if ( $ugm->getExpiry() ) {
637  $tempList[] = $linkG;
638  $tempMembersList[] = $linkM;
639  } else {
640  $list[] = $linkG;
641  $membersList[] = $linkM;
642 
643  }
644  }
645 
646  $autoList = [];
647  $autoMembersList = [];
648  if ( $user instanceof User ) {
649  foreach ( Autopromote::getAutopromoteGroups( $user ) as $group ) {
650  $autoList[] = UserGroupMembership::getLink( $group, $this->getContext(), 'html' );
651  $autoMembersList[] = UserGroupMembership::getLink( $group, $this->getContext(),
652  'html', $user->getName() );
653  }
654  }
655 
656  $language = $this->getLanguage();
657  $displayedList = $this->msg( 'userrights-groupsmember-type' )
658  ->rawParams(
659  $language->commaList( array_merge( $tempList, $list ) ),
660  $language->commaList( array_merge( $tempMembersList, $membersList ) )
661  )->escaped();
662  $displayedAutolist = $this->msg( 'userrights-groupsmember-type' )
663  ->rawParams(
664  $language->commaList( $autoList ),
665  $language->commaList( $autoMembersList )
666  )->escaped();
667 
668  $grouplist = '';
669  $count = count( $list );
670  if ( $count > 0 ) {
671  $grouplist = $this->msg( 'userrights-groupsmember' )
672  ->numParams( $count )
673  ->params( $user->getName() )
674  ->parse();
675  $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
676  }
677 
678  $count = count( $autoList );
679  if ( $count > 0 ) {
680  $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto' )
681  ->numParams( $count )
682  ->params( $user->getName() )
683  ->parse();
684  $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
685  }
686 
687  $userToolLinks = Linker::userToolLinks(
688  $user->getId(),
689  $user->getName(),
690  false, /* default for redContribsWhenNoEdits */
691  Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
692  );
693 
694  list( $groupCheckboxes, $canChangeAny ) =
695  $this->groupCheckboxes( $groupMemberships, $user );
696  $this->getOutput()->addHTML(
698  'form',
699  [
700  'method' => 'post',
701  'action' => $this->getPageTitle()->getLocalURL(),
702  'name' => 'editGroup',
703  'id' => 'mw-userrights-form2'
704  ]
705  ) .
706  Html::hidden( 'user', $this->mTarget ) .
707  Html::hidden( 'wpEditToken', $this->getUser()->getEditToken( $this->mTarget ) ) .
708  Html::hidden(
709  'conflictcheck-originalgroups',
710  implode( ',', $user->getGroups() )
711  ) . // Conflict detection
712  Xml::openElement( 'fieldset' ) .
713  Xml::element(
714  'legend',
715  [],
716  $this->msg(
717  $canChangeAny ? 'userrights-editusergroup' : 'userrights-viewusergroup',
718  $user->getName()
719  )->text()
720  ) .
721  $this->msg(
722  $canChangeAny ? 'editinguser' : 'viewinguserrights'
723  )->params( wfEscapeWikiText( $user->getName() ) )
724  ->rawParams( $userToolLinks )->parse()
725  );
726  if ( $canChangeAny ) {
727  $conf = $this->getConfig();
728  $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
729  $this->getOutput()->addHTML(
730  $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
731  $grouplist .
732  $groupCheckboxes .
733  Xml::openElement( 'table', [ 'id' => 'mw-userrights-table-outer' ] ) .
734  "<tr>
735  <td class='mw-label'>" .
736  Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) .
737  "</td>
738  <td class='mw-input'>" .
739  Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ), [
740  'id' => 'wpReason',
741  // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
742  // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
743  // Unicode codepoints (or 255 UTF-8 bytes for old schema).
744  'maxlength' => $oldCommentSchema ? 255 : CommentStore::COMMENT_CHARACTER_LIMIT,
745  ] ) .
746  "</td>
747  </tr>
748  <tr>
749  <td></td>
750  <td class='mw-submit'>" .
751  Xml::submitButton( $this->msg( 'saveusergroups', $user->getName() )->text(),
752  [ 'name' => 'saveusergroups' ] +
753  Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
754  ) .
755  "</td>
756  </tr>" .
757  Xml::closeElement( 'table' ) . "\n"
758  );
759  } else {
760  $this->getOutput()->addHTML( $grouplist );
761  }
762  $this->getOutput()->addHTML(
763  Xml::closeElement( 'fieldset' ) .
764  Xml::closeElement( 'form' ) . "\n"
765  );
766  }
767 
772  protected static function getAllGroups() {
773  return User::getAllGroups();
774  }
775 
785  private function groupCheckboxes( $usergroups, $user ) {
786  $allgroups = $this->getAllGroups();
787  $ret = '';
788 
789  // Get the list of preset expiry times from the system message
790  $expiryOptionsMsg = $this->msg( 'userrights-expiry-options' )->inContentLanguage();
791  $expiryOptions = $expiryOptionsMsg->isDisabled() ?
792  [] :
793  explode( ',', $expiryOptionsMsg->text() );
794 
795  // Put all column info into an associative array so that extensions can
796  // more easily manage it.
797  $columns = [ 'unchangeable' => [], 'changeable' => [] ];
798 
799  foreach ( $allgroups as $group ) {
800  $set = isset( $usergroups[$group] );
801  // Users who can add the group, but not remove it, can only lengthen
802  // expiries, not shorten them. So they should only see the expiry
803  // dropdown if the group currently has a finite expiry
804  $canOnlyLengthenExpiry = ( $set && $this->canAdd( $group ) &&
805  !$this->canRemove( $group ) && $usergroups[$group]->getExpiry() );
806  // Should the checkbox be disabled?
807  $disabledCheckbox = !(
808  ( $set && $this->canRemove( $group ) ) ||
809  ( !$set && $this->canAdd( $group ) ) );
810  // Should the expiry elements be disabled?
811  $disabledExpiry = $disabledCheckbox && !$canOnlyLengthenExpiry;
812  // Do we need to point out that this action is irreversible?
813  $irreversible = !$disabledCheckbox && (
814  ( $set && !$this->canAdd( $group ) ) ||
815  ( !$set && !$this->canRemove( $group ) ) );
816 
817  $checkbox = [
818  'set' => $set,
819  'disabled' => $disabledCheckbox,
820  'disabled-expiry' => $disabledExpiry,
821  'irreversible' => $irreversible
822  ];
823 
824  if ( $disabledCheckbox && $disabledExpiry ) {
825  $columns['unchangeable'][$group] = $checkbox;
826  } else {
827  $columns['changeable'][$group] = $checkbox;
828  }
829  }
830 
831  // Build the HTML table
832  $ret .= Xml::openElement( 'table', [ 'class' => 'mw-userrights-groups' ] ) .
833  "<tr>\n";
834  foreach ( $columns as $name => $column ) {
835  if ( $column === [] ) {
836  continue;
837  }
838  // Messages: userrights-changeable-col, userrights-unchangeable-col
839  $ret .= Xml::element(
840  'th',
841  null,
842  $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text()
843  );
844  }
845 
846  $ret .= "</tr>\n<tr>\n";
847  foreach ( $columns as $column ) {
848  if ( $column === [] ) {
849  continue;
850  }
851  $ret .= "\t<td style='vertical-align:top;'>\n";
852  foreach ( $column as $group => $checkbox ) {
853  $attr = [ 'class' => 'mw-userrights-groupcheckbox' ];
854  if ( $checkbox['disabled'] ) {
855  $attr['disabled'] = 'disabled';
856  }
857 
858  $member = UserGroupMembership::getGroupMemberName( $group, $user->getName() );
859  if ( $checkbox['irreversible'] ) {
860  $text = $this->msg( 'userrights-irreversible-marker', $member )->text();
861  } elseif ( $checkbox['disabled'] && !$checkbox['disabled-expiry'] ) {
862  $text = $this->msg( 'userrights-no-shorten-expiry-marker', $member )->text();
863  } else {
864  $text = $member;
865  }
866  $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
867  "wpGroup-" . $group, $checkbox['set'], $attr );
868 
869  if ( $this->canProcessExpiries() ) {
870  $uiUser = $this->getUser();
871  $uiLanguage = $this->getLanguage();
872 
873  $currentExpiry = isset( $usergroups[$group] ) ?
874  $usergroups[$group]->getExpiry() :
875  null;
876 
877  // If the user can't modify the expiry, print the current expiry below
878  // it in plain text. Otherwise provide UI to set/change the expiry
879  if ( $checkbox['set'] &&
880  ( $checkbox['irreversible'] || $checkbox['disabled-expiry'] )
881  ) {
882  if ( $currentExpiry ) {
883  $expiryFormatted = $uiLanguage->userTimeAndDate( $currentExpiry, $uiUser );
884  $expiryFormattedD = $uiLanguage->userDate( $currentExpiry, $uiUser );
885  $expiryFormattedT = $uiLanguage->userTime( $currentExpiry, $uiUser );
886  $expiryHtml = $this->msg( 'userrights-expiry-current' )->params(
887  $expiryFormatted, $expiryFormattedD, $expiryFormattedT )->text();
888  } else {
889  $expiryHtml = $this->msg( 'userrights-expiry-none' )->text();
890  }
891  // T171345: Add a hidden form element so that other groups can still be manipulated,
892  // otherwise saving errors out with an invalid expiry time for this group.
893  $expiryHtml .= Html::Hidden( "wpExpiry-$group",
894  $currentExpiry ? 'existing' : 'infinite' );
895  $expiryHtml .= "<br />\n";
896  } else {
897  $expiryHtml = Xml::element( 'span', null,
898  $this->msg( 'userrights-expiry' )->text() );
899  $expiryHtml .= Xml::openElement( 'span' );
900 
901  // add a form element to set the expiry date
902  $expiryFormOptions = new XmlSelect(
903  "wpExpiry-$group",
904  "mw-input-wpExpiry-$group", // forward compatibility with HTMLForm
905  $currentExpiry ? 'existing' : 'infinite'
906  );
907  if ( $checkbox['disabled-expiry'] ) {
908  $expiryFormOptions->setAttribute( 'disabled', 'disabled' );
909  }
910 
911  if ( $currentExpiry ) {
912  $timestamp = $uiLanguage->userTimeAndDate( $currentExpiry, $uiUser );
913  $d = $uiLanguage->userDate( $currentExpiry, $uiUser );
914  $t = $uiLanguage->userTime( $currentExpiry, $uiUser );
915  $existingExpiryMessage = $this->msg( 'userrights-expiry-existing',
916  $timestamp, $d, $t );
917  $expiryFormOptions->addOption( $existingExpiryMessage->text(), 'existing' );
918  }
919 
920  $expiryFormOptions->addOption(
921  $this->msg( 'userrights-expiry-none' )->text(),
922  'infinite'
923  );
924  $expiryFormOptions->addOption(
925  $this->msg( 'userrights-expiry-othertime' )->text(),
926  'other'
927  );
928  foreach ( $expiryOptions as $option ) {
929  if ( strpos( $option, ":" ) === false ) {
930  $displayText = $value = $option;
931  } else {
932  list( $displayText, $value ) = explode( ":", $option );
933  }
934  $expiryFormOptions->addOption( $displayText, htmlspecialchars( $value ) );
935  }
936 
937  // Add expiry dropdown
938  $expiryHtml .= $expiryFormOptions->getHTML() . '<br />';
939 
940  // Add custom expiry field
941  $attribs = [
942  'id' => "mw-input-wpExpiry-$group-other",
943  'class' => 'mw-userrights-expiryfield',
944  ];
945  if ( $checkbox['disabled-expiry'] ) {
946  $attribs['disabled'] = 'disabled';
947  }
948  $expiryHtml .= Xml::input( "wpExpiry-$group-other", 30, '', $attribs );
949 
950  // If the user group is set but the checkbox is disabled, mimic a
951  // checked checkbox in the form submission
952  if ( $checkbox['set'] && $checkbox['disabled'] ) {
953  $expiryHtml .= Html::hidden( "wpGroup-$group", 1 );
954  }
955 
956  $expiryHtml .= Xml::closeElement( 'span' );
957  }
958 
959  $divAttribs = [
960  'id' => "mw-userrights-nested-wpGroup-$group",
961  'class' => 'mw-userrights-nested',
962  ];
963  $checkboxHtml .= "\t\t\t" . Xml::tags( 'div', $divAttribs, $expiryHtml ) . "\n";
964  }
965  $ret .= "\t\t" . ( ( $checkbox['disabled'] && $checkbox['disabled-expiry'] )
966  ? Xml::tags( 'div', [ 'class' => 'mw-userrights-disabled' ], $checkboxHtml )
967  : Xml::tags( 'div', [], $checkboxHtml )
968  ) . "\n";
969  }
970  $ret .= "\t</td>\n";
971  }
972  $ret .= Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' );
973 
974  return [ $ret, (bool)$columns['changeable'] ];
975  }
976 
981  private function canRemove( $group ) {
982  $groups = $this->changeableGroups();
983 
984  return in_array(
985  $group,
986  $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] )
987  );
988  }
989 
994  private function canAdd( $group ) {
995  $groups = $this->changeableGroups();
996 
997  return in_array(
998  $group,
999  $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] )
1000  );
1001  }
1002 
1013  function changeableGroups() {
1014  return $this->getUser()->changeableGroups();
1015  }
1016 
1023  protected function showLogFragment( $user, $output ) {
1024  $rightsLogPage = new LogPage( 'rights' );
1025  $output->addHTML( Xml::element( 'h2', null, $rightsLogPage->getName()->text() ) );
1026  LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage() );
1027  }
1028 
1037  public function prefixSearchSubpages( $search, $limit, $offset ) {
1038  $user = User::newFromName( $search );
1039  if ( !$user ) {
1040  // No prefix suggestion for invalid user
1041  return [];
1042  }
1043  // Autocomplete subpage as user list - public to allow caching
1044  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
1045  }
1046 
1047  protected function getGroupName() {
1048  return 'users';
1049  }
1050 }
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:247
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:675
UserrightsPage\canRemove
canRemove( $group)
Definition: SpecialUserrights.php:981
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:793
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
UserBlockedError
Show an error when the user tries to do something whilst blocked.
Definition: UserBlockedError.php:27
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:722
UserrightsPage\editUserGroupsForm
editUserGroupsForm( $username)
Edit user groups membership.
Definition: SpecialUserrights.php:472
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$output
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2255
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:359
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:18
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1980
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:2005
UserNamePrefixSearch\search
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
Definition: UserNamePrefixSearch.php:39
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:864
Autopromote\getAutopromoteGroups
static getAutopromoteGroups(User $user)
Get the groups for the given user based on $wgAutopromote.
Definition: Autopromote.php:35
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:68
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:591
UserrightsPage\switchForm
switchForm()
Output a form to allow searching for a user.
Definition: SpecialUserrights.php:585
SpecialPage\getSkin
getSkin()
Shortcut to get the skin being used for this instance.
Definition: SpecialPage.php:742
UserrightsPage\execute
execute( $par)
Manage forms to be shown according to posted data.
Definition: SpecialUserrights.php:82
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:752
UserrightsPage\userCanChangeRights
userCanChangeRights( $targetUser, $checkIfSelf=true)
Check whether the current user (from context) can change the target user's rights.
Definition: SpecialUserrights.php:60
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
UserrightsPage\showLogFragment
showLogFragment( $user, $output)
Show a rights log fragment for the specified user.
Definition: SpecialUserrights.php:1023
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
UserrightsPage\$mFetchedUser
$mFetchedUser
Definition: SpecialUserrights.php:40
Linker\tooltipAndAccesskeyAttribs
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2135
XmlSelect
Class for generating HTML <select> or <datalist> elements.
Definition: XmlSelect.php:26
UserrightsPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUserrights.php:1047
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:610
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:309
UserrightsPage\expiryToTimestamp
static expiryToTimestamp( $expiry)
Converts a user group membership expiry string into a timestamp.
Definition: SpecialUserrights.php:230
UserrightsPage\prefixSearchSubpages
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Definition: SpecialUserrights.php:1037
UserrightsPage\getAllGroups
static getAllGroups()
Returns an array of all groups that may be edited.
Definition: SpecialUserrights.php:772
UserrightsPage
Special page to allow managing user group membership.
Definition: SpecialUserrights.php:29
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:832
UserrightsPage\showEditUserGroupsForm
showEditUserGroupsForm( $user, $groups, $groupMemberships)
Show the form to edit group memberships.
Definition: SpecialUserrights.php:630
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:761
UserrightsPage\serialiseUgmForLog
static serialiseUgmForLog( $ugm)
Serialise a UserGroupMembership object for storage in the log_params section of the logging table.
Definition: SpecialUserrights.php:418
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:2890
UserGroupMembership\getLink
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
Definition: UserGroupMembership.php:375
UserrightsPage\fetchUser
fetchUser( $username, $writing=true)
Normalize the input username, which may be local or remote, and return a user (or proxy) object for m...
Definition: SpecialUserrights.php:500
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:31
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
UserrightsPage\canProcessExpiries
canProcessExpiries()
Returns true if this user rights form can set and change user group expiries.
Definition: SpecialUserrights.php:217
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:527
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:732
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:616
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:2009
UserrightsPage\getSuccessURL
getSuccessURL()
Definition: SpecialUserrights.php:207
UserrightsPage\canAdd
canAdd( $group)
Definition: SpecialUserrights.php:994
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:994
MediaWiki\Auth\AuthManager\callLegacyAuthPlugin
static callLegacyAuthPlugin( $method, array $params, $return=null)
Call a legacy AuthPlugin method, if necessary.
Definition: AuthManager.php:239
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
UserrightsPage\__construct
__construct()
Definition: SpecialUserrights.php:43
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:695
MIGRATION_OLD
const MIGRATION_OLD
Definition: Defines.php:302
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:774
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:2014
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:2763
User\whoIs
static whoIs( $id)
Get the username corresponding to a given user ID.
Definition: User.php:863
$value
$value
Definition: styleTest.css.php:45
Linker\userToolLinks
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:931
Linker\TOOL_LINKS_EMAIL
const TOOL_LINKS_EMAIL
Definition: Linker.php:39
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
UserRightsProxy\validDatabase
static validDatabase( $database)
Confirm the selected database name is a valid local interwiki database name.
Definition: UserRightsProxy.php:62
UserrightsPage\groupCheckboxes
groupCheckboxes( $usergroups, $user)
Adds a table with checkboxes where you can select what groups to add/remove.
Definition: SpecialUserrights.php:785
wfIsInfinity
wfIsInfinity( $str)
Determine input string is represents as infinity.
Definition: GlobalFunctions.php:3321
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:712
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1643
UserrightsPage\doesWrites
doesWrites()
Indicates whether this special page may perform database writes.
Definition: SpecialUserrights.php:47
User\getAllGroups
static getAllGroups()
Return the set of defined explicit groups.
Definition: User.php:5085
$status
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition: hooks.txt:1255
UserrightsPage\saveUserGroups
saveUserGroups( $username, $reason, $user)
Save user groups changes in the database.
Definition: SpecialUserrights.php:255
CommentStore\COMMENT_CHARACTER_LIMIT
const COMMENT_CHARACTER_LIMIT
Maximum length of a comment in UTF-8 characters.
Definition: CommentStore.php:37
UserRightsProxy\newFromName
static newFromName( $database, $name, $ignoreInvalidDB=false)
Factory function; get a remote user entry by name.
Definition: UserRightsProxy.php:104
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
UserrightsPage\doSaveUserGroups
doSaveUserGroups( $user, $add, $remove, $reason='', $tags=[], $groupExpiries=[])
Save user groups changes in the database.
Definition: SpecialUserrights.php:328
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
UserrightsPage\makeGroupNameList
makeGroupNameList( $ids)
Definition: SpecialUserrights.php:574
User\getCanonicalName
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
Definition: User.php:1210
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:22
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:785
ManualLogEntry
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:432
UserrightsPage\$mTarget
$mTarget
The target of the local right-adjuster's interest.
Definition: SpecialUserrights.php:36
Xml\input
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:275
SpecialPage\checkReadOnly
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Definition: SpecialPage.php:319
$t
$t
Definition: testCompression.php:69
UserrightsPage\changeableGroups
changeableGroups()
Returns $this->getUser()->changeableGroups()
Definition: SpecialUserrights.php:1013
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2806
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
UserRightsProxy\whoIs
static whoIs( $database, $id, $ignoreInvalidDB=false)
Same as User::whoIs()
Definition: UserRightsProxy.php:75
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
UserrightsPage\addLogEntry
addLogEntry( $user, $oldGroups, $newGroups, $reason, $tags, $oldUGMs, $newUGMs)
Add a rights log entry for an action.
Definition: SpecialUserrights.php:435
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
Xml\inputLabel
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field with a label.
Definition: Xml.php:381
UserGroupMembership\getGroupMemberName
static getGroupMemberName( $group, $username)
Gets the localized name for a member of a group, if it exists.
Definition: UserGroupMembership.php:455
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:629
UserGroupMembership
Represents a "user group membership" – a specific instance of a user belonging to a group.
Definition: UserGroupMembership.php:37
UserrightsPage\$isself
$isself
Definition: SpecialUserrights.php:41
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:460
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:420