Add preference for watching uploaded files
authorMark Holmquist <mtraceur@member.fsf.org>
Thu, 7 Nov 2013 02:50:01 +0000 (18:50 -0800)
committerMark Holmquist <mtraceur@member.fsf.org>
Fri, 8 Apr 2016 20:21:17 +0000 (15:21 -0500)
Adds a preference in the Watchlist section for watching uploaded files
for an account. Also works from API-based upload methods, so
UploadWizard and other tools should work fine.

Bug: T33313
Change-Id: If962e667de12b35904b2d1b2d9e99c26b588ec2a

RELEASE-NOTES-1.27
includes/DefaultSettings.php
includes/Preferences.php
includes/api/ApiUpload.php
includes/specials/SpecialUpload.php
languages/i18n/en.json
languages/i18n/qqq.json

index 915b93b..4918ac9 100644 (file)
@@ -181,6 +181,8 @@ HHVM 3.1.
   and error messages. It is available client-side via mw.config.get( 'wgRequestId' ).
   The request ID supplants exception IDs. Accordingly, MWExceptionHandler::getLogId()
   is deprecated.
+* (T33313) Add a preference for watching uploads by default, also applies
+  to API-based upload tools.
 
 === External library changes in 1.27 ===
 
index 711967e..26a6676 100644 (file)
@@ -4563,6 +4563,7 @@ $wgDefaultUserOptions = [
        'watchcreations' => 1,
        'watchdefault' => 1,
        'watchdeletion' => 0,
+       'watchuploads' => 1,
        'watchlistdays' => 3.0,
        'watchlisthideanons' => 0,
        'watchlisthidebots' => 0,
index 54176a6..d076219 100644 (file)
@@ -1042,10 +1042,14 @@ class Preferences {
                        $watchTypes['rollback'] = 'watchrollback';
                }
 
+               if ( $user->isAllowed( 'upload' ) ) {
+                       $watchTypes['upload'] = 'watchuploads';
+               }
+
                foreach ( $watchTypes as $action => $pref ) {
                        if ( $user->isAllowed( $action ) ) {
                                // Messages:
-                               // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations
+                               // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations, tog-watchuploads
                                // tog-watchrollback
                                $defaultPreferences[$pref] = [
                                        'type' => 'toggle',
index 326f8ba..a5e2fbb 100644 (file)
@@ -685,16 +685,19 @@ class ApiUpload extends ApiBase {
                /** @var $file File */
                $file = $this->mUpload->getLocalFile();
 
-               // For preferences mode, we want to watch if 'watchdefault' is set or
-               // if the *file* doesn't exist and 'watchcreations' is set. But
-               // getWatchlistValue()'s automatic handling checks if the *title*
-               // exists or not, so we need to check both prefs manually.
+               // For preferences mode, we want to watch if 'watchdefault' is set,
+               // or if the *file* doesn't exist, and either 'watchuploads' or
+               // 'watchcreations' is set. But getWatchlistValue()'s automatic
+               // handling checks if the *title* exists or not, so we need to check
+               // all three preferences manually.
                $watch = $this->getWatchlistValue(
                        $this->mParams['watchlist'], $file->getTitle(), 'watchdefault'
                );
+
                if ( !$watch && $this->mParams['watchlist'] == 'preferences' && !$file->exists() ) {
-                       $watch = $this->getWatchlistValue(
-                               $this->mParams['watchlist'], $file->getTitle(), 'watchcreations'
+                       $watch = (
+                               $this->getWatchlistValue( 'preferences', $file->getTitle(), 'watchuploads' ) ||
+                               $this->getWatchlistValue( 'preferences', $file->getTitle(), 'watchcreations' )
                        );
                }
 
index 2754b13..82e07fd 100644 (file)
@@ -622,7 +622,8 @@ class SpecialUpload extends SpecialPage {
                        return false;
                } else {
                        // New page should get watched if that's our option.
-                       return $this->getUser()->getOption( 'watchcreations' );
+                       return $this->getUser()->getOption( 'watchcreations' ) ||
+                               $this->getUser()->getOption( 'watchuploads' );
                }
        }
 
index 51d4659..1d97ee9 100644 (file)
@@ -18,6 +18,7 @@
        "tog-watchdefault": "Add pages and files I edit to my watchlist",
        "tog-watchmoves": "Add pages and files I move to my watchlist",
        "tog-watchdeletion": "Add pages and files I delete to my watchlist",
+       "tog-watchuploads": "Add new files I upload to my watchlist",
        "tog-watchrollback": "Add pages where I have performed a rollback to my watchlist",
        "tog-minordefault": "Mark all edits minor by default",
        "tog-previewontop": "Show preview before edit box",
index 3eca961..0b18352 100644 (file)
        "tog-watchdefault": "[[Special:Preferences]], tab 'Watchlist'. Offers user to add edited pages to watchlist. {{Gender}}",
        "tog-watchmoves": "[[Special:Preferences]], tab 'Watchlist'. Offers user to add moved pages to watchlist. {{Gender}}",
        "tog-watchdeletion": "[[Special:Preferences]], tab 'Watchlist'. Offers user to add deleted pages to watchlist. {{Gender}}",
+       "tog-watchuploads": "[[Special:Preferences]], tab 'Watchlist'. Offers user to add their uploaded files to watchlist. {{Gender}}",
        "tog-watchrollback": "[[Special:Preferences]], tab 'Watchlist'. Offers user to add pages where the user has rollbacked an edit to watchlist. {{Gender}}\n\nSee also {{msg-mw|tog-watchdefault}}, {{msg-mw|tog-watchcreations}}.",
        "tog-minordefault": "[[Special:Preferences]], tab 'Edit'. Offers user to mark all edits minor by default.  {{Gender}}",
        "tog-previewontop": "Toggle option used in [[Special:Preferences]]. {{Gender}}",