mediawiki-extensions-Echo/Notifier.php
Andrew Garrett 8839f98735 Implement email notification in Echo. No way to turn it off yet, but at least it is there :).
Change-Id: Ie7c3d776d3698264d18ccaec90cc39aae83761dd
2012-05-18 01:36:18 +10:00

37 lines
1,011 B
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) );
}
/**
* 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 );
}
}