Go to the documentation of this file.
55 $this->expiry =
$expiry ?:
null;
80 $this->userId = (int)$row->ug_user;
81 $this->group = $row->ug_group;
82 $this->expiry = $row->ug_expiry ===
null ?
95 $ugm->initFromRow( $row );
124 if ( $dbw ===
null ) {
130 [
'ug_user' => $this->userId,
'ug_group' => $this->
group ],
138 'user_former_groups',
139 [
'ufg_user' => $this->userId,
'ufg_group' => $this->
group ],
157 if ( $dbw ===
null ) {
165 if ( $this->
group ===
null ) {
166 throw new UnexpectedValueException(
167 'Don\'t try inserting an uninitialized UserGroupMembership object' );
168 } elseif ( $this->userId <= 0 ) {
169 throw new UnexpectedValueException(
170 'UserGroupMembership::insert() needs a positive user ID. ' .
171 'Did you forget to add your User object to the database before calling addGroup()?' );
175 $dbw->
insert(
'user_groups', $row, __METHOD__, [
'IGNORE' ] );
182 'ug_user' => $row[
'ug_user'],
183 'ug_group' => $row[
'ug_group'],
188 if ( $allowUpdate ) {
189 if ( $this->expiry ) {
190 $conds[] =
'ug_expiry IS NULL OR ug_expiry != ' .
193 $conds[] =
'ug_expiry IS NOT NULL';
199 $row = $dbw->
selectRow(
'user_groups', $this::selectFields(), $conds, __METHOD__ );
203 [
'ug_expiry' => $this->expiry ? $dbw->
timestamp( $this->expiry ) :
null ],
204 [
'ug_user' => $row->ug_user,
'ug_group' => $row->ug_group ],
210 return $affected > 0;
222 'ug_expiry' => $this->expiry ? $db->
timestamp( $this->expiry ) :
null,
231 if ( !$this->expiry ) {
244 $services = MediaWikiServices::getInstance();
245 if (
$services->getReadOnlyMode()->isReadOnly() ) {
249 $lbFactory =
$services->getDBLoadBalancerFactory();
250 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
253 $lockKey = $dbw->
getDomainID() .
':usergroups-prune';
255 if ( !$scopedLock ) {
266 self::selectFields(),
269 [
'FOR UPDATE',
'LIMIT' => 100 ]
272 if (
$res->numRows() > 0 ) {
275 foreach (
$res as $row ) {
276 $insertData[] = [
'ufg_user' => $row->ug_user,
'ufg_group' => $row->ug_group ];
278 [
'ug_user' => $row->ug_user,
'ug_group' => $row->ug_group ],
289 $dbw->
insert(
'user_former_groups', $insertData, __METHOD__, [
'IGNORE' ] );
291 $purgedRows +=
$res->numRows();
296 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
297 }
while (
$res->numRows() > 0 );
314 $res = $db->select(
'user_groups',
315 self::selectFields(),
320 foreach (
$res as $row ) {
322 if ( !$ugm->isExpired() ) {
323 $ugms[$ugm->group] = $ugm;
346 $row = $db->selectRow(
'user_groups',
347 self::selectFields(),
355 if ( !$ugm->isExpired() ) {
377 if ( $format !==
'wiki' && $format !==
'html' ) {
378 throw new MWException(
'UserGroupMembership::getLink() $format parameter should be ' .
379 "'wiki' or 'html'" );
384 $group = $ugm->getGroup();
390 if ( $userName !==
null ) {
399 if ( $format ===
'wiki' ) {
400 $linkPage = $linkTitle->getFullText();
401 $groupLink =
"[[$linkPage|$groupName]]";
403 $groupLink =
Linker::link( $linkTitle, htmlspecialchars( $groupName ) );
406 $groupLink = htmlspecialchars( $groupName );
411 $uiLanguage =
$context->getLanguage();
413 $expiryDT = $uiLanguage->userTimeAndDate(
$expiry, $uiUser );
414 $expiryD = $uiLanguage->userDate(
$expiry, $uiUser );
415 $expiryT = $uiLanguage->userTime(
$expiry, $uiUser );
416 if ( $format ===
'html' ) {
417 $groupLink = Message::rawParam( $groupLink );
419 return $context->msg(
'group-membership-link-with-expiry' )
420 ->params( $groupLink, $expiryDT, $expiryD, $expiryT )->text();
434 return $msg->isBlank() ?
$group : $msg->text();
447 return $msg->isBlank() ?
$group : $msg->text();
458 $msg =
wfMessage(
"grouppage-$group" )->inContentLanguage();
459 if ( $msg->exists() ) {
461 if ( is_object(
$title ) ) {
getDatabaseArray(IDatabase $db)
Get an array suitable for passing to $dbw->insert() or $dbw->update()
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
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
insert( $allowUpdate=false, IDatabase $dbw=null)
Insert a user right membership into the database.
static getGroupName( $group)
Gets the localized friendly name for a group, if it exists.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
string null $expiry
Timestamp of expiry in TS_MW format, or null if no expiry.
wfReadOnly()
Check whether the wiki is in read-only mode.
static purgeExpired()
Purge expired memberships from the user_groups table.
static getGroupPage( $group)
Gets the title of a page describing a particular user group.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static getMembershipsForUser( $userId, IDatabase $db=null)
Returns UserGroupMembership objects for all the groups a user currently belongs to.
namespace and then decline to actually register it file or subcat img or subcat $title
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static newFromRow( $row)
Creates a new UserGroupMembership object from a database row.
__construct( $userId=0, $group=null, $expiry=null)
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
isExpired()
Has the membership expired?
static selectFields()
Returns the list of user_groups fields that should be selected to create a new user group membership.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
int $userId
The ID of the user who belongs to the group.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
invalid e g too many</span ></p > ! 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
Interface for objects which can provide a MediaWiki context on request.
static singleton( $domain=false)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
static getMembership( $userId, $group, IDatabase $db=null)
Returns a UserGroupMembership object that pertains to the given user and group, or false if the user ...
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 use $formDescriptor instead 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 "<
this hook is for auditing only or null if authentication failed before getting that far $username
static getGroupMemberName( $group, $username)
Gets the localized name for a member of a group, if it exists.
Represents a "user group membership" – a specific instance of a user belonging to a group.