API: Added watch and unwatch parameters to action=move and action=delete
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 2 Mar 2008 19:00:50 +0000 (19:00 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 2 Mar 2008 19:00:50 +0000 (19:00 +0000)
RELEASE-NOTES
includes/api/ApiDelete.php
includes/api/ApiMove.php

index 2eae85c..2f14227 100644 (file)
@@ -72,6 +72,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 13157) Added ucuserprefix parameter to list=usercontibs
 * (bug 12394) Added rctitles parameter to list=recentchanges, making rcid retrieval easier
 * (bug 13218) Fix inclusion of " character in hyperlinks
+* Added watch and unwatch parameters to action=delete and action=move
 
 === Languages updated in 1.13 ===
 
index a80a43a..edfe672 100644 (file)
@@ -68,12 +68,16 @@ class ApiDelete extends ApiBase {
                $reason = (isset($params['reason']) ? $params['reason'] : NULL);
                $dbw = wfGetDb(DB_MASTER);
                $dbw->begin();
-               $retval = self::delete($articleObj, $params['token'],   $reason);
+               $retval = self::delete($articleObj, $params['token'], $reason);
                
                if(!empty($retval))
                        // We don't care about multiple errors, just report one of them
                        $this->dieUsageMsg(current($retval));
-
+               
+               if($params['watch'] || $wgUser->getOption('watchdeletion'))
+                       $articleObj->doWatch();
+               else if($params['unwatch'])
+                       $articleObj->doUnwatch();
                $dbw->commit();
                $r = array('title' => $titleObj->getPrefixedText(), 'reason' => $reason);
                $this->getResult()->addValue(null, $this->getModuleName(), $r);
@@ -125,6 +129,8 @@ class ApiDelete extends ApiBase {
                        'title' => null,
                        'token' => null,
                        'reason' => null,
+                       'watch' => false,
+                       'unwatch' => false
                );
        }
 
@@ -132,7 +138,9 @@ class ApiDelete extends ApiBase {
                return array (
                        'title' => 'Title of the page you want to delete.',
                        'token' => 'A delete token previously retrieved through prop=info',
-                       'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.'
+                       'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.',
+                       'watch' => 'Add the page to your watchlist',
+                       'unwatch' => 'Remove the page from your watchlist'
                );
        }
 
index 2c63efe..919b7bc 100644 (file)
@@ -86,7 +86,7 @@ class ApiMove extends ApiBase {
                        $this->dieUsageMsg(array($retval));
 
                $r = array('from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason']);
-               if(!$params['noredirect'])
+               if(!$params['noredirect'] || !$wgUser->isAllowed('suppressredirect'))
                        $r['redirectcreated'] = '';
        
                if($params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage())
@@ -106,6 +106,18 @@ class ApiMove extends ApiBase {
                                $r['talkmove-error-info'] = ApiBase::$messageMap[$retval]['info'];
                        }       
                }
+               
+               # Watch pages
+               if($params['watch'] || $wgUser->getOption('watchmoves'))
+               {
+                       $wgUser->addWatch($fromTitle);
+                       $wgUser->addWatch($toTitle);
+               }
+               else if($params['unwatch'])
+               {
+                       $wgUser->removeWatch($fromTitle);
+                       $wgUser->removeWatch($toTitle);
+               }
                $dbw->commit(); // Make sure all changes are really written to the DB
                $this->getResult()->addValue(null, $this->getModuleName(), $r);
        }
@@ -119,7 +131,9 @@ class ApiMove extends ApiBase {
                        'token' => null,
                        'reason' => null,
                        'movetalk' => false,
-                       'noredirect' => false
+                       'noredirect' => false,
+                       'watch' => false,
+                       'unwatch' => false
                );
        }
 
@@ -130,7 +144,9 @@ class ApiMove extends ApiBase {
                        'token' => 'A move token previously retrieved through prop=info',
                        'reason' => 'Reason for the move (optional).',
                        'movetalk' => 'Move the talk page, if it exists.',
-                       'noredirect' => 'Don\'t create a redirect'
+                       'noredirect' => 'Don\'t create a redirect',
+                       'watch' => 'Add the page and the redirect to your watchlist',
+                       'unwatch' => 'Remove the page and the redirect from your watchlist'
                );
        }