X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FWatchAction.php;h=890740fdd5ae19c608dc2e0a3dc2b249d5ea4ae9;hb=ea8c52b7ce54ef254dc4cf6d867b15b56e21b6fc;hp=51108c07a88c81d497f2bb3fd51044ecc2043011;hpb=235219d34b1382d8b0130f1e9ff88108f466cc8b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/WatchAction.php b/includes/actions/WatchAction.php index 51108c07a8..890740fdd5 100644 --- a/includes/actions/WatchAction.php +++ b/includes/actions/WatchAction.php @@ -42,36 +42,12 @@ class WatchAction extends FormAction { return $this->msg( 'addwatch' )->escaped(); } - /** - * Just get an empty form with a single submit button - * @return array - */ - protected function getFormFields() { - return array(); - } - public function onSubmit( $data ) { self::doWatch( $this->getTitle(), $this->getUser() ); return true; } - /** - * This can be either formed or formless depending on the session token given - */ - public function show() { - $this->setHeaders(); - - $user = $this->getUser(); - // This will throw exceptions if there's a problem - $this->checkCanExecute( $user ); - - $form = $this->getForm(); - if ( $form->show() ) { - $this->onSuccess(); - } - } - protected function checkCanExecute( User $user ) { // Must be logged in if ( $user->isAnon() ) { @@ -106,12 +82,12 @@ class WatchAction extends FormAction { */ public static function doWatchOrUnwatch( $watch, Title $title, User $user ) { if ( $user->isLoggedIn() && - $user->isWatched( $title, WatchedItem::IGNORE_USER_RIGHTS ) != $watch + $user->isWatched( $title, User::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 ) { - return self::doWatch( $title, $user, WatchedItem::IGNORE_USER_RIGHTS ); + return self::doWatch( $title, $user, User::IGNORE_USER_RIGHTS ); } else { return self::doUnwatch( $title, $user ); } @@ -125,25 +101,26 @@ class WatchAction extends FormAction { * @since 1.22 Returns Status, $checkRights parameter added * @param Title $title Page to watch/unwatch * @param User $user User who is watching/unwatching - * @param int $checkRights Passed through to $user->addWatch() + * @param bool $checkRights Passed through to $user->addWatch() + * Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS. * @return Status */ - public static function doWatch( Title $title, User $user, - $checkRights = WatchedItem::CHECK_USER_RIGHTS + public static function doWatch( + Title $title, + User $user, + $checkRights = User::CHECK_USER_RIGHTS ) { - if ( $checkRights !== WatchedItem::IGNORE_USER_RIGHTS && - !$user->isAllowed( 'editmywatchlist' ) - ) { + if ( $checkRights && !$user->isAllowed( 'editmywatchlist' ) ) { return User::newFatalPermissionDeniedStatus( 'editmywatchlist' ); } $page = WikiPage::factory( $title ); $status = Status::newFatal( 'hookaborted' ); - if ( Hooks::run( 'WatchArticle', array( &$user, &$page, &$status ) ) ) { + if ( Hooks::run( 'WatchArticle', [ &$user, &$page, &$status ] ) ) { $status = Status::newGood(); $user->addWatch( $title, $checkRights ); - Hooks::run( 'WatchArticleComplete', array( &$user, &$page ) ); + Hooks::run( 'WatchArticleComplete', [ &$user, &$page ] ); } return $status; @@ -164,10 +141,10 @@ class WatchAction extends FormAction { $page = WikiPage::factory( $title ); $status = Status::newFatal( 'hookaborted' ); - if ( Hooks::run( 'UnwatchArticle', array( &$user, &$page, &$status ) ) ) { + if ( Hooks::run( 'UnwatchArticle', [ &$user, &$page, &$status ] ) ) { $status = Status::newGood(); $user->removeWatch( $title ); - Hooks::run( 'UnwatchArticleComplete', array( &$user, &$page ) ); + Hooks::run( 'UnwatchArticleComplete', [ &$user, &$page ] ); } return $status; @@ -202,4 +179,8 @@ class WatchAction extends FormAction { public static function getUnwatchToken( Title $title, User $user, $action = 'unwatch' ) { return self::getWatchToken( $title, $user, $action ); } + + public function doesWrites() { + return true; + } }