From: Roan Kattouw Date: Sun, 2 Mar 2008 19:00:50 +0000 (+0000) Subject: API: Added watch and unwatch parameters to action=move and action=delete X-Git-Tag: 1.31.0-rc.0~49286 X-Git-Url: https://git.cyclocoop.org/admin/%7B%7Blocalurl:Special:UserLogin%7D%7D?a=commitdiff_plain;h=8aba62cf9f5d9c38312df766b423433d8c7df5d6;p=lhc%2Fweb%2Fwiklou.git API: Added watch and unwatch parameters to action=move and action=delete --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2eae85ce24..2f142275c4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index a80a43a2c3..edfe672623 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -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' ); } diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 2c63efed04..919b7bc16c 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -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' ); }