if ( !$user->isLoggedIn() ) {
$this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
}
-
$params = $this->extractRequestParams();
- $title = Title::newFromText( $params['title'] );
-
- if ( !$title || $title->getNamespace() < 0 ) {
- $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
+ // titles can handle basic request of 1 title,
+ // but title is still supported for backward compatability
+ if ( isset( $params['title'] ) ) {
+ $title = Title::newFromText( $params['title'] );
+ if ( !$title || $title->getNamespace() < 0 ) {
+ $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
+ }
+ $res = $this->watchTitle( $title, $user, $params);
+ } else {
+ $pageSet = new ApiPageSet( $this );
+ $pageSet->execute();
+ $res = array();
+ foreach ( $pageSet->getTitles() as $title ) {
+ $r = $this->watchTitle( $title, $user, $params);
+ $res[] = $r;
+ }
}
-
+ $this->getResult()->addValue( null, $this->getModuleName(), $res );
+ }
+ private function watchTitle( $title, $user, $params ) {
$res = array( 'title' => $title->getPrefixedText() );
if ( $params['unwatch'] ) {
if ( !$success ) {
$this->dieUsageMsg( 'hookaborted' );
}
- $this->getResult()->addValue( null, $this->getModuleName(), $res );
+ return $res;
}
public function mustBePosted() {
return array(
'title' => array(
ApiBase::PARAM_TYPE => 'string',
- ApiBase::PARAM_REQUIRED => true
+ ),
+ 'titles' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_ISMULTI => true
),
'unwatch' => false,
'token' => array(