2012-04-27 15:14:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// @todo Fill in
|
|
|
|
class EchoNotifier {
|
|
|
|
/**
|
|
|
|
* Record an EchoNotification for an EchoEvent.
|
|
|
|
*
|
2012-09-02 09:30:38 +00:00
|
|
|
* @param $user User to notify.
|
|
|
|
* @param $event EchoEvent to notify about.
|
2012-04-27 15:14:24 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
*
|
2012-09-02 09:30:38 +00:00
|
|
|
* @param $user User to notify.
|
|
|
|
* @param $event EchoEvent to notify about.
|
|
|
|
* @return bool
|
2012-04-27 15:14:24 +00:00
|
|
|
*/
|
|
|
|
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-09-02 09:30:38 +00:00
|
|
|
|
|
|
|
return true;
|
2012-04-27 15:14:24 +00:00
|
|
|
}
|
2012-08-30 16:04:39 +00:00
|
|
|
}
|