44 parent::__construct(
'Userrights' );
64 if ( $targetUser->getId() == 0 ) {
68 return !empty( $available[
'add'] )
69 || !empty( $available[
'remove'] )
70 || ( (
$isself || !$checkIfSelf ) &&
71 ( !empty( $available[
'add-self'] )
72 || !empty( $available[
'remove-self'] ) ) );
88 $out->addModules( [
'mediawiki.special.userrights' ] );
90 $this->mTarget = $par ??
$request->getVal(
'user' );
92 if ( is_string( $this->mTarget ) ) {
93 $this->mTarget = trim( $this->mTarget );
100 $fetchedStatus = $this->
fetchUser( $this->mTarget,
true );
101 if ( $fetchedStatus->isOK() ) {
102 $this->mFetchedUser = $fetchedStatus->value;
103 if ( $this->mFetchedUser instanceof
User ) {
106 $this->
getSkin()->setRelevantUser( $this->mFetchedUser );
112 $session->get(
'specialUserrightsSaveSuccess' ) &&
113 $this->mFetchedUser !==
null
116 $session->remove(
'specialUserrightsSaveSuccess' );
118 $out->addModuleStyles(
'mediawiki.notification.convertmessagebox.styles' );
123 'class' =>
'mw-notify-success successbox',
124 'id' =>
'mw-preferences-success',
125 'data-mw-autohide' =>
'false',
130 $this->
msg(
'savedrights', $this->mFetchedUser->getName() )->text()
139 $out->addModuleStyles(
'mediawiki.special' );
140 $this->
addHelpLink(
'Help:Assigning permissions' );
146 $request->getCheck(
'saveusergroups' ) &&
147 $this->mTarget !==
null &&
148 $user->matchEditToken(
$request->getVal(
'wpEditToken' ), $this->mTarget )
155 if (
$user->isBlocked() && !
$user->isAllowed(
'userrights' ) ) {
162 if ( !$fetchedStatus->isOK() ) {
163 $this->
getOutput()->addWikiTextAsInterface( $fetchedStatus->getWikiText() );
169 if ( $targetUser instanceof
User ) {
170 $targetUser->clearInstanceCache();
173 $conflictCheck =
$request->getVal(
'conflictcheck-originalgroups' );
174 $conflictCheck = ( $conflictCheck ===
'' ) ? [] : explode(
',', $conflictCheck );
175 $userGroups = $targetUser->getGroups();
177 if ( $userGroups !== $conflictCheck ) {
178 $out->wrapWikiMsg(
'<span class="error">$1</span>',
'userrights-conflict' );
188 $session->set(
'specialUserrightsSaveSuccess', 1 );
194 $out->wrapWikiTextAsInterface(
'error',
$status->getWikiText() );
200 if ( $this->mTarget !==
null ) {
206 return $this->
getPageTitle( $this->mTarget )->getFullURL();
233 $unix = strtotime( $expiry );
235 if ( !$unix || $unix === -1 ) {
258 $existingUGMs =
$user->getGroupMemberships();
262 foreach ( $allgroups
as $group ) {
265 if ( $this->
getRequest()->getCheck(
"wpGroup-$group" ) ) {
266 $addgroup[] = $group;
270 $expiryDropdown = $this->
getRequest()->getVal(
"wpExpiry-$group" );
271 if ( $expiryDropdown ===
'existing' ) {
275 if ( $expiryDropdown ===
'other' ) {
276 $expiryValue = $this->
getRequest()->getVal(
"wpExpiry-$group-other" );
278 $expiryValue = $expiryDropdown;
284 if ( $groupExpiries[$group] ===
false ) {
285 return Status::newFatal(
'userrights-invalid-expiry', $group );
289 if ( $groupExpiries[$group] && $groupExpiries[$group] <
wfTimestampNow() ) {
290 return Status::newFatal(
'userrights-expiry-in-past', $group );
296 isset( $existingUGMs[$group] ) &&
297 ( $existingUGMs[$group]->getExpiry() ?:
'infinity' ) >
298 ( $groupExpiries[$group] ?:
'infinity' )
300 return Status::newFatal(
'userrights-cannot-shorten-expiry', $group );
304 $removegroup[] = $group;
310 return Status::newGood();
331 $groups =
$user->getGroups();
332 $ugms =
$user->getGroupMemberships();
334 $addable = array_merge( $changeable[
'add'],
$isself ? $changeable[
'add-self'] : [] );
335 $removable = array_merge( $changeable[
'remove'],
$isself ? $changeable[
'remove-self'] : [] );
337 $remove = array_unique(
338 array_intersect( (
array)$remove, $removable, $groups ) );
339 $add = array_intersect( (
array)$add, $addable );
344 $add = array_filter( $add,
345 function ( $group )
use ( $groups, $groupExpiries, $removable, $ugms ) {
346 if ( isset( $groupExpiries[$group] ) &&
347 !in_array( $group, $removable ) &&
348 isset( $ugms[$group] ) &&
349 ( $ugms[$group]->getExpiry() ?:
'infinity' ) >
350 ( $groupExpiries[$group] ?:
'infinity' )
354 return !in_array( $group, $groups ) || array_key_exists( $group, $groupExpiries );
357 Hooks::run(
'ChangeUserGroups', [ $this->
getUser(),
$user, &$add, &$remove ] );
359 $oldGroups = $groups;
360 $oldUGMs =
$user->getGroupMemberships();
361 $newGroups = $oldGroups;
365 foreach ( $remove
as $index => $group ) {
366 if ( !
$user->removeGroup( $group ) ) {
367 unset( $remove[$index] );
370 $newGroups = array_diff( $newGroups, $remove );
373 foreach ( $add
as $index => $group ) {
374 $expiry = $groupExpiries[$group] ??
null;
375 if ( !
$user->addGroup( $group, $expiry ) ) {
376 unset( $add[$index] );
379 $newGroups = array_merge( $newGroups, $add );
381 $newGroups = array_unique( $newGroups );
382 $newUGMs =
$user->getGroupMemberships();
385 $user->invalidateCache();
388 Hooks::run(
'UserGroupsChanged', [
$user, $add, $remove, $this->
getUser(),
389 $reason, $oldUGMs, $newUGMs ] );
391 wfDebug(
'oldGroups: ' . print_r( $oldGroups,
true ) .
"\n" );
392 wfDebug(
'newGroups: ' . print_r( $newGroups,
true ) .
"\n" );
393 wfDebug(
'oldUGMs: ' . print_r( $oldUGMs,
true ) .
"\n" );
394 wfDebug(
'newUGMs: ' . print_r( $newUGMs,
true ) .
"\n" );
396 Hooks::run(
'UserRights', [ &
$user, $add, $remove ],
'1.26' );
399 if ( $newGroups != $oldGroups || $newUGMs != $oldUGMs ) {
400 $this->
addLogEntry(
$user, $oldGroups, $newGroups, $reason, $tags, $oldUGMs, $newUGMs );
403 return [ $add, $remove ];
417 return [
'expiry' => $ugm->getExpiry() ];
435 $oldUGMs = array_map(
function ( $group )
use ( $oldUGMs ) {
436 return isset( $oldUGMs[$group] ) ?
440 $newUGMs = array_map(
function ( $group )
use ( $newUGMs ) {
441 return isset( $newUGMs[$group] ) ?
447 $logEntry->setPerformer( $this->
getUser() );
448 $logEntry->setTarget(
$user->getUserPage() );
449 $logEntry->setComment( $reason );
450 $logEntry->setParameters( [
451 '4::oldgroups' => $oldGroups,
452 '5::newgroups' => $newGroups,
453 'oldmetadata' => $oldUGMs,
454 'newmetadata' => $newUGMs,
456 $logid = $logEntry->insert();
457 if ( count( $tags ) ) {
458 $logEntry->setTags( $tags );
460 $logEntry->publish( $logid );
477 $groups =
$user->getGroups();
478 $groupMemberships =
$user->getGroupMemberships();
496 $parts = explode( $this->
getConfig()->
get(
'UserrightsInterwikiDelimiter' ),
$username );
497 if ( count( $parts ) < 2 ) {
501 list(
$name, $wikiId ) = array_map(
'trim', $parts );
503 if ( WikiMap::isCurrentWikiId( $wikiId ) ) {
506 if ( $writing && !$this->
getUser()->isAllowed(
'userrights-interwiki' ) ) {
507 return Status::newFatal(
'userrights-no-interwiki' );
510 return Status::newFatal(
'userrights-nodatabase', $wikiId );
515 if (
$name ===
'' ) {
516 return Status::newFatal(
'nouserspecified' );
519 if (
$name[0] ==
'#' ) {
522 $id = intval( substr(
$name, 1 ) );
524 if ( $wikiId ==
'' ) {
531 return Status::newFatal(
'noname' );
535 if (
$name ===
false ) {
537 return Status::newFatal(
'nosuchusershort',
$username );
541 if ( $wikiId ==
'' ) {
548 return Status::newFatal(
'nosuchusershort',
$username );
551 return Status::newGood(
$user );
562 if ( empty( $ids ) ) {
563 return $this->
msg(
'rightsnone' )->inContentLanguage()->text();
565 return implode(
', ', $ids );
573 $this->
getOutput()->addModules(
'mediawiki.userSuggest' );
582 'id' =>
'mw-userrights-form1'
585 Html::hidden(
'title', $this->
getPageTitle()->getPrefixedText() ) .
586 Xml::fieldset( $this->
msg(
'userrights-lookup-user' )->
text() ) .
588 $this->
msg(
'userrights-user-editname' )->
text(),
592 str_replace(
'_',
' ', $this->mTarget ),
594 'class' =>
'mw-autocomplete-user',
597 $this->mFetchedUser ===
null ? [
'autofocus' =>
'' ] : []
601 $this->
msg(
'editusergroup' )->
text()
603 Html::closeElement(
'fieldset' ) .
604 Html::closeElement(
'form' ) .
"\n"
618 $list = $membersList = $tempList = $tempMembersList = [];
619 foreach ( $groupMemberships
as $ugm ) {
620 $linkG = UserGroupMembership::getLink( $ugm, $this->
getContext(),
'html' );
621 $linkM = UserGroupMembership::getLink( $ugm, $this->
getContext(),
'html',
623 if ( $ugm->getExpiry() ) {
624 $tempList[] = $linkG;
625 $tempMembersList[] = $linkM;
628 $membersList[] = $linkM;
634 $autoMembersList = [];
637 $autoList[] = UserGroupMembership::getLink( $group, $this->
getContext(),
'html' );
638 $autoMembersList[] = UserGroupMembership::getLink( $group, $this->
getContext(),
639 'html',
$user->getName() );
644 $displayedList = $this->
msg(
'userrights-groupsmember-type' )
646 $language->commaList( array_merge( $tempList, $list ) ),
647 $language->commaList( array_merge( $tempMembersList, $membersList ) )
649 $displayedAutolist = $this->
msg(
'userrights-groupsmember-type' )
651 $language->commaList( $autoList ),
652 $language->commaList( $autoMembersList )
656 $count = count( $list ) + count( $tempList );
658 $grouplist = $this->
msg(
'userrights-groupsmember' )
659 ->numParams( $count )
660 ->params(
$user->getName() )
662 $grouplist =
'<p>' . $grouplist .
' ' . $displayedList .
"</p>\n";
665 $count = count( $autoList );
667 $autogrouplistintro = $this->
msg(
'userrights-groupsmember-auto' )
668 ->numParams( $count )
669 ->params(
$user->getName() )
671 $grouplist .=
'<p>' . $autogrouplistintro .
' ' . $displayedAutolist .
"</p>\n";
681 list( $groupCheckboxes, $canChangeAny ) =
689 'name' =>
'editGroup',
690 'id' =>
'mw-userrights-form2'
693 Html::hidden(
'user', $this->mTarget ) .
694 Html::hidden(
'wpEditToken', $this->
getUser()->getEditToken( $this->mTarget ) ) .
696 'conflictcheck-originalgroups',
697 implode(
',',
$user->getGroups() )
699 Xml::openElement(
'fieldset' ) .
704 $canChangeAny ?
'userrights-editusergroup' :
'userrights-viewusergroup',
709 $canChangeAny ?
'editinguser' :
'viewinguserrights'
711 ->rawParams( $userToolLinks )->parse()
713 if ( $canChangeAny ) {
715 $this->
msg(
'userrights-groups-help',
$user->getName() )->parse() .
718 Xml::openElement(
'table', [
'id' =>
'mw-userrights-table-outer' ] ) .
720 <td class='mw-label'>" .
721 Xml::label( $this->msg(
'userrights-reason' )->text(),
'wpReason' ) .
723 <td class='mw-input'>" .
724 Xml::input(
'user-reason', 60, $this->getRequest()->getVal(
'user-reason',
false ), [
729 'maxlength' => CommentStore::COMMENT_CHARACTER_LIMIT,
735 <td class='mw-submit'>" .
736 Xml::submitButton( $this->msg(
'saveusergroups',
$user->getName() )->text(),
737 [
'name' =>
'saveusergroups' ] +
742 Xml::closeElement(
'table' ) .
"\n"
745 $this->
getOutput()->addHTML( $grouplist );
748 Xml::closeElement(
'fieldset' ) .
749 Xml::closeElement(
'form' ) .
"\n"
775 $expiryOptionsMsg = $this->
msg(
'userrights-expiry-options' )->inContentLanguage();
776 $expiryOptions = $expiryOptionsMsg->isDisabled() ?
778 explode(
',', $expiryOptionsMsg->text() );
782 $columns = [
'unchangeable' => [],
'changeable' => [] ];
784 foreach ( $allgroups
as $group ) {
785 $set = isset( $usergroups[$group] );
789 $canOnlyLengthenExpiry = ( $set && $this->
canAdd( $group ) &&
790 !$this->
canRemove( $group ) && $usergroups[$group]->getExpiry() );
792 $disabledCheckbox = !(
793 ( $set && $this->
canRemove( $group ) ) ||
794 ( !$set && $this->
canAdd( $group ) ) );
796 $disabledExpiry = $disabledCheckbox && !$canOnlyLengthenExpiry;
798 $irreversible = !$disabledCheckbox && (
799 ( $set && !$this->
canAdd( $group ) ) ||
800 ( !$set && !$this->
canRemove( $group ) ) );
804 'disabled' => $disabledCheckbox,
805 'disabled-expiry' => $disabledExpiry,
806 'irreversible' => $irreversible
809 if ( $disabledCheckbox && $disabledExpiry ) {
810 $columns[
'unchangeable'][$group] = $checkbox;
812 $columns[
'changeable'][$group] = $checkbox;
817 $ret .= Xml::openElement(
'table', [
'class' =>
'mw-userrights-groups' ] ) .
819 foreach ( $columns
as $name => $column ) {
820 if ( $column === [] ) {
824 $ret .= Xml::element(
827 $this->
msg(
'userrights-' .
$name .
'-col', count( $column ) )->
text()
831 $ret .=
"</tr>\n<tr>\n";
832 foreach ( $columns
as $column ) {
833 if ( $column === [] ) {
836 $ret .=
"\t<td style='vertical-align:top;'>\n";
837 foreach ( $column
as $group => $checkbox ) {
838 $attr = [
'class' =>
'mw-userrights-groupcheckbox' ];
839 if ( $checkbox[
'disabled'] ) {
840 $attr[
'disabled'] =
'disabled';
843 $member = UserGroupMembership::getGroupMemberName( $group,
$user->getName() );
844 if ( $checkbox[
'irreversible'] ) {
845 $text = $this->
msg(
'userrights-irreversible-marker', $member )->text();
846 } elseif ( $checkbox[
'disabled'] && !$checkbox[
'disabled-expiry'] ) {
847 $text = $this->
msg(
'userrights-no-shorten-expiry-marker', $member )->text();
851 $checkboxHtml = Xml::checkLabel( $text,
"wpGroup-" . $group,
852 "wpGroup-" . $group, $checkbox[
'set'], $attr );
858 $currentExpiry = isset( $usergroups[$group] ) ?
859 $usergroups[$group]->getExpiry() :
864 if ( $checkbox[
'set'] &&
865 ( $checkbox[
'irreversible'] || $checkbox[
'disabled-expiry'] )
867 if ( $currentExpiry ) {
868 $expiryFormatted = $uiLanguage->userTimeAndDate( $currentExpiry, $uiUser );
869 $expiryFormattedD = $uiLanguage->userDate( $currentExpiry, $uiUser );
870 $expiryFormattedT = $uiLanguage->userTime( $currentExpiry, $uiUser );
871 $expiryHtml = $this->
msg(
'userrights-expiry-current' )->params(
872 $expiryFormatted, $expiryFormattedD, $expiryFormattedT )->text();
874 $expiryHtml = $this->
msg(
'userrights-expiry-none' )->text();
878 $expiryHtml .= Html::hidden(
"wpExpiry-$group",
879 $currentExpiry ?
'existing' :
'infinite' );
880 $expiryHtml .=
"<br />\n";
882 $expiryHtml = Xml::element(
'span',
null,
883 $this->
msg(
'userrights-expiry' )->
text() );
884 $expiryHtml .= Xml::openElement(
'span' );
889 "mw-input-wpExpiry-$group",
890 $currentExpiry ?
'existing' :
'infinite'
892 if ( $checkbox[
'disabled-expiry'] ) {
893 $expiryFormOptions->
setAttribute(
'disabled',
'disabled' );
896 if ( $currentExpiry ) {
897 $timestamp = $uiLanguage->userTimeAndDate( $currentExpiry, $uiUser );
898 $d = $uiLanguage->userDate( $currentExpiry, $uiUser );
899 $t = $uiLanguage->userTime( $currentExpiry, $uiUser );
900 $existingExpiryMessage = $this->
msg(
'userrights-expiry-existing',
901 $timestamp, $d,
$t );
902 $expiryFormOptions->addOption( $existingExpiryMessage->text(),
'existing' );
905 $expiryFormOptions->addOption(
906 $this->
msg(
'userrights-expiry-none' )->
text(),
909 $expiryFormOptions->addOption(
910 $this->
msg(
'userrights-expiry-othertime' )->
text(),
913 foreach ( $expiryOptions
as $option ) {
914 if ( strpos( $option,
":" ) ===
false ) {
915 $displayText =
$value = $option;
917 list( $displayText,
$value ) = explode(
":", $option );
919 $expiryFormOptions->addOption( $displayText, htmlspecialchars(
$value ) );
923 $expiryHtml .= $expiryFormOptions->getHTML() .
'<br />';
927 'id' =>
"mw-input-wpExpiry-$group-other",
928 'class' =>
'mw-userrights-expiryfield',
930 if ( $checkbox[
'disabled-expiry'] ) {
933 $expiryHtml .= Xml::input(
"wpExpiry-$group-other", 30,
'',
$attribs );
937 if ( $checkbox[
'set'] && $checkbox[
'disabled'] ) {
938 $expiryHtml .= Html::hidden(
"wpGroup-$group", 1 );
941 $expiryHtml .= Xml::closeElement(
'span' );
945 'id' =>
"mw-userrights-nested-wpGroup-$group",
946 'class' =>
'mw-userrights-nested',
948 $checkboxHtml .=
"\t\t\t" . Xml::tags(
'div', $divAttribs, $expiryHtml ) .
"\n";
950 $ret .=
"\t\t" . ( ( $checkbox[
'disabled'] && $checkbox[
'disabled-expiry'] )
951 ? Xml::tags(
'div', [
'class' =>
'mw-userrights-disabled' ], $checkboxHtml )
952 : Xml::tags(
'div', [], $checkboxHtml )
957 $ret .= Xml::closeElement(
'tr' ) . Xml::closeElement(
'table' );
959 return [
$ret, (bool)$columns[
'changeable'] ];
971 $groups[
'remove'] ) || ( $this->isself && in_array( $group, $groups[
'remove-self'] )
984 $groups[
'add'] ) || ( $this->isself && in_array( $group, $groups[
'add-self'] )
999 return $this->
getUser()->changeableGroups();
1009 $rightsLogPage =
new LogPage(
'rights' );
1010 $output->addHTML( Xml::element(
'h2',
null, $rightsLogPage->getName()->text() ) );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfIsInfinity( $str)
Determine input string is represents as infinity.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null, $useParentheses=true)
Generate standard user tool links (talk, contributions, block link, etc.)
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Class to simplify the use of log pages.
Class for creating new log entries and inserting them into the database.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getSkin()
Shortcut to get the skin being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Show an error when the user tries to do something whilst blocked.
Represents a "user group membership" – a specific instance of a user belonging to a group.
static search( $audience, $search, $limit, $offset=0)
Do a prefix search of user names and return a list of matching user names.
static newFromName( $wikiId, $name, $ignoreInvalidDB=false)
Factory function; get a remote user entry by name.
static validDatabase( $wikiId)
Confirm the selected database name is a valid local interwiki database name.
static whoIs( $wikiId, $id, $ignoreInvalidDB=false)
Same as User::whoIs()
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static getAllGroups()
Return the set of defined explicit groups.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
static whoIs( $id)
Get the username corresponding to a given user ID.
Special page to allow managing user group membership.
doSaveUserGroups( $user, array $add, array $remove, $reason='', array $tags=[], array $groupExpiries=[])
Save user groups changes in the database.
static expiryToTimestamp( $expiry)
Converts a user group membership expiry string into a timestamp.
showEditUserGroupsForm( $user, $groups, $groupMemberships)
Show the form to edit group memberships.
static getAllGroups()
Returns an array of all groups that may be edited.
switchForm()
Output a form to allow searching for a user.
$mTarget
The target of the local right-adjuster's interest.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
userCanChangeRights( $targetUser, $checkIfSelf=true)
Check whether the current user (from context) can change the target user's rights.
editUserGroupsForm( $username)
Edit user groups membership.
groupCheckboxes( $usergroups, $user)
Adds a table with checkboxes where you can select what groups to add/remove.
canProcessExpiries()
Returns true if this user rights form can set and change user group expiries.
fetchUser( $username, $writing=true)
Normalize the input username, which may be local or remote, and return a user (or proxy) object for m...
showLogFragment( $user, $output)
Show a rights log fragment for the specified user.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Manage forms to be shown according to posted data.
saveUserGroups( $username, $reason, $user)
Save user groups changes in the database.
static serialiseUgmForLog( $ugm)
Serialise a UserGroupMembership object for storage in the log_params section of the logging table.
doesWrites()
Indicates whether this special page may perform database writes.
addLogEntry( $user, array $oldGroups, array $newGroups, $reason, array $tags, array $oldUGMs, array $newUGMs)
Add a rights log entry for an action.
changeableGroups()
Returns $this->getUser()->changeableGroups()
Class for generating HTML <select> or <datalist> elements.
setAttribute( $name, $value)
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
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
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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
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. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header '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
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
Allows to change the fields on the form that will be generated $name
this hook is for auditing only or null if authentication failed before getting that far $username
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
return true to allow those checks to and false if checking is done & $user
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))