* Visit the documentation pages under http://meta.wikipedia.com/Enotif
*/
class EmailNotification {
+
+ /**
+ * Notification is due to user's user talk being edited
+ */
+ const USER_TALK = 'user_talk';
+ /**
+ * Notification is due to a watchlisted page being edited
+ */
+ const WATCHLIST = 'watchlist';
+ /**
+ * Notification because user is notified for all changes
+ */
+ const ALL_CHANGES = 'all_changes';
+
protected $subject, $body, $replyto, $from;
protected $timestamp, $summary, $minorEdit, $oldid, $composed_common, $pageStatus;
protected $mailTargets = array();
&& $this->canSendUserTalkEmail( $editor, $title, $minorEdit )
) {
$targetUser = User::newFromName( $title->getText() );
- $this->compose( $targetUser );
+ $this->compose( $targetUser, self::USER_TALK );
$userTalkId = $targetUser->getId();
}
&& !( $wgBlockDisablesLogin && $watchingUser->isBlocked() )
) {
if ( Hooks::run( 'SendWatchlistEmailNotification', array( $watchingUser, $title, $this ) ) ) {
- $this->compose( $watchingUser );
+ $this->compose( $watchingUser, self::WATCHLIST );
}
}
}
continue;
}
$user = User::newFromName( $name );
- $this->compose( $user );
+ $this->compose( $user, self::ALL_CHANGES );
}
$this->sendMails();
*
* Call sendMails() to send any mails that were queued.
* @param User $user
+ * @param string $source
*/
- function compose( $user ) {
+ function compose( $user, $source ) {
global $wgEnotifImpersonal;
if ( !$this->composed_common ) {
if ( $wgEnotifImpersonal ) {
$this->mailTargets[] = MailAddress::newFromUser( $user );
} else {
- $this->sendPersonalised( $user );
+ $this->sendPersonalised( $user, $source );
}
}
* Returns true if the mail was sent successfully.
*
* @param User $watchingUser
+ * @param string $source
* @return bool
* @private
*/
- function sendPersonalised( $watchingUser ) {
+ function sendPersonalised( $watchingUser, $source ) {
global $wgContLang, $wgEnotifUseRealName;
// From the PHP manual:
// Note: The to parameter cannot be an address in the form of
$wgContLang->userTime( $this->timestamp, $watchingUser ) ),
$this->body );
+ $headers = array();
+ if ( $source === self::WATCHLIST ) {
+ $headers['List-Help'] = 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist';
+ }
+
return UserMailer::send( $to, $this->from, $this->subject, $body, array(
'replyTo' => $this->replyto,
+ 'headers' => $headers,
) );
}
* @param array $options:
* 'replyTo' MailAddress
* 'contentType' string default 'text/plain; charset=UTF-8'
+ * 'headers' array Extra headers to set
*
* Previous versions of this function had $replyto as the 5th argument and $contentType
* as the 6th. These are still supported for backwards compatability, but deprecated.
public static function send( $to, $from, $subject, $body, $options = array() ) {
global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams, $wgAllowHTMLEmail;
$contentType = 'text/plain; charset=UTF-8';
+ $headers = array();
if ( is_array( $options ) ) {
$replyto = isset( $options['replyTo'] ) ? $options['replyTo'] : null;
$contentType = isset( $options['contentType'] ) ? $options['contentType'] : $contentType;
+ $headers = isset( $options['headers'] ) ? $options['headers'] : $headers;
} else {
// Old calling style
wfDeprecated( __METHOD__ . ' with $replyto as 5th parameter', '1.26' );