Watch/unwatch to ApiUpload
authorSam Reed <reedy@users.mediawiki.org>
Thu, 25 Mar 2010 21:17:51 +0000 (21:17 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 25 Mar 2010 21:17:51 +0000 (21:17 +0000)
Prevent mutually exclusive values

includes/api/ApiUpload.php

index 7f0d857..4e8f1b7 100644 (file)
@@ -47,6 +47,10 @@ class ApiUpload extends ApiBase {
 
                $this->mParams = $this->extractRequestParams();
                $request = $this->getMain()->getRequest();
+               
+               if ( isset( $this->mParams['watch'] ) && isset( $this->mParams['unwatch'] ) ) {
+                       $this->dieUsageMsg( array( 'show' ) );
+               }
 
                // Add the uploaded file to the params array
                $this->mParams['file'] = $request->getFileName( 'file' );
@@ -222,6 +226,10 @@ class ApiUpload extends ApiBase {
                // No errors, no warnings: do the upload
                $status = $this->mUpload->performUpload( $this->mParams['comment'],
                        $this->mParams['text'], $this->mParams['watch'], $wgUser );
+                       
+               if ( $this->mParams['unwatch'] ) {
+                       $wgUser->removeWatch( $file->getTitle() );
+               }
 
                if ( !$status->isGood() ) {
                        $error = $status->getErrorsArray();
@@ -255,6 +263,7 @@ class ApiUpload extends ApiBase {
                        'text' => null,
                        'token' => null,
                        'watch' => false,
+                       'unwatch' => false,
                        'ignorewarnings' => false,
                        'file' => null,
                        'url' => null,
@@ -270,6 +279,7 @@ class ApiUpload extends ApiBase {
                        'comment' => 'Upload comment. Also used as the initial page text for new files if "text" is not specified',
                        'text' => 'Initial page text for new files',
                        'watch' => 'Watch the page',
+                       'watch' => 'Unwatch the page',
                        'ignorewarnings' => 'Ignore any warnings',
                        'file' => 'File contents',
                        'url' => 'Url to fetch the file from',