MediaWiki  master
UserGroupMembership Class Reference

Represents a "user group membership" – a specific instance of a user belonging to a group. More...

Public Member Functions

 __construct (int $userId=0, ?string $group=null, ?string $expiry=null)
 
 equals (UserGroupMembership $ugm)
 Compares two pure value objects. More...
 
 getExpiry ()
 
 getGroup ()
 
 getUserId ()
 
 isExpired ()
 Has the membership expired? More...
 

Static Public Member Functions

static getGroupMemberName ( $group, $member)
 Gets the localized name for a member of a group, if it exists. More...
 
static getGroupName ( $group)
 Gets the localized friendly name for a group, if it exists. More...
 
static getGroupPage ( $group)
 Gets the title of a page describing a particular user group. More...
 
static getLink ( $ugm, IContextSource $context, $format, $userName=null)
 Gets a link for a user group, possibly including the expiry date if relevant. More...
 

Private Attributes

bool $expired
 Expiration flag. More...
 
string null $expiry
 Timestamp of expiry in TS_MW format, or null if no expiry. More...
 
string $group
 
int $userId
 The ID of the user who belongs to the group. More...
 

Detailed Description

Represents a "user group membership" – a specific instance of a user belonging to a group.

For example, the fact that user Mary belongs to the sysop group is a user group membership.

The class is a pure value object. Use UserGroupManager to modify user group memberships.

Since
1.29

Definition at line 35 of file UserGroupMembership.php.

Constructor & Destructor Documentation

◆ __construct()

UserGroupMembership::__construct ( int  $userId = 0,
?string  $group = null,
?string  $expiry = null 
)
Parameters
int$userIdThe ID of the user who belongs to the group
string | null$groupThe internal group name
string | null$expiryTimestamp of expiry in TS_MW format, or null if no expiry

Definition at line 54 of file UserGroupMembership.php.

References $expiry, $group, $userId, and wfTimestampNow().

Member Function Documentation

◆ equals()

UserGroupMembership::equals ( UserGroupMembership  $ugm)

Compares two pure value objects.

Parameters
UserGroupMembership$ugm
Returns
bool
Since
1.35

Definition at line 212 of file UserGroupMembership.php.

References getGroup(), and getUserId().

◆ getExpiry()

UserGroupMembership::getExpiry ( )
Returns
string|null Timestamp of expiry in TS_MW format, or null if no expiry

Definition at line 78 of file UserGroupMembership.php.

References $expiry.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ getGroup()

UserGroupMembership::getGroup ( )
Returns
string

Definition at line 71 of file UserGroupMembership.php.

References $group.

Referenced by equals().

◆ getGroupMemberName()

static UserGroupMembership::getGroupMemberName (   $group,
  $member 
)
static

Gets the localized name for a member of a group, if it exists.

For example, "administrator" or "bureaucrat"

Parameters
string$groupInternal group name
string | UserIdentity$memberUsername or UserIdentity of member for gender
Returns
string Localized name for group member

Definition at line 182 of file UserGroupMembership.php.

References $group, and RequestContext\getMain().

Referenced by getLink(), RightsLogFormatter\getMessageParameters(), and UserrightsPage\groupCheckboxes().

◆ getGroupName()

static UserGroupMembership::getGroupName (   $group)
static

Gets the localized friendly name for a group, if it exists.

For example, "Administrators" or "Bureaucrats"

Parameters
string$groupInternal group name
Returns
string Localized friendly group name
Deprecated:
since 1.38, use Language::getGroupName or Message::userGroupParams

Definition at line 170 of file UserGroupMembership.php.

References $group, and RequestContext\getMain().

Referenced by SpecialListGroupRights\execute(), SpecialPasswordPolicies\execute(), UsersPager\getAllGroups(), SpecialStatistics\getGroupStats(), and getLink().

◆ getGroupPage()

static UserGroupMembership::getGroupPage (   $group)
static

Gets the title of a page describing a particular user group.

When the name of the group appears in the UI, it can link to this page.

Parameters
string$groupInternal group name
Returns
Title|bool Title of the page if it exists, false otherwise

Definition at line 193 of file UserGroupMembership.php.

References $title, Title\newFromText(), and wfMessage().

Referenced by UsersPager\doBatchLookups(), SpecialListGroupRights\execute(), SpecialPasswordPolicies\execute(), SpecialStatistics\getGroupStats(), and getLink().

◆ getLink()

static UserGroupMembership::getLink (   $ugm,
IContextSource  $context,
  $format,
  $userName = null 
)
static

Gets a link for a user group, possibly including the expiry date if relevant.

Parameters
string | UserGroupMembership$ugmEither a group name as a string, or a UserGroupMembership object
IContextSource$context
string$formatEither 'wiki' or 'html'
string | null$userNameIf you want to use the group member message ("administrator"), pass the name of the user who belongs to the group; it is used for GENDER of the group member message. If you instead want the group name message ("Administrators"), omit this parameter.
Returns
string

Definition at line 104 of file UserGroupMembership.php.

References $expiry, $group, getGroupMemberName(), getGroupName(), getGroupPage(), IContextSource\getLanguage(), IContextSource\getUser(), MessageLocalizer\msg(), and Message\rawParam().

Referenced by PermissionsError\__construct(), UsersPager\buildGroupLink(), SpecialListGroupRights\formatPermissions(), User\newFatalPermissionDeniedStatus(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and UserrightsPage\showEditUserGroupsForm().

◆ getUserId()

UserGroupMembership::getUserId ( )
Returns
int

Definition at line 64 of file UserGroupMembership.php.

References $userId.

Referenced by equals().

◆ isExpired()

UserGroupMembership::isExpired ( )

Has the membership expired?

Returns
bool

Definition at line 87 of file UserGroupMembership.php.

References $expired.

Member Data Documentation

◆ $expired

bool UserGroupMembership::$expired
private

Expiration flag.

Definition at line 47 of file UserGroupMembership.php.

Referenced by isExpired().

◆ $expiry

string null UserGroupMembership::$expiry
private

Timestamp of expiry in TS_MW format, or null if no expiry.

Definition at line 44 of file UserGroupMembership.php.

Referenced by __construct(), getExpiry(), and getLink().

◆ $group

string UserGroupMembership::$group
private

◆ $userId

int UserGroupMembership::$userId
private

The ID of the user who belongs to the group.

Definition at line 38 of file UserGroupMembership.php.

Referenced by __construct(), and getUserId().


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