mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Merge "Add welcome notification for new users."
This commit is contained in:
commit
419f7b1cbb
|
@ -33,6 +33,9 @@ $messages['en'] = array(
|
|||
'notification-add-talkpage-topic-yours' => '$2 {{GENDER:$1|sent}} you a message: "[[$4#$3|$3]]"',
|
||||
'notification-add-comment-yours' => '$2 {{GENDER:$1|commented}} on "[[$4#$3|$3]]" on your talk page',
|
||||
'notification-talkpage-content' => '$1', ## Do not translate unless you deliberately want to change behaviour
|
||||
'notification-new-user' => 'Welcome to {{SITENAME}}, $1!',
|
||||
'notification-new-user-content' => 'Hi $1, and welcome to {{SITENAME}}.<br />
|
||||
Please remember to sign any comments on talk pages with 4 tildes (~~~~).',
|
||||
|
||||
'notification-edit-email-subject' => '{{SITENAME}} notification: $3 has been edited by $2',
|
||||
'notification-edit-email-body' => 'Hello $5,
|
||||
|
@ -121,6 +124,8 @@ $messages['qqq'] = array(
|
|||
* $2 Linked Username;
|
||||
* $3 Discussion name;
|
||||
* $4 link to user talk page.',
|
||||
'notification-new-user' => 'Title for the welcome notification. $1 is the name of the new user.',
|
||||
'notification-new-user-content' => 'The content shown to users on their welcome notification. $1 is the name of the new user.',
|
||||
'notification-edit-email-subject' => 'E-mail subject. Parameters:
|
||||
* $2 is a username
|
||||
* $3 is a page title',
|
||||
|
|
12
Echo.php
12
Echo.php
|
@ -139,6 +139,7 @@ $wgHooks['EchoGetNotificationTypes'] = array( 'EchoHooks::getNotificationTypes'
|
|||
$wgHooks['WatchArticleComplete'][] = 'EchoHooks::onWatch';
|
||||
$wgHooks['UnwatchArticleComplete'][] = 'EchoHooks::onUnwatch';
|
||||
$wgHooks['ArticleSaveComplete'][] = 'EchoHooks::onArticleSaved';
|
||||
$wgHooks['AddNewAccount'][] = 'EchoHooks::onAccountCreated';
|
||||
|
||||
// Disable ordinary email notifications
|
||||
$wgHooks['AbortEmailNotification'][] = 'EchoHooks::abortEmailNotification';
|
||||
|
@ -149,7 +150,7 @@ $wgHooks['ArticleEditUpdateNewTalk'][] = 'EchoHooks::abortNewtalkNotification';
|
|||
|
||||
$wgEchoDisableStandardEmail = true;
|
||||
|
||||
$wgEchoDefaultNotificationTypes = array(
|
||||
$wgEchoDefaultNotificationTypes = array( // Welcome events do not use subscription, and will only trigger notify, not email.
|
||||
'all' => array(
|
||||
'notify' => true,
|
||||
'email' => true,
|
||||
|
@ -165,6 +166,7 @@ $wgEchoEnabledEvents = array(
|
|||
'edit-user-talk',
|
||||
'add-comment',
|
||||
'add-talkpage-topic',
|
||||
'welcome',
|
||||
);
|
||||
|
||||
$wgEchoNotificationFormatters = array(
|
||||
|
@ -202,4 +204,12 @@ $wgEchoNotificationFormatters = array(
|
|||
'content-params' => array( 'commentText' ),
|
||||
'icon' => 'chat',
|
||||
),
|
||||
'welcome' => array(
|
||||
'type' => 'welcome',
|
||||
'title-message' => 'notification-new-user',
|
||||
'title-params' => array( 'agent' ),
|
||||
'content-message' => 'notification-new-user-content',
|
||||
'content-params' => array( 'agent' ),
|
||||
'icon' => 'w',
|
||||
)
|
||||
);
|
||||
|
|
18
Hooks.php
18
Hooks.php
|
@ -59,6 +59,9 @@ class EchoHooks {
|
|||
EchoDiscussionParser::getNotifiedUsersForComment( $revision )
|
||||
);
|
||||
break;
|
||||
case 'welcome':
|
||||
$users[$event->getAgent()->getId()] = $event->getAgent();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -190,6 +193,21 @@ class EchoHooks {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for AddNewAccount hook.
|
||||
* @see http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount
|
||||
* @param $user User object that was created.
|
||||
* @param $byEmail bool True when account was created "by email".
|
||||
*/
|
||||
public static function onAccountCreated( $user, $byEmail ) {
|
||||
$event = EchoEvent::create( array(
|
||||
'type' => 'welcome',
|
||||
'agent' => $user,
|
||||
) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for BeforePageDisplay hook.
|
||||
* @see http://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
|
||||
|
|
|
@ -79,18 +79,22 @@ class EchoNotificationController {
|
|||
return;
|
||||
}
|
||||
|
||||
$subscriptions = self::getSubscriptionsForEvent( $event );
|
||||
if ( $event->getType() == 'welcome' ) { // Welcome events should only be sent to the new user, no need for subscriptions.
|
||||
self::doNotification( $event, $event->getAgent(), 'notify' );
|
||||
} else {
|
||||
$subscriptions = self::getSubscriptionsForEvent( $event );
|
||||
|
||||
foreach ( $subscriptions as $subscription ) {
|
||||
$user = $subscription->getUser();
|
||||
$notifyTypes = $subscription->getNotificationTypes();
|
||||
foreach ( $subscriptions as $subscription ) {
|
||||
$user = $subscription->getUser();
|
||||
$notifyTypes = $subscription->getNotificationTypes();
|
||||
|
||||
$notifyTypes = array_keys( array_filter( $notifyTypes ) );
|
||||
$notifyTypes = array_keys( array_filter( $notifyTypes ) );
|
||||
|
||||
wfRunHooks( 'EchoGetNotificationTypes', array( $subscription, $event, &$notifyTypes ) );
|
||||
wfRunHooks( 'EchoGetNotificationTypes', array( $subscription, $event, &$notifyTypes ) );
|
||||
|
||||
foreach ( $notifyTypes as $type ) {
|
||||
self::doNotification( $event, $user, $type );
|
||||
foreach ( $notifyTypes as $type ) {
|
||||
self::doNotification( $event, $user, $type );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ abstract class EchoNotificationFormatter {
|
|||
'basic' => 'EchoBasicFormatter',
|
||||
'edit' => 'EchoEditFormatter',
|
||||
'comment' => 'EchoCommentFormatter',
|
||||
'welcome' => 'EchoBasicFormatter',
|
||||
);
|
||||
protected $validOutputFormats = array( 'text', 'html', 'email' );
|
||||
protected $outputFormat = 'text';
|
||||
|
|
Loading…
Reference in a new issue