*/
class MailAddress {
/**
- * @param mixed $address String with an email address, or a User object
- * @param string $name Human-readable name if a string address is given
+ * @param $address Mixed: string with an email address, or a User object
+ * @param $name String: human-readable name if a string address is given
*/
function __construct( $address, $name=null ) {
if( is_object( $address ) && $address instanceof User ) {
* @param $subject String: email's subject.
* @param $body String: email's text.
* @param $replyto String: optional reply-to email (default: null).
+ * @param $contentType String: optional custom Content-Type
* @return mixed True on success, a WikiError object on failure.
*/
- static function send( $to, $from, $subject, $body, $replyto=null ) {
+ static function send( $to, $from, $subject, $body, $replyto=null, $contentType=null ) {
global $wgSMTP, $wgOutputEncoding, $wgErrorString, $wgEnotifImpersonal;
global $wgEnotifMaxRecips;
$headers['From'] = $from->toString();
- if ($wgEnotifImpersonal)
+ if ($wgEnotifImpersonal) {
$headers['To'] = 'undisclosed-recipients:;';
- else
- $headers['To'] = $to->toString();
+ }
+ else {
+ $headers['To'] = implode( ", ", (array )$dest );
+ }
if ( $replyto ) {
$headers['Reply-To'] = $replyto->toString();
$headers['Subject'] = wfQuotedPrintable( $subject );
$headers['Date'] = date( 'r' );
$headers['MIME-Version'] = '1.0';
- $headers['Content-type'] = 'text/plain; charset='.$wgOutputEncoding;
+ $headers['Content-type'] = (is_null($contentType) ?
+ 'text/plain; charset='.$wgOutputEncoding : $contentType);
$headers['Content-transfer-encoding'] = '8bit';
$headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; // FIXME
$headers['X-Mailer'] = 'MediaWiki mailer';
} else {
$endl = "\n";
}
+ $ctype = (is_null($contentType) ?
+ 'text/plain; charset='.$wgOutputEncoding : $contentType);
$headers =
"MIME-Version: 1.0$endl" .
- "Content-type: text/plain; charset={$wgOutputEncoding}$endl" .
+ "Content-type: $ctype$endl" .
"Content-Transfer-Encoding: 8bit$endl" .
"X-Mailer: MediaWiki mailer$endl".
'From: ' . $from->toString();
*
*/
class EmailNotification {
- /**@{{
- * @private
- */
- var $to, $subject, $body, $replyto, $from;
- var $user, $title, $timestamp, $summary, $minorEdit, $oldid, $composed_common, $editor;
- var $mailTargets = array();
-
- /**@}}*/
+ private $to, $subject, $body, $replyto, $from;
+ private $user, $title, $timestamp, $summary, $minorEdit, $oldid, $composed_common, $editor;
+ private $mailTargets = array();
/**
* Send emails corresponding to the user $editor editing the page $title.
if ($wgEnotifUseJobQ) {
$params = array(
"editor" => $editor->getName(),
+ "editorID" => $editor->getID(),
"timestamp" => $timestamp,
"summary" => $summary,
"minorEdit" => $minorEdit,
*/
function actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid=false) {
- # we use $wgEmergencyContact as sender's address
+ # we use $wgPasswordSender as sender's address
global $wgEnotifWatchlist;
global $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgShowUpdatedMarker;
global $wgEnotifImpersonal;
} elseif ( $targetUser->getId() == $editor->getId() ) {
wfDebug( __METHOD__.": user edited their own talk page, no notification sent\n" );
} elseif( $targetUser->getOption( 'enotifusertalkpages' ) ) {
- wfDebug( __METHOD__.": sending talk page update notification\n" );
- $this->compose( $targetUser );
- $userTalkId = $targetUser->getId();
+ if( $targetUser->isEmailConfirmed() ) {
+ wfDebug( __METHOD__.": sending talk page update notification\n" );
+ $this->compose( $targetUser );
+ $userTalkId = $targetUser->getId();
+ } else {
+ wfDebug( __METHOD__.": talk page owner doesn't have validated email\n" );
+ }
} else {
wfDebug( __METHOD__.": talk page owner doesn't want notifications\n" );
}
}
-
if ( $wgEnotifWatchlist ) {
// Send updates to watchers other than the current editor
- $userCondition = 'wl_user <> ' . intval( $editor->getId() );
+ $userCondition = 'wl_user != ' . $editor->getID();
if ( $userTalkId !== false ) {
// Already sent an email to this person
- $userCondition .= ' AND wl_user <> ' . intval( $userTalkId );
+ $userCondition .= ' AND wl_user != ' . intval( $userTalkId );
}
$dbr = wfGetDB( DB_SLAVE );
$this->sendMails();
if ( $wgShowUpdatedMarker || $wgEnotifWatchlist ) {
- # mark the changed watch-listed page with a timestamp, so that the page is
- # listed with an "updated since your last visit" icon in the watch list, ...
+ # Mark the changed watch-listed page with a timestamp, so that the page is
+ # listed with an "updated since your last visit" icon in the watch list. Do
+ # not do this to users for their own edits.
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'watchlist',
array( /* SET */
), array( /* WHERE */
'wl_title' => $title->getDBkey(),
'wl_namespace' => $title->getNamespace(),
- 'wl_notificationtimestamp IS NULL'
+ 'wl_notificationtimestamp IS NULL',
+ 'wl_user != ' . $editor->getID()
), __METHOD__
);
}
* @private
*/
function composeCommonMailtext() {
- global $wgEmergencyContact, $wgNoReplyAddress;
+ global $wgPasswordSender, $wgNoReplyAddress;
global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
global $wgEnotifImpersonal;
# global configuration level.
$editor = $this->editor;
$name = $editor->getName();
- $adminAddress = new MailAddress( $wgEmergencyContact, 'WikiAdmin' );
+ $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
$editorAddress = new MailAddress( $editor );
if( $wgEnotifRevealEditorAddress
&& ( $editor->getEmail() != '' )