MediaWiki  1.27.2
SpecialUserrights.php
Go to the documentation of this file.
1 <?php
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  /*
35  * @var null|User $mFetchedUser The user object of the target username or null.
36  */
37  protected $mFetchedUser = null;
38  protected $isself = false;
39 
40  public function __construct() {
41  parent::__construct( 'Userrights' );
42  }
43 
44  public function doesWrites() {
45  return true;
46  }
47 
48  public function isRestricted() {
49  return true;
50  }
51 
52  public function userCanExecute( User $user ) {
53  return $this->userCanChangeRights( $user, false );
54  }
55 
61  public function userCanChangeRights( $user, $checkIfSelf = true ) {
62  $available = $this->changeableGroups();
63  if ( $user->getId() == 0 ) {
64  return false;
65  }
66 
67  return !empty( $available['add'] )
68  || !empty( $available['remove'] )
69  || ( ( $this->isself || !$checkIfSelf ) &&
70  ( !empty( $available['add-self'] )
71  || !empty( $available['remove-self'] ) ) );
72  }
73 
81  public function execute( $par ) {
82  // If the visitor doesn't have permissions to assign or remove
83  // any groups, it's a bit silly to give them the user search prompt.
84 
85  $user = $this->getUser();
86  $request = $this->getRequest();
87  $out = $this->getOutput();
88 
89  /*
90  * If the user is blocked and they only have "partial" access
91  * (e.g. they don't have the userrights permission), then don't
92  * allow them to use Special:UserRights.
93  */
94  if ( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
95  throw new UserBlockedError( $user->getBlock() );
96  }
97 
98  if ( $par !== null ) {
99  $this->mTarget = $par;
100  } else {
101  $this->mTarget = $request->getVal( 'user' );
102  }
103 
104  $available = $this->changeableGroups();
105 
106  if ( $this->mTarget === null ) {
107  /*
108  * If the user specified no target, and they can only
109  * edit their own groups, automatically set them as the
110  * target.
111  */
112  if ( !count( $available['add'] ) && !count( $available['remove'] ) ) {
113  $this->mTarget = $user->getName();
114  }
115  }
116 
117  if ( $this->mTarget !== null && User::getCanonicalName( $this->mTarget ) === $user->getName() ) {
118  $this->isself = true;
119  }
120 
121  $fetchedStatus = $this->fetchUser( $this->mTarget );
122  if ( $fetchedStatus->isOK() ) {
123  $this->mFetchedUser = $fetchedStatus->value;
124  if ( $this->mFetchedUser instanceof User ) {
125  // Set the 'relevant user' in the skin, so it displays links like Contributions,
126  // User logs, UserRights, etc.
127  $this->getSkin()->setRelevantUser( $this->mFetchedUser );
128  }
129  }
130 
131  if ( !$this->userCanChangeRights( $user, true ) ) {
132  if ( $this->isself && $request->getCheck( 'success' ) ) {
133  // bug 48609: if the user just removed its own rights, this would
134  // leads it in a "permissions error" page. In that case, show a
135  // message that it can't anymore use this page instead of an error
136  $this->setHeaders();
137  $out->wrapWikiMsg( "<div class=\"successbox\">\n$1\n</div>", 'userrights-removed-self' );
138  $out->returnToMain();
139 
140  return;
141  }
142 
143  // @todo FIXME: There may be intermediate groups we can mention.
144  $msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
145  throw new PermissionsError( null, [ [ $msg ] ] );
146  }
147 
148  // show a successbox, if the user rights was saved successfully
149  if ( $request->getCheck( 'success' ) && $this->mFetchedUser !== null ) {
150  $out->wrapWikiMsg(
151  "<div class=\"successbox\">\n$1\n</div>",
152  [ 'savedrights', $this->mFetchedUser->getName() ]
153  );
154  }
155 
156  $this->checkReadOnly();
157 
158  $this->setHeaders();
159  $this->outputHeader();
160 
161  $out->addModuleStyles( 'mediawiki.special' );
162  $this->addHelpLink( 'Help:Assigning permissions' );
163 
164  // show the general form
165  if ( count( $available['add'] ) || count( $available['remove'] ) ) {
166  $this->switchForm();
167  }
168 
169  if (
170  $request->wasPosted() &&
171  $request->getCheck( 'saveusergroups' ) &&
172  $this->mTarget !== null &&
173  $user->matchEditToken( $request->getVal( 'wpEditToken' ), $this->mTarget )
174  ) {
175  // save settings
176  if ( !$fetchedStatus->isOK() ) {
177  $this->getOutput()->addWikiText( $fetchedStatus->getWikiText() );
178 
179  return;
180  }
181 
182  $targetUser = $this->mFetchedUser;
183  if ( $targetUser instanceof User ) { // UserRightsProxy doesn't have this method (bug 61252)
184  $targetUser->clearInstanceCache(); // bug 38989
185  }
186 
187  if ( $request->getVal( 'conflictcheck-originalgroups' )
188  !== implode( ',', $targetUser->getGroups() )
189  ) {
190  $out->addWikiMsg( 'userrights-conflict' );
191  } else {
192  $this->saveUserGroups(
193  $this->mTarget,
194  $request->getVal( 'user-reason' ),
195  $targetUser
196  );
197 
198  $out->redirect( $this->getSuccessURL() );
199 
200  return;
201  }
202  }
203 
204  // show some more forms
205  if ( $this->mTarget !== null ) {
206  $this->editUserGroupsForm( $this->mTarget );
207  }
208  }
209 
210  function getSuccessURL() {
211  return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
212  }
213 
223  function saveUserGroups( $username, $reason, $user ) {
224  $allgroups = $this->getAllGroups();
225  $addgroup = [];
226  $removegroup = [];
227 
228  // This could possibly create a highly unlikely race condition if permissions are changed between
229  // when the form is loaded and when the form is saved. Ignoring it for the moment.
230  foreach ( $allgroups as $group ) {
231  // We'll tell it to remove all unchecked groups, and add all checked groups.
232  // Later on, this gets filtered for what can actually be removed
233  if ( $this->getRequest()->getCheck( "wpGroup-$group" ) ) {
234  $addgroup[] = $group;
235  } else {
236  $removegroup[] = $group;
237  }
238  }
239 
240  $this->doSaveUserGroups( $user, $addgroup, $removegroup, $reason );
241  }
242 
252  function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
253  // Validate input set...
254  $isself = $user->getName() == $this->getUser()->getName();
255  $groups = $user->getGroups();
256  $changeable = $this->changeableGroups();
257  $addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : [] );
258  $removable = array_merge( $changeable['remove'], $isself ? $changeable['remove-self'] : [] );
259 
260  $remove = array_unique(
261  array_intersect( (array)$remove, $removable, $groups ) );
262  $add = array_unique( array_diff(
263  array_intersect( (array)$add, $addable ),
264  $groups )
265  );
266 
267  $oldGroups = $user->getGroups();
268  $newGroups = $oldGroups;
269 
270  // Remove then add groups
271  if ( $remove ) {
272  foreach ( $remove as $index => $group ) {
273  if ( !$user->removeGroup( $group ) ) {
274  unset( $remove[$index] );
275  }
276  }
277  $newGroups = array_diff( $newGroups, $remove );
278  }
279  if ( $add ) {
280  foreach ( $add as $index => $group ) {
281  if ( !$user->addGroup( $group ) ) {
282  unset( $add[$index] );
283  }
284  }
285  $newGroups = array_merge( $newGroups, $add );
286  }
287  $newGroups = array_unique( $newGroups );
288 
289  // Ensure that caches are cleared
290  $user->invalidateCache();
291 
292  // update groups in external authentication database
293  Hooks::run( 'UserGroupsChanged', [ $user, $add, $remove, $this->getUser(), $reason ] );
295  'updateExternalDBGroups', [ $user, $add, $remove ]
296  );
297 
298  wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
299  wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
300  // Deprecated in favor of UserGroupsChanged hook
301  Hooks::run( 'UserRights', [ &$user, $add, $remove ], '1.26' );
302 
303  if ( $newGroups != $oldGroups ) {
304  $this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
305  }
306 
307  return [ $add, $remove ];
308  }
309 
317  function addLogEntry( $user, $oldGroups, $newGroups, $reason ) {
318  $logEntry = new ManualLogEntry( 'rights', 'rights' );
319  $logEntry->setPerformer( $this->getUser() );
320  $logEntry->setTarget( $user->getUserPage() );
321  $logEntry->setComment( $reason );
322  $logEntry->setParameters( [
323  '4::oldgroups' => $oldGroups,
324  '5::newgroups' => $newGroups,
325  ] );
326  $logid = $logEntry->insert();
327  $logEntry->publish( $logid );
328  }
329 
335  $status = $this->fetchUser( $username );
336  if ( !$status->isOK() ) {
337  $this->getOutput()->addWikiText( $status->getWikiText() );
338 
339  return;
340  } else {
341  $user = $status->value;
342  }
343 
344  $groups = $user->getGroups();
345 
346  $this->showEditUserGroupsForm( $user, $groups );
347 
348  // This isn't really ideal logging behavior, but let's not hide the
349  // interwiki logs if we're using them as is.
350  $this->showLogFragment( $user, $this->getOutput() );
351  }
352 
361  public function fetchUser( $username ) {
362  $parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
363  if ( count( $parts ) < 2 ) {
364  $name = trim( $username );
365  $database = '';
366  } else {
367  list( $name, $database ) = array_map( 'trim', $parts );
368 
369  if ( $database == wfWikiID() ) {
370  $database = '';
371  } else {
372  if ( !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
373  return Status::newFatal( 'userrights-no-interwiki' );
374  }
375  if ( !UserRightsProxy::validDatabase( $database ) ) {
376  return Status::newFatal( 'userrights-nodatabase', $database );
377  }
378  }
379  }
380 
381  if ( $name === '' ) {
382  return Status::newFatal( 'nouserspecified' );
383  }
384 
385  if ( $name[0] == '#' ) {
386  // Numeric ID can be specified...
387  // We'll do a lookup for the name internally.
388  $id = intval( substr( $name, 1 ) );
389 
390  if ( $database == '' ) {
391  $name = User::whoIs( $id );
392  } else {
393  $name = UserRightsProxy::whoIs( $database, $id );
394  }
395 
396  if ( !$name ) {
397  return Status::newFatal( 'noname' );
398  }
399  } else {
401  if ( $name === false ) {
402  // invalid name
403  return Status::newFatal( 'nosuchusershort', $username );
404  }
405  }
406 
407  if ( $database == '' ) {
409  } else {
410  $user = UserRightsProxy::newFromName( $database, $name );
411  }
412 
413  if ( !$user || $user->isAnon() ) {
414  return Status::newFatal( 'nosuchusershort', $username );
415  }
416 
417  return Status::newGood( $user );
418  }
419 
427  public function makeGroupNameList( $ids ) {
428  if ( empty( $ids ) ) {
429  return $this->msg( 'rightsnone' )->inContentLanguage()->text();
430  } else {
431  return implode( ', ', $ids );
432  }
433  }
434 
438  function switchForm() {
439  $this->getOutput()->addModules( 'mediawiki.userSuggest' );
440 
441  $this->getOutput()->addHTML(
443  'form',
444  [
445  'method' => 'get',
446  'action' => wfScript(),
447  'name' => 'uluser',
448  'id' => 'mw-userrights-form1'
449  ]
450  ) .
451  Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
452  Xml::fieldset( $this->msg( 'userrights-lookup-user' )->text() ) .
454  $this->msg( 'userrights-user-editname' )->text(),
455  'user',
456  'username',
457  30,
458  str_replace( '_', ' ', $this->mTarget ),
459  [
460  'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
461  ] + (
462  // Set autofocus on blank input and error input
463  $this->mFetchedUser === null ? [ 'autofocus' => '' ] : []
464  )
465  ) . ' ' .
467  $this->msg(
468  'editusergroup',
469  $this->mFetchedUser === null ? '[]' : $this->mFetchedUser->getName()
470  )->text()
471  ) .
472  Html::closeElement( 'fieldset' ) .
473  Html::closeElement( 'form' ) . "\n"
474  );
475  }
476 
485  protected function splitGroups( $groups ) {
486  list( $addable, $removable, $addself, $removeself ) = array_values( $this->changeableGroups() );
487 
488  $removable = array_intersect(
489  array_merge( $this->isself ? $removeself : [], $removable ),
490  $groups
491  ); // Can't remove groups the user doesn't have
492  $addable = array_diff(
493  array_merge( $this->isself ? $addself : [], $addable ),
494  $groups
495  ); // Can't add groups the user does have
496 
497  return [ $addable, $removable ];
498  }
499 
506  protected function showEditUserGroupsForm( $user, $groups ) {
507  $list = [];
508  $membersList = [];
509  foreach ( $groups as $group ) {
510  $list[] = self::buildGroupLink( $group );
511  $membersList[] = self::buildGroupMemberLink( $group );
512  }
513 
514  $autoList = [];
515  $autoMembersList = [];
516  if ( $user instanceof User ) {
517  foreach ( Autopromote::getAutopromoteGroups( $user ) as $group ) {
518  $autoList[] = self::buildGroupLink( $group );
519  $autoMembersList[] = self::buildGroupMemberLink( $group );
520  }
521  }
522 
523  $language = $this->getLanguage();
524  $displayedList = $this->msg( 'userrights-groupsmember-type' )
525  ->rawParams(
526  $language->listToText( $list ),
527  $language->listToText( $membersList )
528  )->escaped();
529  $displayedAutolist = $this->msg( 'userrights-groupsmember-type' )
530  ->rawParams(
531  $language->listToText( $autoList ),
532  $language->listToText( $autoMembersList )
533  )->escaped();
534 
535  $grouplist = '';
536  $count = count( $list );
537  if ( $count > 0 ) {
538  $grouplist = $this->msg( 'userrights-groupsmember' )
539  ->numParams( $count )
540  ->params( $user->getName() )
541  ->parse();
542  $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
543  }
544 
545  $count = count( $autoList );
546  if ( $count > 0 ) {
547  $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto' )
548  ->numParams( $count )
549  ->params( $user->getName() )
550  ->parse();
551  $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
552  }
553 
554  $userToolLinks = Linker::userToolLinks(
555  $user->getId(),
556  $user->getName(),
557  false, /* default for redContribsWhenNoEdits */
558  Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
559  );
560 
561  $this->getOutput()->addHTML(
563  'form',
564  [
565  'method' => 'post',
566  'action' => $this->getPageTitle()->getLocalURL(),
567  'name' => 'editGroup',
568  'id' => 'mw-userrights-form2'
569  ]
570  ) .
571  Html::hidden( 'user', $this->mTarget ) .
572  Html::hidden( 'wpEditToken', $this->getUser()->getEditToken( $this->mTarget ) ) .
573  Html::hidden(
574  'conflictcheck-originalgroups',
575  implode( ',', $user->getGroups() )
576  ) . // Conflict detection
577  Xml::openElement( 'fieldset' ) .
578  Xml::element(
579  'legend',
580  [],
581  $this->msg( 'userrights-editusergroup', $user->getName() )->text()
582  ) .
583  $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
584  ->rawParams( $userToolLinks )->parse() .
585  $this->msg( 'userrights-groups-help', $user->getName() )->parse() .
586  $grouplist .
587  $this->groupCheckboxes( $groups, $user ) .
588  Xml::openElement( 'table', [ 'id' => 'mw-userrights-table-outer' ] ) .
589  "<tr>
590  <td class='mw-label'>" .
591  Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) .
592  "</td>
593  <td class='mw-input'>" .
594  Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ),
595  [ 'id' => 'wpReason', 'maxlength' => 255 ] ) .
596  "</td>
597  </tr>
598  <tr>
599  <td></td>
600  <td class='mw-submit'>" .
601  Xml::submitButton( $this->msg( 'saveusergroups', $user->getName() )->text(),
602  [ 'name' => 'saveusergroups' ] +
603  Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
604  ) .
605  "</td>
606  </tr>" .
607  Xml::closeElement( 'table' ) . "\n" .
608  Xml::closeElement( 'fieldset' ) .
609  Xml::closeElement( 'form' ) . "\n"
610  );
611  }
612 
619  private static function buildGroupLink( $group ) {
620  return User::makeGroupLinkHTML( $group, User::getGroupName( $group ) );
621  }
622 
629  private static function buildGroupMemberLink( $group ) {
630  return User::makeGroupLinkHTML( $group, User::getGroupMember( $group ) );
631  }
632 
637  protected static function getAllGroups() {
638  return User::getAllGroups();
639  }
640 
649  private function groupCheckboxes( $usergroups, $user ) {
650  $allgroups = $this->getAllGroups();
651  $ret = '';
652 
653  // Put all column info into an associative array so that extensions can
654  // more easily manage it.
655  $columns = [ 'unchangeable' => [], 'changeable' => [] ];
656 
657  foreach ( $allgroups as $group ) {
658  $set = in_array( $group, $usergroups );
659  // Should the checkbox be disabled?
660  $disabled = !(
661  ( $set && $this->canRemove( $group ) ) ||
662  ( !$set && $this->canAdd( $group ) ) );
663  // Do we need to point out that this action is irreversible?
664  $irreversible = !$disabled && (
665  ( $set && !$this->canAdd( $group ) ) ||
666  ( !$set && !$this->canRemove( $group ) ) );
667 
668  $checkbox = [
669  'set' => $set,
670  'disabled' => $disabled,
671  'irreversible' => $irreversible
672  ];
673 
674  if ( $disabled ) {
675  $columns['unchangeable'][$group] = $checkbox;
676  } else {
677  $columns['changeable'][$group] = $checkbox;
678  }
679  }
680 
681  // Build the HTML table
682  $ret .= Xml::openElement( 'table', [ 'class' => 'mw-userrights-groups' ] ) .
683  "<tr>\n";
684  foreach ( $columns as $name => $column ) {
685  if ( $column === [] ) {
686  continue;
687  }
688  // Messages: userrights-changeable-col, userrights-unchangeable-col
689  $ret .= Xml::element(
690  'th',
691  null,
692  $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text()
693  );
694  }
695 
696  $ret .= "</tr>\n<tr>\n";
697  foreach ( $columns as $column ) {
698  if ( $column === [] ) {
699  continue;
700  }
701  $ret .= "\t<td style='vertical-align:top;'>\n";
702  foreach ( $column as $group => $checkbox ) {
703  $attr = $checkbox['disabled'] ? [ 'disabled' => 'disabled' ] : [];
704 
705  $member = User::getGroupMember( $group, $user->getName() );
706  if ( $checkbox['irreversible'] ) {
707  $text = $this->msg( 'userrights-irreversible-marker', $member )->text();
708  } else {
709  $text = $member;
710  }
711  $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
712  "wpGroup-" . $group, $checkbox['set'], $attr );
713  $ret .= "\t\t" . ( $checkbox['disabled']
714  ? Xml::tags( 'span', [ 'class' => 'mw-userrights-disabled' ], $checkboxHtml )
715  : $checkboxHtml
716  ) . "<br />\n";
717  }
718  $ret .= "\t</td>\n";
719  }
720  $ret .= Xml::closeElement( 'tr' ) . Xml::closeElement( 'table' );
721 
722  return $ret;
723  }
724 
729  private function canRemove( $group ) {
730  // $this->changeableGroups()['remove'] doesn't work, of course. Thanks, PHP.
731  $groups = $this->changeableGroups();
732 
733  return in_array(
734  $group,
735  $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] )
736  );
737  }
738 
743  private function canAdd( $group ) {
744  $groups = $this->changeableGroups();
745 
746  return in_array(
747  $group,
748  $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] )
749  );
750  }
751 
762  function changeableGroups() {
763  return $this->getUser()->changeableGroups();
764  }
765 
772  protected function showLogFragment( $user, $output ) {
773  $rightsLogPage = new LogPage( 'rights' );
774  $output->addHTML( Xml::element( 'h2', null, $rightsLogPage->getName()->text() ) );
775  LogEventsList::showLogExtract( $output, 'rights', $user->getUserPage() );
776  }
777 
786  public function prefixSearchSubpages( $search, $limit, $offset ) {
787  $user = User::newFromName( $search );
788  if ( !$user ) {
789  // No prefix suggestion for invalid user
790  return [];
791  }
792  // Autocomplete subpage as user list - public to allow caching
793  return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
794  }
795 
796  protected function getGroupName() {
797  return 'users';
798  }
799 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:568
showEditUserGroupsForm($user, $groups)
Show the form to edit group memberships.
static closeElement($element)
Returns "".
Definition: Html.php:306
static whoIs($id)
Get the username corresponding to a given user ID.
Definition: User.php:750
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
userCanExecute(User $user)
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:762
the array() calling protocol came about after MediaWiki 1.4rc1.
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
static buildGroupLink($group)
Format a link to a group description page.
static whoIs($database, $id, $ignoreInvalidDB=false)
Same as User::whoIs()
static getCanonicalName($name, $validate= 'valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid...
Definition: User.php:1050
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:1798
static newFromName($database, $name, $ignoreInvalidDB=false)
Factory function; get a remote user entry by name.
changeableGroups()
Returns $this->getUser()->changeableGroups()
fetchUser($username)
Normalize the input username, which may be local or remote, and return a user (or proxy) object for m...
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:759
static input($name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:275
splitGroups($groups)
Go through used and available groups and return the ones that this form will be able to manipulate ba...
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
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
static newFatal($message)
Factory function for fatal errors.
Definition: Status.php:89
userCanChangeRights($user, $checkIfSelf=true)
static makeGroupLinkHTML($group, $text= '')
Create a link to the group in HTML, if available; else return the group name.
Definition: User.php:4708
static tooltipAndAccesskeyAttribs($name, array $msgParams=[])
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2335
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:460
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:359
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
static getAllGroups()
Return the set of defined explicit groups.
Definition: User.php:4644
outputHeader($summaryMessageKey= '')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Class to simplify the use of log pages.
Definition: LogPage.php:32
static fieldset($legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:578
static closeElement($element)
Shortcut to close an XML element.
Definition: Xml.php:118
prefixSearchSubpages($search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
Parent class for all special pages.
Definition: SpecialPage.php:36
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:248
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
switchForm()
Output a form to allow searching for a user.
execute($par)
Manage forms to be shown according to posted data.
static validDatabase($database)
Confirm the selected database name is a valid local interwiki database name.
static search($audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static openElement($element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
getSkin()
Shortcut to get the skin being used for this instance.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
doSaveUserGroups($user, $add, $remove, $reason= '')
Save user groups changes in the database.
static getAutopromoteGroups(User $user)
Get the groups for the given user based on $wgAutopromote.
Definition: Autopromote.php:35
static callLegacyAuthPlugin($method, array $params, $return=null)
Call a legacy AuthPlugin method, if necessary.
static buildGroupMemberLink($group)
Format a link to a group member description page.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
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:12
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Show an error when the user tries to do something whilst blocked.
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:9
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 local account $user
Definition: hooks.txt:242
static getGroupName($group)
Get the localized descriptive name for a group, if it exists.
Definition: User.php:4621
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition: hooks.txt:1004
groupCheckboxes($usergroups, $user)
Adds a table with checkboxes where you can select what groups to add/remove.
static getAllGroups()
Returns an array of all groups that may be edited.
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:35
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:762
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
static getGroupMember($group, $username= '#')
Get the localized descriptive name for a member of a group, if it exists.
Definition: User.php:4633
editUserGroupsForm($username)
Edit user groups membership.
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:394
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2418
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
addLogEntry($user, $oldGroups, $newGroups, $reason)
Add a rights log entry for an action.
Show an error when a user tries to do something they do not have the necessary permissions for...
static userToolLinks($userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
Definition: Linker.php:1133
getLanguage()
Shortcut to get user's language.
saveUserGroups($username, $reason, $user)
Save user groups changes in the database.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired 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 inclusive $limit
Definition: hooks.txt:1004
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1004
Special page to allow managing user group membership.
$count
static checkLabel($label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:420
getRequest()
Get the WebRequest being used for this instance.
showLogFragment($user, $output)
Show a rights log fragment for the specified user.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
static newGood($value=null)
Factory function for good results.
Definition: Status.php:101
const TOOL_LINKS_EMAIL
Definition: Linker.php:38
getPageTitle($subpage=false)
Get a self-referential title object.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310