From: Mark Holmquist Date: Thu, 7 Nov 2013 02:50:01 +0000 (-0800) Subject: Add preference for watching uploaded files X-Git-Tag: 1.31.0-rc.0~7314^2 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=785d472559446afa8a949e8ebb67f07f328e52f4;p=lhc%2Fweb%2Fwiklou.git Add preference for watching uploaded files 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 --- diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index 915b93bc0e..4918ac92fa 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -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 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 711967e3ef..26a6676028 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4563,6 +4563,7 @@ $wgDefaultUserOptions = [ 'watchcreations' => 1, 'watchdefault' => 1, 'watchdeletion' => 0, + 'watchuploads' => 1, 'watchlistdays' => 3.0, 'watchlisthideanons' => 0, 'watchlisthidebots' => 0, diff --git a/includes/Preferences.php b/includes/Preferences.php index 54176a6960..d076219d63 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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', diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 326f8ba112..a5e2fbb3d4 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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' ) ); } diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 2754b1356f..82e07fd6bf 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -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' ); } } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 51d46598ae..1d97ee9e53 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 3eca96189f..0b183524f5 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -194,6 +194,7 @@ "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}}",