mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-23 21:23:09 +00:00
950f74eba8
Change-Id: Iedeaca3c31195a5cf7df8dd38d6332cfabffcc67
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
// @todo Fill in
|
|
class EchoNotifier {
|
|
/**
|
|
* Record an EchoNotification for an EchoEvent.
|
|
*
|
|
* @param $user The User to notify.
|
|
* @param $event The EchoEvent to notify about.
|
|
*/
|
|
public static function notifyWithNotification( $user, $event ) {
|
|
EchoNotification::create( array( 'user' => $user, 'event' => $event ) );
|
|
EchoNotificationController::resetNotificationCount( $user );
|
|
}
|
|
|
|
/**
|
|
* Send a Notification to a user by email
|
|
*
|
|
* @param $user The User to notify.
|
|
* @param $event The EchoEvent to notify about.
|
|
*/
|
|
public static function notifyWithEmail( $user, $event ) {
|
|
if ( !$user->isEmailConfirmed() ) {
|
|
// No valid email address
|
|
return false;
|
|
}
|
|
|
|
global $wgPasswordSender, $wgPasswordSenderName;
|
|
|
|
$adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
|
|
$address = new MailAddress( $user );
|
|
$email = EchoNotificationController::formatNotification( $event, $user, 'email' );
|
|
$subject = $email['subject'];
|
|
$body = $email['body'];
|
|
|
|
UserMailer::send( $address, $adminAddress, $subject, $body );
|
|
}
|
|
}
|