mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Use UserGetDefaultOptions hook instead of $wgExtensionFunctions
$wgExtensionFunctions are run on every MediaWiki request, and should be avoided unless necessary. Default user options should be controlled by the UserGetDefaultOptions hook instead. Bug: T180192 Change-Id: I2a79e078753d289c3ea2f04b613ce72c59a9e59a
This commit is contained in:
parent
70d07878c9
commit
9f2383a727
|
@ -415,6 +415,7 @@
|
||||||
"UserGroupsChanged": "EchoHooks::onUserGroupsChanged",
|
"UserGroupsChanged": "EchoHooks::onUserGroupsChanged",
|
||||||
"UserLoadOptions": "EchoHooks::onUserLoadOptions",
|
"UserLoadOptions": "EchoHooks::onUserLoadOptions",
|
||||||
"UserSaveOptions": "EchoHooks::onUserSaveOptions",
|
"UserSaveOptions": "EchoHooks::onUserSaveOptions",
|
||||||
|
"UserGetDefaultOptions": "EchoHooks::onUserGetDefaultOptions",
|
||||||
"UserClearNewTalkNotification": "EchoHooks::onUserClearNewTalkNotification",
|
"UserClearNewTalkNotification": "EchoHooks::onUserClearNewTalkNotification",
|
||||||
"ParserTestTables": "EchoHooks::onParserTestTables",
|
"ParserTestTables": "EchoHooks::onParserTestTables",
|
||||||
"EmailUserComplete": "EchoHooks::onEmailUserComplete",
|
"EmailUserComplete": "EchoHooks::onEmailUserComplete",
|
||||||
|
|
|
@ -12,29 +12,36 @@ class EchoHooks {
|
||||||
private static $lastRevertedRevision = null;
|
private static $lastRevertedRevision = null;
|
||||||
|
|
||||||
public static function registerExtension() {
|
public static function registerExtension() {
|
||||||
global $wgNotificationSender, $wgPasswordSender, $wgAllowHTMLEmail,
|
global $wgNotificationSender, $wgPasswordSender;
|
||||||
$wgEchoNotificationCategories, $wgDefaultUserOptions;
|
|
||||||
|
|
||||||
$wgNotificationSender = $wgPasswordSender;
|
$wgNotificationSender = $wgPasswordSender;
|
||||||
|
|
||||||
if ( $wgAllowHTMLEmail ) {
|
|
||||||
$wgDefaultUserOptions['echo-email-format'] = 'html'; /*EchoHooks::EMAIL_FORMAT_HTML*/
|
|
||||||
} else {
|
|
||||||
$wgDefaultUserOptions['echo-email-format'] = 'plain-text'; /*EchoHooks::EMAIL_FORMAT_PLAIN_TEXT*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set all of the events to notify by web but not email by default (won't affect events that don't email)
|
/**
|
||||||
|
* @param array &$defaults
|
||||||
|
*/
|
||||||
|
public static function onUserGetDefaultOptions( array &$defaults ) {
|
||||||
|
global $wgAllowHTMLEmail, $wgEchoNotificationCategories;
|
||||||
|
|
||||||
|
if ( $wgAllowHTMLEmail ) {
|
||||||
|
$defaults['echo-email-format'] = 'html'; /*EchoHooks::EMAIL_FORMAT_HTML*/
|
||||||
|
} else {
|
||||||
|
$defaults['echo-email-format'] = 'plain-text'; /*EchoHooks::EMAIL_FORMAT_PLAIN_TEXT*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set all of the events to notify by web but not email by default
|
||||||
|
// (won't affect events that don't email)
|
||||||
foreach ( $wgEchoNotificationCategories as $category => $categoryData ) {
|
foreach ( $wgEchoNotificationCategories as $category => $categoryData ) {
|
||||||
$wgDefaultUserOptions["echo-subscriptions-email-{$category}"] = false;
|
$defaults["echo-subscriptions-email-{$category}"] = false;
|
||||||
$wgDefaultUserOptions["echo-subscriptions-web-{$category}"] = true;
|
$defaults["echo-subscriptions-web-{$category}"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// most settings default to web on, email off, but override these
|
// most settings default to web on, email off, but override these
|
||||||
$wgDefaultUserOptions['echo-subscriptions-email-system'] = true;
|
$defaults['echo-subscriptions-email-system'] = true;
|
||||||
$wgDefaultUserOptions['echo-subscriptions-email-user-rights'] = true;
|
$defaults['echo-subscriptions-email-user-rights'] = true;
|
||||||
$wgDefaultUserOptions['echo-subscriptions-web-article-linked'] = false;
|
$defaults['echo-subscriptions-web-article-linked'] = false;
|
||||||
$wgDefaultUserOptions['echo-subscriptions-web-mention-failure'] = false;
|
$defaults['echo-subscriptions-web-mention-failure'] = false;
|
||||||
$wgDefaultUserOptions['echo-subscriptions-web-mention-success'] = false;
|
$defaults['echo-subscriptions-web-mention-success'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue