X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUndelete.php;h=e24f2ced59c1b0fda0f54bccfe5e4d44b29c2873;hb=a0c9fb59a934a3e7d9f31f249ab0b2b923f49db7;hp=469fe7f7e32b798f251fb2cc64eca71ab8b95915;hpb=3c18e32e58d53ab38d1dd52d00f248ddef435ebd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index 469fe7f7e3..e24f2ced59 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -44,15 +44,23 @@ class ApiUndelete extends ApiBase { $titleObj = Title::newFromText( $params['title'] ); if ( !$titleObj || $titleObj->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + $this->dieUsageMsg( [ 'invalidtitle', $params['title'] ] ); + } + + // Check if user can add tags + if ( !is_null( $params['tags'] ) ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user ); + if ( !$ableToTag->isOK() ) { + $this->dieStatus( $ableToTag ); + } } // Convert timestamps if ( !isset( $params['timestamps'] ) ) { - $params['timestamps'] = array(); + $params['timestamps'] = []; } if ( !is_array( $params['timestamps'] ) ) { - $params['timestamps'] = array( $params['timestamps'] ); + $params['timestamps'] = [ $params['timestamps'] ]; } foreach ( $params['timestamps'] as $i => $ts ) { $params['timestamps'][$i] = wfTimestamp( TS_MW, $ts ); @@ -60,11 +68,12 @@ class ApiUndelete extends ApiBase { $pa = new PageArchive( $titleObj, $this->getConfig() ); $retval = $pa->undelete( - ( isset( $params['timestamps'] ) ? $params['timestamps'] : array() ), + ( isset( $params['timestamps'] ) ? $params['timestamps'] : [] ), $params['reason'], $params['fileids'], false, - $this->getUser() + $user, + $params['tags'] ); if ( !is_array( $retval ) ) { $this->dieUsageMsg( 'cannotundelete' ); @@ -72,7 +81,7 @@ class ApiUndelete extends ApiBase { if ( $retval[1] ) { Hooks::run( 'FileUndeleteComplete', - array( $titleObj, $params['fileids'], $this->getUser(), $params['reason'] ) ); + [ $titleObj, $params['fileids'], $this->getUser(), $params['reason'] ] ); } $this->setWatch( $params['watchlist'], $titleObj ); @@ -93,30 +102,34 @@ class ApiUndelete extends ApiBase { } public function getAllowedParams() { - return array( - 'title' => array( + return [ + 'title' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true - ), + ], 'reason' => '', - 'timestamps' => array( + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], + 'timestamps' => [ ApiBase::PARAM_TYPE => 'timestamp', ApiBase::PARAM_ISMULTI => true, - ), - 'fileids' => array( + ], + 'fileids' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_ISMULTI => true, - ), - 'watchlist' => array( + ], + 'watchlist' => [ ApiBase::PARAM_DFLT => 'preferences', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'watch', 'unwatch', 'preferences', 'nochange' - ), - ), - ); + ], + ], + ]; } public function needsToken() { @@ -124,13 +137,13 @@ class ApiUndelete extends ApiBase { } protected function getExamplesMessages() { - return array( + return [ 'action=undelete&title=Main%20Page&token=123ABC&reason=Restoring%20main%20page' => 'apihelp-undelete-example-page', 'action=undelete&title=Main%20Page&token=123ABC' . '×tamps=2007-07-03T22:00:45Z|2007-07-02T19:48:56Z' => 'apihelp-undelete-example-revisions', - ); + ]; } public function getHelpUrls() {