Merge "Making sure that email notification settings stay in sync."

This commit is contained in:
jenkins-bot 2013-04-30 17:33:51 +00:00 committed by Gerrit Code Review
commit 8250b8ef61
2 changed files with 25 additions and 12 deletions

View file

@ -94,6 +94,8 @@ $wgHooks['MakeGlobalVariablesScript'][] = 'EchoHooks::makeGlobalVariablesScript'
$wgHooks['UnitTestsList'][] = 'EchoHooks::getUnitTests';
$wgHooks['ResourceLoaderRegisterModules'][] = 'EchoHooks::onResourceLoaderRegisterModules';
$wgHooks['UserRights'][] = 'EchoHooks::onUserRights';
$wgHooks['UserLoadOptions'][] = 'EchoHooks::onUserLoadOptions';
$wgHooks['UserSaveOptions'][] = 'EchoHooks::onUserSaveOptions';
// Extension initialization
$wgExtensionFunctions[] = 'EchoHooks::initEchoExtension';

View file

@ -222,18 +222,6 @@ class EchoHooks {
*/
public static function getNotificationTypes( $user, $event, &$notifyTypes ) {
$type = $event->getType();
// Figure out when to disallow email notifications
if ( $type == 'edit' ) {
if ( !$user->getOption( 'enotifwatchlistpages' ) ) {
$notifyTypes = array_diff( $notifyTypes, array( 'email' ) );
}
} elseif ( $type == 'edit-user-talk' ) {
if ( !$user->getOption( 'enotifusertalkpages' ) ) {
$notifyTypes = array_diff( $notifyTypes, array( 'email' ) );
}
}
if ( !$user->getOption( 'enotifminoredits' ) ) {
$extra = $event->getExtra();
if ( !empty( $extra['revid'] ) ) {
@ -755,4 +743,27 @@ class EchoHooks {
// so will not change on disk until user saves for some other reason
return true;
}
/**
* Handler for UserSaveOptions hook.
* @see http://www.mediawiki.org/wiki/Manual:Hooks/UserSaveOptions
* @param $user User whose options are being saved
* @param $options Options can be modified
* @return bool true in all cases
*/
public static function onUserSaveOptions( $user, &$options ) {
global $wgRecentEchoInstall;
if ( $wgRecentEchoInstall ) {
// Both echo-subscriptions-email-edit-user-talk and enotifusertalkpages
// default to true.
if ( isset( $options['echo-subscriptions-email-edit-user-talk'] ) &&
!$options['echo-subscriptions-email-edit-user-talk']
) {
$options['enotifusertalkpages'] = false;
} else {
$options['enotifusertalkpages'] = true;
}
}
return true;
}
}