mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-09-24 02:39:33 +00:00
Echo: Make it possible to specify exactly which events are active with $wgEchoEnabledEvents
Change-Id: Iecf77f1e0dd80a209ef9be013fb2adf44e69a604
This commit is contained in:
parent
da5280b1d4
commit
1d47038e62
|
@ -68,6 +68,8 @@ $1',
|
||||||
'echo-link' => 'My notifications',
|
'echo-link' => 'My notifications',
|
||||||
'echo-overlay-link' => 'All notifications…',
|
'echo-overlay-link' => 'All notifications…',
|
||||||
'echo-overlay-title' => 'My notifications',
|
'echo-overlay-title' => 'My notifications',
|
||||||
|
|
||||||
|
'echo-error-no-formatter' => 'Error: Unable to find notification formatter for event type "$1".',
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Message documentation (Message documentation)
|
/** 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-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-link' => 'Link to "all notifications" at the bottom of the overlay',
|
||||||
'echo-overlay-title' => 'Title at the top of the notifications 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) (беларуская (тарашкевіца))
|
/** Belarusian (Taraškievica orthography) (беларуская (тарашкевіца))
|
||||||
|
|
6
Echo.php
6
Echo.php
|
@ -159,6 +159,12 @@ $wgEchoNotifiers = array(
|
||||||
'email' => array('EchoNotifier', 'notifyWithEmail'),
|
'email' => array('EchoNotifier', 'notifyWithEmail'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$wgEchoEnabledEvents = array(
|
||||||
|
'edit-user-talk',
|
||||||
|
'add-comment',
|
||||||
|
'add-talkpage-topic',
|
||||||
|
);
|
||||||
|
|
||||||
$wgEchoNotificationFormatters = array(
|
$wgEchoNotificationFormatters = array(
|
||||||
'edit-user-talk' => array(
|
'edit-user-talk' => array(
|
||||||
'type' => 'edit',
|
'type' => 'edit',
|
||||||
|
|
15
Hooks.php
15
Hooks.php
|
@ -98,6 +98,11 @@ class EchoHooks {
|
||||||
* @return true in all cases
|
* @return true in all cases
|
||||||
*/
|
*/
|
||||||
public static function getPreferences( $user, &$preferences ) {
|
public static function getPreferences( $user, &$preferences ) {
|
||||||
|
global $wgEchoEnabledEvents;
|
||||||
|
if ( $wgEchoEnabledEvents !== false && ! in_array( 'edit', $wgEchoEnabledEvents ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$preferences['echo-notify-watchlist'] = array(
|
$preferences['echo-notify-watchlist'] = array(
|
||||||
'type' => 'toggle',
|
'type' => 'toggle',
|
||||||
'label-message' => 'echo-pref-notify-watchlist',
|
'label-message' => 'echo-pref-notify-watchlist',
|
||||||
|
@ -114,6 +119,11 @@ class EchoHooks {
|
||||||
* @return true in all cases
|
* @return true in all cases
|
||||||
*/
|
*/
|
||||||
public static function onWatch( $user, $article ) {
|
public static function onWatch( $user, $article ) {
|
||||||
|
global $wgEchoEnabledEvents;
|
||||||
|
if ( $wgEchoEnabledEvents !== false && ! in_array( 'edit', $wgEchoEnabledEvents ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $user->getOption('echo-notify-watchlist') ) {
|
if ( ! $user->getOption('echo-notify-watchlist') ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -132,6 +142,11 @@ class EchoHooks {
|
||||||
* @return true in all cases
|
* @return true in all cases
|
||||||
*/
|
*/
|
||||||
public static function onUnwatch( $user, $article ) {
|
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 = new EchoSubscription( $user, 'edit', $article->getTitle() );
|
||||||
$subscription->disableNotification('notify');
|
$subscription->disableNotification('notify');
|
||||||
$subscription->save();
|
$subscription->save();
|
||||||
|
|
|
@ -186,6 +186,7 @@ class EchoNotificationController {
|
||||||
return $notifier->format($event, $user, $type);
|
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" );
|
throw new MWException( "'type' parameter is mandatory" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global $wgEchoEnabledEvents;
|
||||||
|
|
||||||
|
if (
|
||||||
|
$wgEchoEnabledEvents !== false &&
|
||||||
|
! in_array( $info['type'], $wgEchoEnabledEvents )
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$obj->id = false;
|
$obj->id = false;
|
||||||
$obj->timestamp = wfTimestampNow();
|
$obj->timestamp = wfTimestampNow();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class SpecialNotifications extends SpecialPage {
|
||||||
$event = EchoEvent::newFromRow( $row );
|
$event = EchoEvent::newFromRow( $row );
|
||||||
$class = 'mw-echo-notification';
|
$class = 'mw-echo-notification';
|
||||||
|
|
||||||
$formatted = EchoNotificationController::formatNotification( $event, $user(), 'html' );
|
$formatted = EchoNotificationController::formatNotification( $event, $user, 'html' );
|
||||||
|
|
||||||
if ( $row->notification_read_timestamp === null ) {
|
if ( $row->notification_read_timestamp === null ) {
|
||||||
$class .= ' mw-echo-unread';
|
$class .= ' mw-echo-unread';
|
||||||
|
|
Loading…
Reference in a new issue