X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiWatch.php;h=c7d636a1bc92b13eaa28a9ea114af8648879bbe7;hb=a14bcc6ebe8afcd06de20f10f6fdce65ce648712;hp=7106b0662632f17a2d9738ae6842ceae7919ceb1;hpb=1b288c914751c627cf3f66275e34616c4040a4cb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 7106b06626..c7d636a1bc 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -36,6 +36,9 @@ class ApiWatch extends ApiBase { if ( !$user->isLoggedIn() ) { $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); } + if ( !$user->isAllowed( 'editmywatchlist' ) ) { + $this->dieUsage( 'You don\'t have permission to edit your watchlist', 'permissiondenied' ); + } $params = $this->extractRequestParams(); $title = Title::newFromText( $params['title'] ); @@ -46,7 +49,7 @@ class ApiWatch extends ApiBase { $res = array( 'title' => $title->getPrefixedText() ); - // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang + // Currently unnecessary, code to act as a safeguard against any change in current behavior of uselang // Copy from ApiParse $oldLang = null; if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) { @@ -57,19 +60,19 @@ class ApiWatch extends ApiBase { if ( $params['unwatch'] ) { $res['unwatched'] = ''; $res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock(); - $success = UnwatchAction::doUnwatch( $title, $user ); + $status = UnwatchAction::doUnwatch( $title, $user ); } else { $res['watched'] = ''; $res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock(); - $success = WatchAction::doWatch( $title, $user ); + $status = WatchAction::doWatch( $title, $user ); } if ( !is_null( $oldLang ) ) { $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang } - if ( !$success ) { - $this->dieUsageMsg( 'hookaborted' ); + if ( !$status->isOK() ) { + $this->dieStatus( $status ); } $this->getResult()->addValue( null, $this->getModuleName(), $res ); }