mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
Merge "Echo: Make it possible to specify exactly which events are active with $wgEchoEnabledEvents"
This commit is contained in:
commit
131ae20665
|
@ -68,6 +68,8 @@ $1',
|
|||
'echo-link' => 'My notifications',
|
||||
'echo-overlay-link' => 'All notifications…',
|
||||
'echo-overlay-title' => 'My notifications',
|
||||
|
||||
'echo-error-no-formatter' => 'Error: Unable to find notification formatter for event type "$1".',
|
||||
);
|
||||
|
||||
/** Message documentation (Message documentation)
|
||||
|
@ -115,6 +117,8 @@ $4 is the page on which the discussion was added, plain text.',
|
|||
'echo-link' => 'Shown in "personal links" when a user has JS. New notifications are indicated with a badge.',
|
||||
'echo-overlay-link' => 'Link to "all notifications" at the bottom of the overlay',
|
||||
'echo-overlay-title' => 'Title at the top of the notifications overlay',
|
||||
'echo-error-no-formatter' => 'Internal error condition shown when a notification cannot be formatted.
|
||||
$1 is the type of notification (e.g. "add-talkpage-section").',
|
||||
);
|
||||
|
||||
/** Belarusian (Taraškievica orthography) (беларуская (тарашкевіца))
|
||||
|
|
6
Echo.php
6
Echo.php
|
@ -159,6 +159,12 @@ $wgEchoNotifiers = array(
|
|||
'email' => array('EchoNotifier', 'notifyWithEmail'),
|
||||
);
|
||||
|
||||
$wgEchoEnabledEvents = array(
|
||||
'edit-user-talk',
|
||||
'add-comment',
|
||||
'add-talkpage-topic',
|
||||
);
|
||||
|
||||
$wgEchoNotificationFormatters = array(
|
||||
'edit-user-talk' => array(
|
||||
'type' => 'edit',
|
||||
|
|
15
Hooks.php
15
Hooks.php
|
@ -98,6 +98,11 @@ class EchoHooks {
|
|||
* @return true in all cases
|
||||
*/
|
||||
public static function getPreferences( $user, &$preferences ) {
|
||||
global $wgEchoEnabledEvents;
|
||||
if ( $wgEchoEnabledEvents !== false && ! in_array( 'edit', $wgEchoEnabledEvents ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$preferences['echo-notify-watchlist'] = array(
|
||||
'type' => 'toggle',
|
||||
'label-message' => 'echo-pref-notify-watchlist',
|
||||
|
@ -114,6 +119,11 @@ class EchoHooks {
|
|||
* @return true in all cases
|
||||
*/
|
||||
public static function onWatch( $user, $article ) {
|
||||
global $wgEchoEnabledEvents;
|
||||
if ( $wgEchoEnabledEvents !== false && ! in_array( 'edit', $wgEchoEnabledEvents ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! $user->getOption('echo-notify-watchlist') ) {
|
||||
return true;
|
||||
}
|
||||
|
@ -132,6 +142,11 @@ class EchoHooks {
|
|||
* @return true in all cases
|
||||
*/
|
||||
public static function onUnwatch( $user, $article ) {
|
||||
global $wgEchoEnabledEvents;
|
||||
if ( $wgEchoEnabledEvents !== false && ! in_array( 'edit', $wgEchoEnabledEvents ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$subscription = new EchoSubscription( $user, 'edit', $article->getTitle() );
|
||||
$subscription->disableNotification('notify');
|
||||
$subscription->save();
|
||||
|
|
|
@ -186,6 +186,7 @@ class EchoNotificationController {
|
|||
return $notifier->format($event, $user, $type);
|
||||
}
|
||||
|
||||
// throw new MWException( "Unable to find notification formatter for event " . $event->getType() );
|
||||
return Xml::tags( 'span', array( 'class' => 'error' ),
|
||||
wfMessage( 'echo-error-no-formatter', $event->getType() )->escaped() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,15 @@ class EchoEvent {
|
|||
throw new MWException( "'type' parameter is mandatory" );
|
||||
}
|
||||
|
||||
global $wgEchoEnabledEvents;
|
||||
|
||||
if (
|
||||
$wgEchoEnabledEvents !== false &&
|
||||
! in_array( $info['type'], $wgEchoEnabledEvents )
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$obj->id = false;
|
||||
$obj->timestamp = wfTimestampNow();
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class SpecialNotifications extends SpecialPage {
|
|||
$event = EchoEvent::newFromRow( $row );
|
||||
$class = 'mw-echo-notification';
|
||||
|
||||
$formatted = EchoNotificationController::formatNotification( $event, $user(), 'html' );
|
||||
$formatted = EchoNotificationController::formatNotification( $event, $user, 'html' );
|
||||
|
||||
if ( $row->notification_read_timestamp === null ) {
|
||||
$class .= ' mw-echo-unread';
|
||||
|
|
Loading…
Reference in a new issue