55 public function __construct(
int $userId = 0, ?
string $group =
null, ?
string $expiry =
null ) {
56 $this->userId = $userId;
57 $this->group = $group;
58 $this->expiry = $expiry ?:
null;
89 return $this->expired;
106 if ( $format !==
'wiki' && $format !==
'html' ) {
107 throw new InvalidArgumentException(
'UserGroupMembership::getLink() $format parameter should be ' .
108 "'wiki' or 'html'" );
112 $expiry = $ugm->getExpiry();
113 $group = $ugm->getGroup();
120 if ( $userName !==
null ) {
121 $groupName = $uiLanguage->getGroupMemberName( $group, $userName );
123 $groupName = $uiLanguage->getGroupName( $group );
128 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
129 if ( $format ===
'wiki' ) {
131 $linkPage = $linkTitle->getFullText();
132 $groupLink =
"[[$linkPage|$groupName]]";
134 $groupLink = $groupName;
138 $groupLink = $linkRenderer->makeLink( $linkTitle, $groupName );
140 $groupLink = htmlspecialchars( $groupName );
147 $expiryDT = $uiLanguage->userTimeAndDate( $expiry, $uiUser );
148 $expiryD = $uiLanguage->userDate( $expiry, $uiUser );
149 $expiryT = $uiLanguage->userTime( $expiry, $uiUser );
151 if ( $format ===
'wiki' ) {
152 return $context->
msg(
'group-membership-link-with-expiry' )
153 ->params( $groupLink, $expiryDT, $expiryD, $expiryT )->text();
157 return $context->
msg(
'group-membership-link-with-expiry' )
158 ->params( $groupLink, $expiryDT, $expiryD, $expiryT )->escaped();
198 $msg =
wfMessage(
"grouppage-$group" )->inContentLanguage();
199 if ( $msg->exists() ) {
200 $title = Title::newFromText( $msg->text() );
201 if ( is_object(
$title ) ) {
219 && $ugm->
getGroup() === $this->group
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static getMain()
Get the RequestContext object associated with the main request.
Represents a "user group membership" – a specific instance of a user belonging to a group.
static getGroupPage( $group)
Gets the title of a page describing a particular user group.
__construct(int $userId=0, ?string $group=null, ?string $expiry=null)
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
static getGroupName( $group)
Gets the localized friendly name for a group, if it exists.
static getGroupMemberName( $group, $member)
Gets the localized name for a member of a group, if it exists.
isExpired()
Has the membership expired?
equals(UserGroupMembership $ugm)
Compares two pure value objects.
Interface for objects which can provide a MediaWiki context on request.
msg( $key,... $params)
This is the method for getting translated interface messages.