jenkins-bot has submitted this change and it was merged.

Change subject: Moving a pref override from Echo to Thanks
......................................................................


Moving a pref override from Echo to Thanks

Bug: 47757
Change-Id: I1aa81cf81ca71af323f0d5448fb5800086a09b1e
---
M Thanks.hooks.php
M Thanks.php
2 files changed, 17 insertions(+), 0 deletions(-)

Approvals:
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Thanks.hooks.php b/Thanks.hooks.php
index 1c280c8..08239d7 100644
--- a/Thanks.hooks.php
+++ b/Thanks.hooks.php
@@ -139,4 +139,19 @@
                }
                return true;
        }
+
+       /**
+        * Handler for AddNewAccount hook
+        * @see http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount
+        * @param $user User object that was created.
+        * @param $byEmail bool True when account was created "by email".
+        * @return bool
+        */
+       public static function onAccountCreated( $user, $byEmail ) {
+               // New users get echo preferences set that are not the default 
settings for existing users.
+               // Specifically, new users are opted into email notifications 
for thanks.
+               $user->setOption( 'echo-subscriptions-email-edit-thank', true );
+               $user->saveSettings();
+               return true;
+       }
 }
diff --git a/Thanks.php b/Thanks.php
index ab3d7a0..fab30d5 100644
--- a/Thanks.php
+++ b/Thanks.php
@@ -57,6 +57,7 @@
 $wgHooks['DiffViewHeader'][] = 'ThanksHooks::onDiffViewHeader';
 $wgHooks['BeforeCreateEchoEvent'][] = 'ThanksHooks::onBeforeCreateEchoEvent';
 $wgHooks['EchoGetDefaultNotifiedUsers'][] = 
'ThanksHooks::onEchoGetDefaultNotifiedUsers';
+$wgHooks['AddNewAccount'][] = 'ThanksHooks::onAccountCreated';
 
 // Register modules
 $wgResourceModules['ext.thanks'] = array(
@@ -97,4 +98,5 @@
 
 // Set default user options
 $wgDefaultUserOptions['echo-subscriptions-web-edit-thank'] = true;
+// This is overriden for new users in ThanksHooks::onAccountCreated
 $wgDefaultUserOptions['echo-subscriptions-email-edit-thank'] = false;

-- 
To view, visit https://gerrit.wikimedia.org/r/61152
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1aa81cf81ca71af323f0d5448fb5800086a09b1e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Thanks
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson (WMF) <[email protected]>
Gerrit-Reviewer: Lwelling <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to