Part of bug 22944
authorSam Reed <reedy@users.mediawiki.org>
Thu, 25 Mar 2010 20:57:24 +0000 (20:57 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 25 Mar 2010 20:57:24 +0000 (20:57 +0000)
Add unwatch to protect

Add unwatch/watch to Rollback and Undelete

includes/api/ApiProtect.php
includes/api/ApiRollback.php
includes/api/ApiUndelete.php

index 3c9b423..47b87b4 100644 (file)
@@ -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',
                );
        }
 
index d4b3d81..849e0f6 100644 (file)
@@ -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',
                );
        }
 
index b4abec7..d88d65b 100644 (file)
@@ -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',
                );
        }