mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-13 17:57:21 +00:00
69d91fa1b6
Basically having fun with the code analyzer. Also: * remove unused local variable assignments * missing return values * CSS optimizations. * Initialize possible unset variables. Change-Id: I77aa08ecb48eeda08f14dc38d7f35d57ea9fa110
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
// @todo Fill in
|
|
class EchoNotifier {
|
|
/**
|
|
* Record an EchoNotification for an EchoEvent.
|
|
*
|
|
* @param $user User to notify.
|
|
* @param $event 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 User to notify.
|
|
* @param $event EchoEvent to notify about.
|
|
* @return bool
|
|
*/
|
|
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 );
|
|
|
|
return true;
|
|
}
|
|
}
|