Go to the documentation of this file.
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
37 parent::__construct(
'Userrights' );
55 if (
$user->getId() == 0 ) {
59 return !empty( $available[
'add'] )
60 || !empty( $available[
'remove'] )
61 || ( ( $this->isself || !$checkIfSelf ) &&
62 ( !empty( $available[
'add-self'] )
63 || !empty( $available[
'remove-self'] ) ) );
84 if (
$user->isBlocked() && !
$user->isAllowed(
'userrights' ) ) {
90 if ( $par !==
null ) {
91 $this->mTarget = $par;
93 $this->mTarget = $request->getVal(
'user' );
98 if ( $this->mTarget ===
null ) {
104 if ( !count( $available[
'add'] ) && !count( $available[
'remove'] ) ) {
105 $this->mTarget =
$user->getName();
110 $this->isself =
true;
114 if ( $this->isself && $request->getCheck(
'success' ) ) {
120 $out->wrapWikiMsg(
"<div class=\"successbox\">\n$1\n</div>",
'userrights-removed-self' );
121 $out->returnToMain();
127 $msg =
$user->isAnon() ?
'userrights-nologin' :
'userrights-notallowed';
137 $out->addModuleStyles(
'mediawiki.special' );
140 if ( count( $available[
'add'] ) || count( $available[
'remove'] ) ) {
145 $request->wasPosted() &&
146 $request->getCheck(
'saveusergroups' ) &&
150 $status = $this->
fetchUser( $this->mTarget );
151 if ( !$status->isOK() ) {
152 $this->
getOutput()->addWikiText( $status->getWikiText() );
157 $targetUser = $status->value;
158 if ( $targetUser instanceof
User ) {
159 $targetUser->clearInstanceCache();
162 if ( $request->getVal(
'conflictcheck-originalgroups' )
163 !== implode(
',', $targetUser->getGroups() )
165 $out->addWikiMsg(
'userrights-conflict' );
169 $request->getVal(
'user-reason' ),
180 if ( $this->mTarget !==
null ) {
186 return $this->
getPageTitle( $this->mTarget )->getFullURL(
array(
'success' => 1 ) );
201 $removegroup =
array();
205 foreach ( $allgroups
as $group ) {
208 if ( $this->
getRequest()->getCheck(
"wpGroup-$group" ) ) {
209 $addgroup[] = $group;
211 $removegroup[] = $group;
232 $groups =
$user->getGroups();
234 $addable = array_merge( $changeable[
'add'],
$isself ? $changeable[
'add-self'] :
array() );
235 $removable = array_merge( $changeable[
'remove'],
$isself ? $changeable[
'remove-self'] :
array() );
237 $remove = array_unique(
238 array_intersect( (
array)$remove, $removable, $groups ) );
239 $add = array_unique( array_diff(
240 array_intersect( (
array)$add, $addable ),
244 $oldGroups =
$user->getGroups();
245 $newGroups = $oldGroups;
249 $newGroups = array_diff( $newGroups, $remove );
250 foreach ( $remove
as $group ) {
251 $user->removeGroup( $group );
255 $newGroups = array_merge( $newGroups, $add );
256 foreach ( $add
as $group ) {
257 $user->addGroup( $group );
260 $newGroups = array_unique( $newGroups );
263 $user->invalidateCache();
266 $wgAuth->updateExternalDBGroups(
$user, $add, $remove );
268 wfDebug(
'oldGroups: ' . print_r( $oldGroups,
true ) .
"\n" );
269 wfDebug(
'newGroups: ' . print_r( $newGroups,
true ) .
"\n" );
272 if ( $newGroups != $oldGroups ) {
276 return array( $add, $remove );
284 $logEntry->setPerformer( $this->
getUser() );
285 $logEntry->setTarget(
$user->getUserPage() );
286 $logEntry->setComment( $reason );
287 $logEntry->setParameters(
array(
288 '4::oldgroups' => $oldGroups,
289 '5::newgroups' => $newGroups,
291 $logid = $logEntry->insert();
292 $logEntry->publish( $logid );
301 if ( !$status->isOK() ) {
302 $this->
getOutput()->addWikiText( $status->getWikiText() );
306 $user = $status->value;
309 $groups =
$user->getGroups();
327 global $wgUserrightsInterwikiDelimiter;
329 $parts = explode( $wgUserrightsInterwikiDelimiter, $username );
330 if ( count( $parts ) < 2 ) {
331 $name = trim( $username );
334 list(
$name, $database ) = array_map(
'trim', $parts );
339 if ( !$this->
getUser()->isAllowed(
'userrights-interwiki' ) ) {
348 if (
$name ===
'' ) {
352 if (
$name[0] ==
'#' ) {
355 $id = intval( substr(
$name, 1 ) );
357 if ( $database ==
'' ) {
368 if (
$name ===
false ) {
374 if ( $database ==
'' ) {
388 if ( empty( $ids ) ) {
389 return $this->
msg(
'rightsnone' )->inContentLanguage()->text();
391 return implode(
', ', $ids );
405 if ( empty( $ids ) ) {
422 'action' => $wgScript,
424 'id' =>
'mw-userrights-form1'
430 $this->
msg(
'userrights-user-editname' )->
text(),
434 str_replace(
'_',
' ', $this->mTarget ),
435 array(
'autofocus' =>
true )
452 list( $addable, $removable, $addself, $removeself ) = array_values( $this->
changeableGroups() );
454 $removable = array_intersect(
455 array_merge( $this->isself ? $removeself :
array(), $removable ),
458 $addable = array_diff(
459 array_merge( $this->isself ? $addself :
array(), $addable ),
463 return array( $addable, $removable );
474 $membersList =
array();
475 foreach ( $groups
as $group ) {
481 $autoMembersList =
array();
490 $displayedList = $this->
msg(
'userrights-groupsmember-type',
491 $language->listToText( $list ),
492 $language->listToText( $membersList )
494 $displayedAutolist = $this->
msg(
'userrights-groupsmember-type',
495 $language->listToText( $autoList ),
496 $language->listToText( $autoMembersList )
502 $grouplist = $this->
msg(
'userrights-groupsmember',
$count,
$user->getName() )->parse();
503 $grouplist =
'<p>' . $grouplist .
' ' . $displayedList .
"</p>\n";
506 $count = count( $autoList );
508 $autogrouplistintro = $this->
msg(
'userrights-groupsmember-auto',
$count,
$user->getName() )
510 $grouplist .=
'<p>' . $autogrouplistintro .
' ' . $displayedAutolist .
"</p>\n";
526 'name' =>
'editGroup',
527 'id' =>
'mw-userrights-form2'
533 'conflictcheck-originalgroups',
534 implode(
',',
$user->getGroups() )
540 $this->
msg(
'userrights-editusergroup',
$user->getName() )->
text()
543 ->rawParams( $userToolLinks )->parse() .
544 $this->
msg(
'userrights-groups-help',
$user->getName() )->parse() .
549 <td class='mw-label'>" .
552 <td class='mw-input'>" .
554 array(
'id' =>
'wpReason',
'maxlength' => 255 ) ) .
559 <td class='mw-submit'>" .
561 array(
'name' =>
'saveusergroups' ) +
616 foreach ( $allgroups
as $group ) {
617 $set = in_array( $group, $usergroups );
620 ( $set && $this->
canRemove( $group ) ) ||
621 ( !$set && $this->
canAdd( $group ) ) );
623 $irreversible = !$disabled && (
624 ( $set && !$this->
canAdd( $group ) ) ||
625 ( !$set && !$this->
canRemove( $group ) ) );
629 'disabled' => $disabled,
630 'irreversible' => $irreversible
634 $columns[
'unchangeable'][$group] = $checkbox;
636 $columns[
'changeable'][$group] = $checkbox;
644 if ( $column ===
array() ) {
651 $this->
msg(
'userrights-' .
$name .
'-col', count( $column ) )->
text()
655 $ret .=
"</tr>\n<tr>\n";
657 if ( $column ===
array() ) {
660 $ret .=
"\t<td style='vertical-align:top;'>\n";
661 foreach ( $column
as $group => $checkbox ) {
662 $attr = $checkbox[
'disabled'] ?
array(
'disabled' =>
'disabled' ) :
array();
665 if ( $checkbox[
'irreversible'] ) {
666 $text = $this->
msg(
'userrights-irreversible-marker', $member )->escaped();
668 $text = htmlspecialchars( $member );
671 "wpGroup-" . $group, $checkbox[
'set'], $attr );
672 $ret .=
"\t\t" . ( $checkbox[
'disabled']
673 ?
Xml::tags(
'span',
array(
'class' =>
'mw-userrights-disabled' ), $checkboxHtml )
694 $groups[
'remove'] ) || ( $this->isself && in_array( $group, $groups[
'remove-self'] )
707 $groups[
'add'] ) || ( $this->isself && in_array( $group, $groups[
'add-self'] )
722 return $this->
getUser()->changeableGroups();
732 $rightsLogPage =
new LogPage(
'rights' );
static checkLabel( $label, $name, $id, $checked=false, $attribs=array())
Convenience function to build an HTML checkbox with a label.
getPageTitle( $subpage=false)
Get a self-referential title object.
makeGroupNameListForLog( $ids)
Make a list of group names to be stored as parameter for log entries.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Show an error when the user tries to do something whilst blocked.
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
getOutput()
Get the OutputPage being used for this instance.
editUserGroupsForm( $username)
Edit user groups membership.
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
static buildGroupMemberLink( $group)
Format a link to a group member description page.
isRestricted()
Can be overridden by subclasses with more complicated permissions schemes.
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
static newGood( $value=null)
Factory function for good results.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
switchForm()
Output a form to allow searching for a user.
execute( $par)
Manage forms to be shown according to posted data.
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
Show an error when a user tries to do something they do not have the necessary permissions for.
getLanguage()
Shortcut to get user's language.
doSaveUserGroups( $user, $add, $remove, $reason='')
Save user groups changes in the database.
static openElement( $element, $attribs=null)
This opens an XML element.
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...
splitGroups( $groups)
Go through used and available groups and return the ones that this form will be able to manipulate ba...
static closeElement( $element)
Returns "</$element>", except if $wgWellFormedXml is off, in which case it returns the empty string w...
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
static tooltipAndAccesskeyAttribs( $name)
Returns the attributes for the tooltip and access key.
static getAllGroups()
Returns an array of all groups that may be edited.
Special page to allow managing user group membership.
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
addLogEntry( $user, $oldGroups, $newGroups, $reason)
Add a rights log entry for an action.
Class to simplify the use of log pages.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
static inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=array())
Convenience function to build an HTML text input field with a label.
when a variable name is used in a it is silently declared as a new masking the global
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
fetchUser( $username)
Normalize the input username, which may be local or remote, and return a user (or proxy) object for m...
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Allows to change the fields on the form that will be generated $name
static whoIs( $id)
Get the username corresponding to a given user ID.
static userToolLinks( $userId, $userText, $redContribsWhenNoEdits=false, $flags=0, $edits=null)
Generate standard user tool links (talk, contributions, block link, etc.)
msg()
Wrapper around wfMessage that sets the current context.
userCanChangeRights( $user, $checkIfSelf=true)
Parent class for all special pages.
static validDatabase( $database)
Confirm the selected database name is a valid local interwiki database name.
groupCheckboxes( $usergroups, $user)
Adds a table with checkboxes where you can select what groups to add/remove.
getRequest()
Get the WebRequest being used for this instance.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
static getAllGroups()
Return the set of defined explicit groups.
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
static getGroupMember( $group, $username='#')
Get the localized descriptive name for a member of a group, if it exists.
saveUserGroups( $username, $reason, $user)
Save user groups changes in the database.
static getGroupName( $group)
Get the localized descriptive name for a group, if it exists.
static newFromName( $database, $name, $ignoreInvalidDB=false)
Factory function; get a remote user entry by name.
static closeElement( $element)
Shortcut to close an XML element.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
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
Class for creating log entries manually, for example to inject them into the database.
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
changeableGroups()
Returns $this->getUser()->changeableGroups()
static buildGroupLink( $group)
Format a link to a group description page.
static input( $name, $size=false, $value=false, $attribs=array())
Convenience function to build an HTML text input field.
static whoIs( $database, $id, $ignoreInvalidDB=false)
Same as User::whoIs()
static label( $label, $id, $attribs=array())
Convenience function to build an HTML form label.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
static fieldset( $legend=false, $content=false, $attribs=array())
Shortcut for creating fieldsets.
static showLogExtract(&$out, $types=array(), $page='', $user='', $param=array())
Show log extract.
static newFatal( $message)
Factory function for fatal errors.
showEditUserGroupsForm( $user, $groups)
Show the form to edit group memberships.