MediaWiki  REL1_24
UserrightsPage Class Reference

Special page to allow managing user group membership. More...

Inheritance diagram for UserrightsPage:
Collaboration diagram for UserrightsPage:

List of all members.

Public Member Functions

 __construct ()
 addLogEntry ($user, $oldGroups, $newGroups, $reason)
 Add a rights log entry for an action.
 changeableGroups ()
 Returns $this->getUser()->changeableGroups()
 doSaveUserGroups ($user, $add, $remove, $reason= '')
 Save user groups changes in the database.
 editUserGroupsForm ($username)
 Edit user groups membership.
 execute ($par)
 Manage forms to be shown according to posted data.
 fetchUser ($username)
 Normalize the input username, which may be local or remote, and return a user (or proxy) object for manipulating it.
 getSuccessURL ()
 isRestricted ()
 Can be overridden by subclasses with more complicated permissions schemes.
 makeGroupNameList ($ids)
 makeGroupNameListForLog ($ids)
 Make a list of group names to be stored as parameter for log entries.
 saveUserGroups ($username, $reason, $user)
 Save user groups changes in the database.
 switchForm ()
 Output a form to allow searching for a user.
 userCanChangeRights ($user, $checkIfSelf=true)
 userCanExecute (User $user)
 Checks if the given user (identified by an object) can execute this special page (as defined by $mRestriction).

Protected Member Functions

 getGroupName ()
 Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'.
 showEditUserGroupsForm ($user, $groups)
 Show the form to edit group memberships.
 showLogFragment ($user, $output)
 Show a rights log fragment for the specified user.
 splitGroups ($groups)
 Go through used and available groups and return the ones that this form will be able to manipulate based on the current user's system permissions.

Static Protected Member Functions

static getAllGroups ()
 Returns an array of all groups that may be edited.

Protected Attributes

 $isself = false
 $mTarget

Private Member Functions

 canAdd ($group)
 canRemove ($group)
 groupCheckboxes ($usergroups, $user)
 Adds a table with checkboxes where you can select what groups to add/remove.

Static Private Member Functions

static buildGroupLink ($group)
 Format a link to a group description page.
static buildGroupMemberLink ($group)
 Format a link to a group member description page.

Detailed Description

Special page to allow managing user group membership.

Definition at line 29 of file SpecialUserrights.php.


Constructor & Destructor Documentation

Definition at line 36 of file SpecialUserrights.php.


Member Function Documentation

UserrightsPage::addLogEntry ( user,
oldGroups,
newGroups,
reason 
)

Add a rights log entry for an action.

Parameters:
User$user
array$oldGroups
array$newGroups
array$reason

Definition at line 286 of file SpecialUserrights.php.

References $user, array(), and SpecialPage\getUser().

Referenced by doSaveUserGroups().

static UserrightsPage::buildGroupLink ( group) [static, private]

Format a link to a group description page.

Parameters:
string$group
Returns:
string

Definition at line 579 of file SpecialUserrights.php.

References User\getGroupName().

Referenced by showEditUserGroupsForm().

static UserrightsPage::buildGroupMemberLink ( group) [static, private]

Format a link to a group member description page.

Parameters:
string$group
Returns:
string

Definition at line 589 of file SpecialUserrights.php.

References User\getGroupMember().

Referenced by showEditUserGroupsForm().

UserrightsPage::canAdd ( group) [private]
Parameters:
string$groupThe name of the group to check
Returns:
bool Can we add the group?

Definition at line 703 of file SpecialUserrights.php.

References changeableGroups().

Referenced by groupCheckboxes().

UserrightsPage::canRemove ( group) [private]
Parameters:
string$groupThe name of the group to check
Returns:
bool Can we remove the group?

Definition at line 689 of file SpecialUserrights.php.

References changeableGroups().

Referenced by groupCheckboxes().

Returns $this->getUser()->changeableGroups()

Returns:
array Array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ), 'add-self' => array( addablegroups to self ), 'remove-self' => array( removable groups from self ) )

Definition at line 722 of file SpecialUserrights.php.

References SpecialPage\getUser().

Referenced by canAdd(), canRemove(), doSaveUserGroups(), execute(), splitGroups(), and userCanChangeRights().

UserrightsPage::doSaveUserGroups ( user,
add,
remove,
reason = '' 
)

Save user groups changes in the database.

Parameters:
User$user
array$addArray of groups to add
array$removeArray of groups to remove
string$reasonReason for group change
Returns:
array Tuple of added, then removed groups

Definition at line 227 of file SpecialUserrights.php.

References $isself, $user, addLogEntry(), array(), as, changeableGroups(), SpecialPage\getUser(), global, wfDebug(), and wfRunHooks().

Referenced by saveUserGroups().

Edit user groups membership.

Parameters:
string$usernameName of the user.

Definition at line 303 of file SpecialUserrights.php.

References $user, fetchUser(), SpecialPage\getOutput(), showEditUserGroupsForm(), and showLogFragment().

Referenced by execute().

Manage forms to be shown according to posted data.

Depending on the submit button used, call a form or a save function.

Parameters:
string | null$parString if any subpage provided, else null
Exceptions:
UserBlockedError|PermissionsError

Reimplemented from SpecialPage.

Definition at line 73 of file SpecialUserrights.php.

References $out, $user, array(), changeableGroups(), SpecialPage\checkReadOnly(), editUserGroupsForm(), fetchUser(), User\getCanonicalName(), SpecialPage\getOutput(), SpecialPage\getRequest(), getSuccessURL(), SpecialPage\getUser(), SpecialPage\outputHeader(), saveUserGroups(), SpecialPage\setHeaders(), switchForm(), and userCanChangeRights().

UserrightsPage::fetchUser ( username)

Normalize the input username, which may be local or remote, and return a user (or proxy) object for manipulating it.

Side effects: error output for invalid access

Parameters:
string$username
Returns:
Status

Definition at line 330 of file SpecialUserrights.php.

References $name, $user, User\getCanonicalName(), SpecialPage\getConfig(), SpecialPage\getUser(), list, Status\newFatal(), UserRightsProxy\newFromName(), User\newFromName(), Status\newGood(), UserRightsProxy\validDatabase(), wfWikiID(), UserRightsProxy\whoIs(), and User\whoIs().

Referenced by editUserGroupsForm(), and execute().

static UserrightsPage::getAllGroups ( ) [static, protected]

Returns an array of all groups that may be edited.

Returns:
array Array of groups that may be edited.

Definition at line 597 of file SpecialUserrights.php.

Referenced by groupCheckboxes(), and saveUserGroups().

Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'.

Returns:
string
Since:
1.21

Reimplemented from SpecialPage.

Definition at line 738 of file SpecialUserrights.php.

Definition at line 185 of file SpecialUserrights.php.

References array(), and SpecialPage\getPageTitle().

Referenced by execute().

UserrightsPage::groupCheckboxes ( usergroups,
user 
) [private]

Adds a table with checkboxes where you can select what groups to add/remove.

Todo:
Just pass the username string?
Parameters:
array$usergroupsGroups the user belongs to
User$user
Returns:
string XHTML table element with checkboxes

Definition at line 609 of file SpecialUserrights.php.

References $columns, $name, $ret, $user, array(), as, canAdd(), canRemove(), Xml\checkLabel(), Xml\closeElement(), Xml\element(), getAllGroups(), User\getGroupMember(), SpecialPage\msg(), Xml\openElement(), Xml\tags(), and text.

Referenced by showEditUserGroupsForm().

Can be overridden by subclasses with more complicated permissions schemes.

Returns:
bool Should the page be displayed with the restricted-access pages?

Reimplemented from SpecialPage.

Definition at line 40 of file SpecialUserrights.php.

Definition at line 389 of file SpecialUserrights.php.

References empty, and SpecialPage\msg().

Referenced by makeGroupNameListForLog().

Make a list of group names to be stored as parameter for log entries.

Deprecated:
since 1.21; use LogFormatter instead.
Parameters:
array$ids
Returns:
string

Definition at line 404 of file SpecialUserrights.php.

References empty, makeGroupNameList(), and wfDeprecated().

UserrightsPage::saveUserGroups ( username,
reason,
user 
)

Save user groups changes in the database.

Data comes from the editUserGroupsForm() form function

Parameters:
string$usernameUsername to apply changes to.
string$reasonReason for group change
User | UserRightsProxy$userTarget user object.
Returns:
null

Definition at line 198 of file SpecialUserrights.php.

References $user, array(), as, doSaveUserGroups(), getAllGroups(), and SpecialPage\getRequest().

Referenced by execute().

UserrightsPage::showLogFragment ( user,
output 
) [protected]

Show a rights log fragment for the specified user.

Parameters:
User$userUser to show log for
OutputPage$outputOutputPage to use

Definition at line 732 of file SpecialUserrights.php.

References $output, $user, Xml\element(), and LogEventsList\showLogExtract().

Referenced by editUserGroupsForm().

UserrightsPage::splitGroups ( groups) [protected]

Go through used and available groups and return the ones that this form will be able to manipulate based on the current user's system permissions.

Parameters:
array$groupsList of groups the given user is in
Returns:
array Tuple of addable, then removable groups

Definition at line 452 of file SpecialUserrights.php.

References array(), changeableGroups(), and list.

UserrightsPage::userCanChangeRights ( user,
checkIfSelf = true 
)
Parameters:
User$user
bool$checkIfSelf
Returns:
bool

Definition at line 53 of file SpecialUserrights.php.

References $user, changeableGroups(), and empty.

Referenced by execute(), and userCanExecute().

Checks if the given user (identified by an object) can execute this special page (as defined by $mRestriction).

Can be overridden by sub- classes with more complicated permissions schemes.

Parameters:
User$userThe user to check
Returns:
bool Does the user have permission to view the page?

Reimplemented from SpecialPage.

Definition at line 44 of file SpecialUserrights.php.

References userCanChangeRights().


Member Data Documentation

UserrightsPage::$isself = false [protected]

Definition at line 34 of file SpecialUserrights.php.

Referenced by doSaveUserGroups().

UserrightsPage::$mTarget [protected]

Definition at line 33 of file SpecialUserrights.php.


The documentation for this class was generated from the following file: