54 $this->expiry =
$expiry ?:
null;
79 $this->userId = (int)$row->ug_user;
80 $this->
group = $row->ug_group;
81 $this->expiry = $row->ug_expiry ===
null ?
94 $ugm->initFromRow( $row );
123 if ( $dbw ===
null ) {
129 [
'ug_user' => $this->userId,
'ug_group' => $this->
group ],
137 'user_former_groups',
138 [
'ufg_user' => $this->userId,
'ufg_group' => $this->
group ],
156 if ( $dbw ===
null ) {
164 if ( $this->
group ===
null ) {
165 throw new UnexpectedValueException(
166 'Don\'t try inserting an uninitialized UserGroupMembership object' );
167 } elseif ( $this->userId <= 0 ) {
168 throw new UnexpectedValueException(
169 'UserGroupMembership::insert() needs a positive user ID. ' .
170 'Did you forget to add your User object to the database before calling addGroup()?' );
174 $dbw->
insert(
'user_groups', $row, __METHOD__, [
'IGNORE' ] );
181 'ug_user' => $row[
'ug_user'],
182 'ug_group' => $row[
'ug_group'],
187 if ( $allowUpdate ) {
188 if ( $this->expiry ) {
189 $conds[] =
'ug_expiry IS NULL OR ug_expiry != ' .
192 $conds[] =
'ug_expiry IS NOT NULL';
198 $row = $dbw->
selectRow(
'user_groups', $this::selectFields(), $conds, __METHOD__ );
202 [
'ug_expiry' => $this->expiry ? $dbw->
timestamp( $this->expiry ) : null ],
203 [
'ug_user' => $row->ug_user,
'ug_group' => $row->ug_group ],
209 return $affected > 0;
221 'ug_expiry' => $this->expiry ? $db->
timestamp( $this->expiry ) :
null,
230 if ( !$this->expiry ) {
247 if ( $dbw ===
null ) {
256 $res = $dbw->
select(
'user_groups', self::selectFields(), $expiryCond,
$fname );
259 $usersAndGroups = [];
260 foreach (
$res as $row ) {
261 $usersAndGroups[] = [
'ufg_user' => $row->ug_user,
'ufg_group' => $row->ug_group ];
268 $dbw->
insert(
'user_former_groups', $usersAndGroups, __METHOD__, [
'IGNORE' ] );
286 $res = $db->select(
'user_groups',
287 self::selectFields(),
292 foreach (
$res as $row ) {
294 if ( !$ugm->isExpired() ) {
295 $ugms[$ugm->group] = $ugm;
317 $row = $db->selectRow(
'user_groups',
318 self::selectFields(),
326 if ( !$ugm->isExpired() ) {
349 if ( $format !==
'wiki' && $format !==
'html' ) {
350 throw new MWException(
'UserGroupMembership::getLink() $format parameter should be ' .
351 "'wiki' or 'html'" );
356 $group = $ugm->getGroup();
362 if ( $userName !==
null ) {
371 if ( $format ===
'wiki' ) {
372 $linkPage = $linkTitle->getFullText();
373 $groupLink =
"[[$linkPage|$groupName]]";
375 $groupLink =
Linker::link( $linkTitle, htmlspecialchars( $groupName ) );
378 $groupLink = htmlspecialchars( $groupName );
383 $uiLanguage =
$context->getLanguage();
385 $expiryDT = $uiLanguage->userTimeAndDate(
$expiry, $uiUser );
386 $expiryD = $uiLanguage->userDate(
$expiry, $uiUser );
387 $expiryT = $uiLanguage->userTime(
$expiry, $uiUser );
388 if ( $format ===
'html' ) {
389 $groupLink = Message::rawParam( $groupLink );
391 return $context->msg(
'group-membership-link-with-expiry' )
392 ->params( $groupLink, $expiryDT, $expiryD, $expiryT )->text();
407 return $msg->isBlank() ?
$group : $msg->text();
420 return $msg->isBlank() ?
$group : $msg->text();
431 $msg =
wfMessage(
"grouppage-$group" )->inContentLanguage();
432 if ( $msg->exists() ) {
433 $title = Title::newFromText( $msg->text() );
434 if ( is_object( $title ) ) {
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
no text was provided for refs named< code > blankwithnoreference</code ></span ></li ></ol ></div > !end !test with< references/> in group !wikitext Wikipedia rocks< ref > Proceeds of vol XXI</ref > Wikipedia rocks< ref group=note > Proceeds of vol XXI</ref >< references/>< references group=note/> ! html< p > Wikipedia rocks< sup id="cite_ref-1" class="reference">< a href="#cite_note-1"> &Wikipedia rocks< sup id="cite_ref-2" class="reference">< a href="#cite_note-2"> &</p >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-1">< span class="mw-cite-backlink">< a href="#cite_ref-1"> ↑</a ></span >< span class="reference-text"> Proceeds of vol XXI</span ></li ></ol ></div >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-2">< span class="mw-cite-backlink">< a href="#cite_ref-2"> ↑</a ></span >< span class="reference-text"> Proceeds of vol XXI</span ></li ></ol ></div > !end !test with< references/> in group
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Represents a "user group membership" – a specific instance of a user belonging to a group.
static newFromRow( $row)
Creates a new UserGroupMembership object from a database row.
static getMembershipsForUser( $userId, IDatabase $db=null)
Returns UserGroupMembership objects for all the groups a user currently belongs to.
static getGroupPage( $group)
Gets the title of a page describing a particular user group.
getDatabaseArray(IDatabase $db)
Get an array suitable for passing to $dbw->insert() or $dbw->update()
static getMembership( $userId, $group, IDatabase $db=null)
Returns a UserGroupMembership object that pertains to the given user and group, or false if the user ...
static selectFields()
Returns the list of user_groups fields that should be selected to create a new user group membership.
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
static purgeExpired(IDatabase $dbw=null)
Purge expired memberships from the user_groups table.
insert( $allowUpdate=false, IDatabase $dbw=null)
Insert a user right membership into the database.
int $userId
The ID of the user who belongs to the group.
static getGroupName( $group)
Gets the localized friendly name for a group, if it exists.
__construct( $userId=0, $group=null, $expiry=null)
isExpired()
Has the membership expired?
static getGroupMemberName( $group, $username)
Gets the localized name for a member of a group, if it exists.
string null $expiry
Timestamp of expiry in TS_MW format, or null if no expiry.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
this hook is for auditing only or null if authentication failed before getting that far $username
Interface for objects which can provide a MediaWiki context on request.