Making sure that email notification settings stay in sync.

Also registering UserLoadOptions hook (oops!)

Finally, getting rid of old override system that is now obsolete.

Change-Id: Ie264981eb20f1e3d3c83721bc376d79e2f5a1430
This commit is contained in:
kaldari 2013-04-29 19:53:33 -07:00
parent 3149e30a33
commit 62155661de
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;
}
}