MediaWiki master
MediaWiki\Watchlist\WatchlistManager Class Reference

WatchlistManager service. More...

Public Member Functions

 __construct (array $options, HookContainer $hookContainer, ReadOnlyMode $readOnlyMode, RevisionLookup $revisionLookup, TalkPageNotificationManager $talkPageNotificationManager, WatchedItemStoreInterface $watchedItemStore, private readonly WatchlistLabelStore $watchlistLabelStore, UserFactory $userFactory, NamespaceInfo $nsInfo, WikiPageFactory $wikiPageFactory)
 
 addWatch (Authority $performer, PageReference $target, ?string $expiry=null)
 Watch a page if the user has permission to edit their watchlist.
 
 addWatchIgnoringRights (UserIdentity $userIdentity, PageReference $target, ?string $expiry=null)
 Watch a page.
 
 clearAllUserNotifications (Authority $performer)
 Resets all of the given user's page-change notification timestamps.
 
 clearTitleUserNotifications (Authority $performer, PageReference $title, $oldRev=null, $oldRevDeprecated=null)
 Clear the user's notification timestamp for the given title.
 
 getTitleNotificationTimestamp (UserIdentity $user, PageReference $title)
 Get the timestamp when this page was updated since the user last saw it.
 
 isTempWatched (Authority $performer, PageReference $target)
 Check if the page is temporarily watched by the user and the user has permission to view their watchlist.
 
 isTempWatchedIgnoringRights (UserIdentity $userIdentity, PageReference $target)
 Check if the article is temporarily watched by the user.
 
 isWatchable (PageReference $target)
 
 isWatched (Authority $performer, PageReference $target)
 Check if the page is watched by the user and the user has permission to view their watchlist.
 
 isWatchedIgnoringRights (UserIdentity $userIdentity, PageReference $target)
 Check if the page is watched by the user.
 
 removeWatch (Authority $performer, PageReference $target)
 Stop watching a page if the user has permission to edit their watchlist.
 
 removeWatchIgnoringRights (UserIdentity $userIdentity, PageReference $target)
 Stop watching a page.
 
 setWatch (bool $watch, Authority $performer, PageReference $target, ?string $expiry=null, ?array $labels=null)
 Watch or unwatch a page, calling watch/unwatch hooks as appropriate.
 

Public Attributes

const OPTION_ENOTIF = 'isEnotifEnabled'
 

Detailed Description

WatchlistManager service.

Since
1.35

Definition at line 37 of file WatchlistManager.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Watchlist\WatchlistManager::__construct ( array $options,
HookContainer $hookContainer,
ReadOnlyMode $readOnlyMode,
RevisionLookup $revisionLookup,
TalkPageNotificationManager $talkPageNotificationManager,
WatchedItemStoreInterface $watchedItemStore,
private readonly WatchlistLabelStore $watchlistLabelStore,
UserFactory $userFactory,
NamespaceInfo $nsInfo,
WikiPageFactory $wikiPageFactory )
Parameters
array{isEnotifEnabled:bool}$options
HookContainer$hookContainer
ReadOnlyMode$readOnlyMode
RevisionLookup$revisionLookup
TalkPageNotificationManager$talkPageNotificationManager
WatchedItemStoreInterface$watchedItemStore
WatchlistLabelStore$watchlistLabelStore
UserFactory$userFactory
NamespaceInfo$nsInfo
WikiPageFactory$wikiPageFactory

Definition at line 104 of file WatchlistManager.php.

References MediaWiki\Watchlist\WatchlistManager\OPTION_ENOTIF.

Member Function Documentation

◆ addWatch()

MediaWiki\Watchlist\WatchlistManager::addWatch ( Authority $performer,
PageReference $target,
?string $expiry = null )

Watch a page if the user has permission to edit their watchlist.

Calls the WatchArticle and WatchArticleComplete hooks.

Since
1.37
Parameters
Authority$performer
PageReference$target
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
Returns
StatusValue

Definition at line 397 of file WatchlistManager.php.

◆ addWatchIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::addWatchIgnoringRights ( UserIdentity $userIdentity,
PageReference $target,
?string $expiry = null )

Watch a page.

Calls the WatchArticle and WatchArticleComplete hooks.

Since
1.37
Parameters
UserIdentity$userIdentity
PageReference$target
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
Returns
StatusValue

Definition at line 357 of file WatchlistManager.php.

◆ clearAllUserNotifications()

MediaWiki\Watchlist\WatchlistManager::clearAllUserNotifications ( Authority $performer)

Resets all of the given user's page-change notification timestamps.

If e-notif e-mails are on, they will receive notification mails on the next change of any watched page.

Note
If the user doesn't have 'editmywatchlist', this will do nothing.
Parameters
Authority$performer

Definition at line 136 of file WatchlistManager.php.

References MediaWiki\Permissions\Authority\getUser(), and MediaWiki\Permissions\Authority\isAllowed().

◆ clearTitleUserNotifications()

MediaWiki\Watchlist\WatchlistManager::clearTitleUserNotifications ( Authority $performer,
PageReference $title,
$oldRev = null,
$oldRevDeprecated = null )

Clear the user's notification timestamp for the given title.

If e-notif e-mails are on, they will receive notification mails on the next change of the page if it's watched etc.

Note
If the user doesn't have 'editmywatchlist', this will do nothing.
Parameters
Authority$performer
PageReference$title
RevisionRecord | null | int$oldRevThe revision record, or null if the latest revision is used. Passing integer for $oldid is deprecated since 1.46
RevisionRecord | null$oldRevDeprecatedDeprecated since 1.46

Definition at line 179 of file WatchlistManager.php.

References MediaWiki\Page\PageReference\getDBkey(), MediaWiki\Page\PageReference\getNamespace(), MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), NS_USER_TALK, and wfDeprecatedMsg().

◆ getTitleNotificationTimestamp()

MediaWiki\Watchlist\WatchlistManager::getTitleNotificationTimestamp ( UserIdentity $user,
PageReference $title )

Get the timestamp when this page was updated since the user last saw it.

Parameters
UserIdentity$user
PageReference$title
Returns
string|bool|null String timestamp, false if not watched, null if nothing is unseen

Definition at line 248 of file WatchlistManager.php.

References MediaWiki\Page\PageReference\getDBkey(), MediaWiki\User\UserIdentity\getId(), MediaWiki\Page\PageReference\getNamespace(), and MediaWiki\User\UserIdentity\isRegistered().

Referenced by MediaWiki\Actions\Pager\HistoryPager\__construct(), and MediaWiki\Actions\HistoryAction\onView().

◆ isTempWatched()

MediaWiki\Watchlist\WatchlistManager::isTempWatched ( Authority $performer,
PageReference $target )

Check if the page is temporarily watched by the user and the user has permission to view their watchlist.

Since
1.37
Parameters
Authority$performer
PageReference$target
Returns
bool

Definition at line 341 of file WatchlistManager.php.

References MediaWiki\Permissions\Authority\getUser().

◆ isTempWatchedIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::isTempWatchedIgnoringRights ( UserIdentity $userIdentity,
PageReference $target )

Check if the article is temporarily watched by the user.

Since
1.37
Parameters
UserIdentity$userIdentity
PageReference$target
Returns
bool

Definition at line 326 of file WatchlistManager.php.

◆ isWatchable()

MediaWiki\Watchlist\WatchlistManager::isWatchable ( PageReference $target)
Since
1.37
Parameters
PageReference$target
Returns
bool

Definition at line 277 of file WatchlistManager.php.

◆ isWatched()

MediaWiki\Watchlist\WatchlistManager::isWatched ( Authority $performer,
PageReference $target )

Check if the page is watched by the user and the user has permission to view their watchlist.

Since
1.37
Parameters
Authority$performer
PageReference$target
Returns
bool

Definition at line 312 of file WatchlistManager.php.

References MediaWiki\Permissions\Authority\getUser().

◆ isWatchedIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::isWatchedIgnoringRights ( UserIdentity $userIdentity,
PageReference $target )

Check if the page is watched by the user.

Since
1.37
Parameters
UserIdentity$userIdentity
PageReference$target
Returns
bool

Definition at line 297 of file WatchlistManager.php.

◆ removeWatch()

MediaWiki\Watchlist\WatchlistManager::removeWatch ( Authority $performer,
PageReference $target )

Stop watching a page if the user has permission to edit their watchlist.

Calls the UnwatchArticle and UnwatchArticleComplete hooks.

Since
1.37
Parameters
Authority$performer
PageReference$target
Returns
StatusValue

Definition at line 486 of file WatchlistManager.php.

◆ removeWatchIgnoringRights()

MediaWiki\Watchlist\WatchlistManager::removeWatchIgnoringRights ( UserIdentity $userIdentity,
PageReference $target )

Stop watching a page.

Calls the UnwatchArticle and UnwatchArticleComplete hooks.

Since
1.37
Parameters
UserIdentity$userIdentity
PageReference$target
Returns
StatusValue

Definition at line 417 of file WatchlistManager.php.

◆ setWatch()

MediaWiki\Watchlist\WatchlistManager::setWatch ( bool $watch,
Authority $performer,
PageReference $target,
?string $expiry = null,
?array $labels = null )

Watch or unwatch a page, calling watch/unwatch hooks as appropriate.

Checks before watching or unwatching to see if the page is already in the requested watch state and if the expiry is the same so it does not act unnecessarily.

Parameters
bool$watchWhether to watch or unwatch the page
Authority$performerwho is watching/unwatching
PageReference$targetPage to watch/unwatch
string | null$expiryOptional expiry timestamp in any format acceptable to wfTimestamp(), null will not create expiries, or leave them unchanged should they already exist.
?int[]$labelsOptional watchlist label IDs.
Returns
StatusValue
Since
1.37

Definition at line 512 of file WatchlistManager.php.

Member Data Documentation

◆ OPTION_ENOTIF

const MediaWiki\Watchlist\WatchlistManager::OPTION_ENOTIF = 'isEnotifEnabled'
Access: internal
For use by ServiceWiring

Definition at line 42 of file WatchlistManager.php.

Referenced by MediaWiki\Watchlist\WatchlistManager\__construct().


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