Do not allow a user to delete a page they can't edit
[lhc/web/wiklou.git] / includes / api / ApiRollback.php
index fbe87d2..af6f9ff 100644 (file)
@@ -61,7 +61,13 @@ class ApiRollback extends ApiBase {
                        $this->dieUsageMsg( reset( $retval ) );
                }
 
-               $this->setWatch( $params['watchlist'], $titleObj );
+               $watch = 'preferences';
+               if ( isset( $params['watchlist'] ) ) {
+                       $watch = $params['watchlist'];
+               }
+
+               // Watch pages
+               $this->setWatch( $watch, $titleObj, 'watchrollback' );
 
                $info = array(
                        'title' => $titleObj->getPrefixedText(),
@@ -115,8 +121,8 @@ class ApiRollback extends ApiBase {
                $p = $this->getModulePrefix();
 
                return array(
-                       'title' => "Title of the page you want to delete. Cannot be used together with {$p}pageid",
-                       'pageid' => "Page ID of the page you want to delete. Cannot be used together with {$p}title",
+                       'title' => "Title of the page you want to roll back. Cannot be used together with {$p}pageid",
+                       'pageid' => "Page ID of the page you want to roll back. Cannot be used together with {$p}title",
                        'user' => 'Name of the user whose edits are to be rolled back. If ' .
                                'set incorrectly, you\'ll get a badtoken error.',
                        'token' => 'A rollback token previously retrieved through ' .
@@ -128,19 +134,6 @@ class ApiRollback extends ApiBase {
                );
        }
 
-       public function getResultProperties() {
-               return array(
-                       '' => array(
-                               'title' => 'string',
-                               'pageid' => 'integer',
-                               'summary' => 'string',
-                               'revid' => 'integer',
-                               'old_revid' => 'integer',
-                               'last_revid' => 'integer'
-                       )
-               );
-       }
-
        public function getDescription() {
                return array(
                        'Undo the last edit to the page. If the last user who edited the page made',
@@ -148,15 +141,6 @@ class ApiRollback extends ApiBase {
                );
        }
 
-       public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'invalidtitle', 'title' ),
-                       array( 'notanarticle' ),
-                       array( 'nosuchpageid', 'pageid' ),
-                       array( 'invaliduser', 'user' ),
-               ) );
-       }
-
        public function needsToken() {
                return true;
        }