summaryrefslogtreecommitdiff
path: root/includes/actions/WatchAction.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/actions/WatchAction.php')
-rw-r--r--includes/actions/WatchAction.php59
1 files changed, 17 insertions, 42 deletions
diff --git a/includes/actions/WatchAction.php b/includes/actions/WatchAction.php
index 929c1b5f..8c9a46a5 100644
--- a/includes/actions/WatchAction.php
+++ b/includes/actions/WatchAction.php
@@ -1,6 +1,6 @@
<?php
/**
- * Performs the watch and unwatch actions on a page
+ * Performs the watch actions on a page
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -51,6 +51,7 @@ class WatchAction extends FormAction {
wfProfileIn( __METHOD__ );
self::doWatch( $this->getTitle(), $this->getUser() );
wfProfileOut( __METHOD__ );
+
return true;
}
@@ -81,10 +82,10 @@ class WatchAction extends FormAction {
protected function checkCanExecute( User $user ) {
// Must be logged in
if ( $user->isAnon() ) {
- throw new ErrorPageError( 'watchnologin', 'watchnologintext' );
+ throw new UserNotLoggedIn( 'watchlistanontext', 'watchnologin' );
}
- return parent::checkCanExecute( $user );
+ parent::checkCanExecute( $user );
}
/**
@@ -96,7 +97,9 @@ class WatchAction extends FormAction {
* @return Status
*/
public static function doWatchOrUnwatch( $watch, Title $title, User $user ) {
- if ( $user->isLoggedIn() && $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch ) {
+ if ( $user->isLoggedIn() &&
+ $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch
+ ) {
// If the user doesn't have 'editmywatchlist', we still want to
// allow them to add but not remove items via edits and such.
if ( $watch ) {
@@ -105,6 +108,7 @@ class WatchAction extends FormAction {
return self::doUnwatch( $title, $user );
}
}
+
return Status::newGood();
}
@@ -116,8 +120,12 @@ class WatchAction extends FormAction {
* @param int $checkRights Passed through to $user->addWatch()
* @return Status
*/
- public static function doWatch( Title $title, User $user, $checkRights = WatchedItem::CHECK_USER_RIGHTS ) {
- if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS && !$user->isAllowed( 'editmywatchlist' ) ) {
+ public static function doWatch( Title $title, User $user,
+ $checkRights = WatchedItem::CHECK_USER_RIGHTS
+ ) {
+ if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS &&
+ !$user->isAllowed( 'editmywatchlist' )
+ ) {
return User::newFatalPermissionDeniedStatus( 'editmywatchlist' );
}
@@ -129,6 +137,7 @@ class WatchAction extends FormAction {
$user->addWatch( $title, $checkRights );
wfRunHooks( 'WatchArticleComplete', array( &$user, &$page ) );
}
+
return $status;
}
@@ -152,6 +161,7 @@ class WatchAction extends FormAction {
$user->removeWatch( $title );
wfRunHooks( 'UnwatchArticleComplete', array( &$user, &$page ) );
}
+
return $status;
}
@@ -168,7 +178,7 @@ class WatchAction extends FormAction {
if ( $action != 'unwatch' ) {
$action = 'watch';
}
- $salt = array( $action, $title->getDBkey() );
+ $salt = array( $action, $title->getPrefixedDBkey() );
// This token stronger salted and not compatible with ApiWatch
// It's title/action specific because index.php is GET and API is POST
@@ -200,38 +210,3 @@ class WatchAction extends FormAction {
$this->getOutput()->addWikiMsg( 'addedwatchtext', $this->getTitle()->getPrefixedText() );
}
}
-
-/**
- * Page removal from a user's watchlist
- *
- * @ingroup Actions
- */
-class UnwatchAction extends WatchAction {
-
- public function getName() {
- return 'unwatch';
- }
-
- protected function getDescription() {
- return $this->msg( 'removewatch' )->escaped();
- }
-
- public function onSubmit( $data ) {
- wfProfileIn( __METHOD__ );
- self::doUnwatch( $this->getTitle(), $this->getUser() );
- wfProfileOut( __METHOD__ );
- return true;
- }
-
- protected function alterForm( HTMLForm $form ) {
- $form->setSubmitTextMsg( 'confirm-unwatch-button' );
- }
-
- protected function preText() {
- return $this->msg( 'confirm-unwatch-top' )->parse();
- }
-
- public function onSuccess() {
- $this->getOutput()->addWikiMsg( 'removedwatchtext', $this->getTitle()->getPrefixedText() );
- }
-}