20 private $watchlistExpiryEnabled;
36 if ( !$watchOptions ) {
47 ParamValidator::PARAM_DEFAULT =>
'preferences',
48 ParamValidator::PARAM_TYPE => $watchOptions,
52 if ( $this->watchlistExpiryEnabled ) {
53 $result[
'watchlistexpiry'] = [
54 ParamValidator::PARAM_TYPE =>
'expiry',
56 ExpiryDef::PARAM_USE_MAX =>
true,
76 ?
string $userOption =
null,
77 ?
string $expiry =
null
96 ?
string $userOption =
null
98 $userWatching = $user->isWatched(
$title,
User::IGNORE_USER_RIGHTS );
100 switch ( $watchlist ) {
109 if ( $userWatching ) {
113 if ( $userOption ===
null ) {
123 return $userWatching;
126 return $userWatching;
136 $watchlistExpiry = null;
137 if ( $this->watchlistExpiryEnabled && isset( $params[
'watchlistexpiry'] ) ) {
138 $watchlistExpiry = ApiResult::formatExpiry( $params[
'watchlistexpiry'] );
141 return $watchlistExpiry;
157 $watchedItem = $store->getWatchedItem( $user,
$title );
159 if ( $watchedItem ) {
160 $expiry = $watchedItem->getExpiry();
162 if ( $expiry !==
null ) {
163 return ApiResult::formatExpiry( $expiry );
getWatchlistExpiry(WatchedItemStoreInterface $store, Title $title, User $user)
Get existing expiry from the database.
getWatchlistValue(string $watchlist, Title $title, User $user, ?string $userOption=null)
Return true if we're to watch the page, false if not.
string $watchlistMaxDuration
Relative maximum expiry.
getExpiryFromParams(array $params)
Get formatted expiry from the given parameters, or null if no expiry was provided.
setWatch(string $watch, Title $title, User $user, ?string $userOption=null, ?string $expiry=null)
Set a watch (or unwatch) based the based on a watchlist parameter.
getWatchlistParams(array $watchOptions=[])
Get additional allow params specific to watchlisting.
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getBoolOption( $oname)
Get the user's current setting for a given option, as a boolean value.
static doWatchOrUnwatch( $watch, Title $title, User $user, string $expiry=null)
Watch or unwatch a page.
trait ApiWatchlistTrait
An ApiWatchlistTrait adds class properties and convenience methods for APIs that allow you to watch a...