case 'unwatch':
return false;
case 'preferences':
- if ( $titleObj->exists() ) {
- global $wgUser;
- return $wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching();
+ global $wgUser;
+ if ( $titleObj->exists() && !$titleObj->userIsWatching() && $wgUser->getOption( 'watchdefault' ) ) {
+ return true;
}
- return false;
+ return null;
case 'nochange':
default:
- return $titleObj->userIsWatching();
+ return null;
}
}
$watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ) || $wgUser->getOption( 'watchdeletion' );
// Deprecated parameters
- if ( $params['watch'] || $watch ) {
- $articleObj->doWatch();
- } elseif ( $params['unwatch'] || !$watch ) {
- $articleObj->doUnwatch();
+ if ( $params['watch'] ) {
+ $watch = true;
+ } elseif ( $params['unwatch'] ) {
+ $watch = false;
+ }
+
+ if ( $watch !== null ) {
+ if ( $watch ) {
+ $articleObj->doWatch();
+ } else {
+ $articleObj->doUnwatch();
+ }
}
}
$watch = false;
}
- if ( $watch ) {
+ if ( $watch || $titleObj->userIsWatching() ) {
$reqArr['wpWatchthis'] = '';
}
// Watch pages
$watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ) || $wgUser->getOption( 'watchmoves' );
-
+
// Deprecated parameters
- if ( $params['watch'] || $watch ) {
- $wgUser->addWatch( $fromTitle );
- $wgUser->addWatch( $toTitle );
- } elseif ( $params['unwatch'] || !$watch ) {
- $wgUser->removeWatch( $fromTitle );
- $wgUser->removeWatch( $toTitle );
+ if ( $params['watch'] ) {
+ $watch = true;
+ } elseif ( $params['unwatch'] ) {
+ $watch = false;
+ }
+
+ if ( $watch !== null ) {
+ if ( $watch ) {
+ $wgUser->addWatch( $fromTitle );
+ $wgUser->addWatch( $toTitle );
+ } else {
+ $wgUser->removeWatch( $fromTitle );
+ $wgUser->removeWatch( $toTitle );
+ }
}
$this->getResult()->addValue( null, $this->getModuleName(), $r );
}
$watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
- if ( $params['watch'] || $watch ) {
- $articleObj->doWatch();
- } else {
- $articleObj->doUnwatch();
+ if ( $params['watch'] ) {
+ $watch = true;
+ }
+
+ if ( $watch !== null ) {
+ if ( $watch ) {
+ $articleObj->doWatch();
+ } else {
+ $articleObj->doUnwatch();
+ }
}
if ( $titleObj->exists() ) {
$watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
- if ( $watch ) {
- $articleObj->doWatch();
- } else if ( !$watch ) {
- $articleObj->doUnwatch();
+ if ( $watch !== null) {
+ if ( $watch ) {
+ $articleObj->doWatch();
+ } else {
+ $articleObj->doUnwatch();
+ }
}
$info = array(
$watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
- if ( $params['watch'] || $watch ) {
- $wgUser->addWatch( $titleObj );
- } else {
- $wgUser->removeWatch( $titleObj );
+ if ( $watch !== null ) {
+ if ( $watch ) {
+ $wgUser->addWatch( $titleObj );
+ } else {
+ $wgUser->removeWatch( $titleObj );
+ }
}
$info['title'] = $titleObj->getPrefixedText();
$file = $this->mUpload->getLocalFile();
- if ( !$watch ) {
- $wgUser->removeWatch( $file->getTitle() );
- }
-
$result['result'] = 'Success';
$result['filename'] = $file->getName();
$result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
ApiBase::PARAM_DFLT => 'preferences',
ApiBase::PARAM_TYPE => array(
'watch',
- 'unwatch',
'preferences',
'nochange'
),