Followup to r64228 - apply restrictions in API.
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index 419d64c..eaf07b9 100644 (file)
@@ -532,6 +532,31 @@ abstract class ApiBase {
 
                return $mValidNamespaces;
        }
+       /**
+       * Handle watchlist settings
+       */
+       protected function getWatchlistValue ( $watchlist, $titleObj ) {
+               switch ( $watchlist ) {
+                       case 'watch':
+                               $watch = true;
+                               break;
+                       case 'unwatch':
+                               $watch = false;
+                               break;
+                       case 'preferences':
+                               global $wgUser;
+                       
+                               if ( $titleObj->exists() ) {
+                                       $watch = $wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching();
+                               }
+                               break;
+                       case 'nochange':
+                       default:
+                               $watch = $titleObj->userIsWatching();
+               }
+               
+               return $watch;
+       }
 
        /**
         * Using the settings determine the value for the given parameter
@@ -848,6 +873,8 @@ abstract class ApiBase {
                'ipb_blocked_as_range' => array( 'code' => 'blockedasrange', 'info' => "IP address ``\$1'' was blocked as part of range ``\$2''. You can't unblock the IP invidually, but you can unblock the range as a whole." ),
                'ipb_cant_unblock' => array( 'code' => 'cantunblock', 'info' => "The block you specified was not found. It may have been unblocked already" ),
                'mailnologin' => array( 'code' => 'cantsend', 'info' => "You are not logged in, you do not have a confirmed e-mail address, or you are not allowed to send e-mail to other users, so you cannot send e-mail" ),
+               'ipbblocked' => array( 'code' => 'ipbblocked', 'info' => 'You cannot block or unblock users while you are yourself blocked' ),
+               'ipbnounblockself' => array( 'code' => 'ipbnounblockself', 'info' => 'You are not allowed to unblock yourself' ),
                'usermaildisabled' => array( 'code' => 'usermaildisabled', 'info' => "User email has been disabled" ),
                'blockedemailuser' => array( 'code' => 'blockedfrommail', 'info' => "You have been blocked from sending e-mail" ),
                'notarget' => array( 'code' => 'notarget', 'info' => "You have not specified a valid target for this action" ),
@@ -927,8 +954,6 @@ abstract class ApiBase {
                'invalid-session-key' => array( 'code' => 'invalid-session-key', 'info' => 'Not a valid session key' ),
                'nouploadmodule' => array( 'code' => 'nouploadmodule', 'info' => 'No upload module set' ),
                'uploaddisabled' => array( 'code' => 'uploaddisabled', 'info' => 'Uploads are not enabled.  Make sure $wgEnableUploads is set to true in LocalSettings.php and the PHP ini setting file_uploads is true' ),
-               'chunked-error' => array( 'code' => 'chunked-error', 'info' => 'There was a problem initializing the chunked upload.' ),
-               'chunk-init-error' => array( 'code' => 'chunk-init-error', 'info' => 'Insufficient information for initialization.' ),
        );
 
        /**