From: Sam Reed Date: Thu, 25 Mar 2010 20:57:24 +0000 (+0000) Subject: Part of bug 22944 X-Git-Tag: 1.31.0-rc.0~37358 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=fa4ca02290220f4f83d92e001bbd8ea79e21a032;p=lhc%2Fweb%2Fwiklou.git Part of bug 22944 Add unwatch to protect Add unwatch/watch to Rollback and Undelete --- diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 3c9b423eb8..47b87b4f18 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -115,7 +115,10 @@ class ApiProtect extends ApiBase { $articleObj = new Article( $titleObj ); if ( $params['watch'] ) { $articleObj->doWatch(); + } elseif ( $params['unwatch'] ) { + $articleObj->doUnwatch(); } + if ( $titleObj->exists() ) { $ok = $articleObj->updateRestrictions( $protections, $params['reason'], $cascade, $expiryarray ); } else { @@ -161,6 +164,7 @@ class ApiProtect extends ApiBase { 'reason' => '', 'cascade' => false, 'watch' => false, + 'unwatch' => false, ); } @@ -175,6 +179,7 @@ class ApiProtect extends ApiBase { 'cascade' => array( 'Enable cascading protection (i.e. protect pages included in this page)', 'Ignored if not all protection levels are \'sysop\' or \'protect\'' ), 'watch' => 'If set, add the page being (un)protected to your watchlist', + 'unwatch' => 'Remove the page being (un)protected from your watchlist', ); } diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index d4b3d81ce1..849e0f6837 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -72,6 +72,12 @@ class ApiRollback extends ApiBase { // We don't care about multiple errors, just report one of them $this->dieUsageMsg( reset( $retval ) ); } + + if ( $params['watch'] || $wgUser->getOption( 'watchdeletion' ) ) { + $articleObj->doWatch(); + } elseif ( $params['unwatch'] ) { + $articleObj->doUnwatch(); + } $info = array( 'title' => $titleObj->getPrefixedText(), @@ -99,7 +105,9 @@ class ApiRollback extends ApiBase { 'user' => null, 'token' => null, 'summary' => null, - 'markbot' => false + 'markbot' => false, + 'watch' => false, + 'unwatch' => false, ); } @@ -109,7 +117,9 @@ class ApiRollback extends ApiBase { '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 prop=revisions', 'summary' => 'Custom edit summary. If not set, default summary will be used.', - 'markbot' => 'Mark the reverted edits and the revert as bot edits' + 'markbot' => 'Mark the reverted edits and the revert as bot edits', + 'watch' => 'Add the page to your watchlist', + 'unwatch' => 'Remove the page from your watchlist', ); } diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index b4abec7dca..d88d65b00e 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -77,6 +77,14 @@ class ApiUndelete extends ApiBase { $this->dieUsageMsg( array( 'cannotundelete' ) ); } + if ( $params['watch'] ) { + $articleObj = new Article( $titleObj ); + $articleObj->doWatch(); + } elseif ( $params['unwatch'] ) { + $articleObj = new Article( $titleObj ); + $articleObj->doUnwatch(); + } + if ( $retval[1] ) { wfRunHooks( 'FileUndeleteComplete', array( $titleObj, array(), $wgUser, $params['reason'] ) ); @@ -104,7 +112,9 @@ class ApiUndelete extends ApiBase { 'reason' => '', 'timestamps' => array( ApiBase::PARAM_ISMULTI => true - ) + ), + 'watch' => false, + 'unwatch' => false, ); } @@ -114,6 +124,8 @@ class ApiUndelete extends ApiBase { 'token' => 'An undelete token previously retrieved through list=deletedrevs', 'reason' => 'Reason for restoring (optional)', 'timestamps' => 'Timestamps of the revisions to restore. If not set, all revisions will be restored.' + 'watch' => 'Add the page to your watchlist', + 'unwatch' => 'Remove the page from your watchlist', ); }