2012-04-27 15:14:24 +00:00
|
|
|
<?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 ) {
|
2012-08-31 21:50:46 +00:00
|
|
|
EchoNotification::create( array( 'user' => $user, 'event' => $event ) );
|
2012-07-17 20:39:45 +00:00
|
|
|
EchoNotificationController::resetNotificationCount( $user );
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 ) {
|
2012-08-31 21:50:46 +00:00
|
|
|
if ( !$user->isEmailConfirmed() ) {
|
2012-05-17 15:36:18 +00:00
|
|
|
// 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'];
|
|
|
|
|
2012-08-30 16:04:39 +00:00
|
|
|
UserMailer::send( $address, $adminAddress, $subject, $body );
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
2012-08-30 16:04:39 +00:00
|
|
|
}
|