MediaWiki  REL1_22
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.

Definition at line 272 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:
$groupstring
Returns:
string

Definition at line 532 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:
$groupstring
Returns:
string

Definition at line 542 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 647 of file SpecialUserrights.php.

References changeableGroups().

Referenced by groupCheckboxes().

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

Definition at line 637 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 657 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:
$userUser object
array$addof groups to add
array$removeof groups to remove
string$reasonreason for group change
Returns:
Array: Tuple of added, then removed groups

Definition at line 218 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 289 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:
$parMixed: string if any subpage provided, else null
Exceptions:
UserBlockedError|PermissionsError

Reimplemented from SpecialPage.

Definition at line 72 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 object

Definition at line 315 of file SpecialUserrights.php.

References $name, $user, User\getCanonicalName(), SpecialPage\getUser(), global, 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 550 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 673 of file SpecialUserrights.php.

Definition at line 176 of file SpecialUserrights.php.

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

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
$userUser a user object
Returns:
string XHTML table element with checkboxes

Definition at line 562 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(), tags(), and text.

Referenced by showEditUserGroupsForm().

Can be overridden by subclasses with more complicated permissions schemes.

Returns:
Boolean: should the page be displayed with the restricted-access pages?

Reimplemented from SpecialPage.

Definition at line 40 of file SpecialUserrights.php.

Definition at line 376 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:
in 1.21; use LogFormatter instead.
Parameters:
$idsarray
Returns:
string

Definition at line 391 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 189 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:
$userUser to show log for
$outputOutputPage to use

Definition at line 667 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 425 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:
$userUser: the user to check
Returns:
Boolean: 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: