MediaWiki master
MediaWiki\User\UserGroupMembership Class Reference

Represents the membership of one user in one user group. More...

Public Member Functions

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

Static Public Member Functions

static getGroupPage ( $group)
 Gets the title of a page describing a particular user group.
 
static getLink ( $ugm, IContextSource $context, string $format, $userName=null)
 Gets a link for a user group, possibly including the expiry date if relevant.
 
static getLinkHTML ( $ugm, IContextSource $context, $userName=null)
 Gets a link for a user group, possibly including the expiry date if relevant.
 
static getLinkWiki ( $ugm, IContextSource $context, $userName=null)
 Gets a link for a user group, possibly including the expiry date if relevant.
 

Detailed Description

Represents the membership of one user in one user group.

For example, if user "Mary" belongs to "sysop" and "bureaucrat" groups, those memberships can be represented by two UserGroupMembership objects.

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

Since
1.29

Definition at line 26 of file UserGroupMembership.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\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 45 of file UserGroupMembership.php.

References wfTimestampNow().

Member Function Documentation

◆ equals()

MediaWiki\User\UserGroupMembership::equals ( UserGroupMembership $ugm)

Compares two pure value objects.

Parameters
UserGroupMembership$ugm
Returns
bool
Since
1.35

Definition at line 256 of file UserGroupMembership.php.

References MediaWiki\User\UserGroupMembership\getGroup(), and MediaWiki\User\UserGroupMembership\getUserId().

◆ getExpiry()

MediaWiki\User\UserGroupMembership::getExpiry ( )
Returns
string|null Timestamp of expiry in TS::MW format, or null if no expiry

Definition at line 69 of file UserGroupMembership.php.

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

◆ getGroup()

MediaWiki\User\UserGroupMembership::getGroup ( )
Returns
string

Definition at line 62 of file UserGroupMembership.php.

Referenced by MediaWiki\User\UserGroupMembership\equals().

◆ getGroupPage()

static MediaWiki\User\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|false Title of the page if it exists, false otherwise

Definition at line 237 of file UserGroupMembership.php.

References wfMessage().

◆ getLink()

static MediaWiki\User\UserGroupMembership::getLink ( $ugm,
IContextSource $context,
string $format,
$userName = null )
static

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

Deprecated
since 1.41 use getLinkWiki or getLinkHTML directly
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 97 of file UserGroupMembership.php.

References MediaWiki\User\UserGroupMembership\getLinkHTML(), and MediaWiki\User\UserGroupMembership\getLinkWiki().

◆ getLinkHTML()

static MediaWiki\User\UserGroupMembership::getLinkHTML ( $ugm,
IContextSource $context,
$userName = null )
static

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

Since
1.41
Parameters
string | UserGroupMembership$ugmEither a group name as a string, or a UserGroupMembership object
IContextSource$context
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 122 of file UserGroupMembership.php.

Referenced by MediaWiki\User\UserGroupMembership\getLink().

◆ getLinkWiki()

static MediaWiki\User\UserGroupMembership::getLinkWiki ( $ugm,
IContextSource $context,
$userName = null )
static

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

Since
1.41
Parameters
string | UserGroupMembership$ugmEither a group name as a string, or a UserGroupMembership object
IContextSource$context
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 163 of file UserGroupMembership.php.

Referenced by MediaWiki\User\UserGroupMembership\getLink().

◆ getUserId()

MediaWiki\User\UserGroupMembership::getUserId ( )
Returns
int

Definition at line 55 of file UserGroupMembership.php.

Referenced by MediaWiki\User\UserGroupMembership\equals().

◆ isExpired()

MediaWiki\User\UserGroupMembership::isExpired ( )

Has the membership expired?

Returns
bool

Definition at line 78 of file UserGroupMembership.php.


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