if ( $this->address ) {
if ( $this->name != '' && !wfIsWindows() ) {
global $wgEnotifUseRealName;
- $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
+ $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name;
$quoted = UserMailer::quotedPrintable( $name );
if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
$quoted = '"' . $quoted . '"';
* Collection of static functions for sending mail
*/
class UserMailer {
- static $mErrorString;
+ private static $mErrorString;
/**
* Send mail using a PEAR mailer
* @throws MWException
* @return Status
*/
- public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8' ) {
+ public static function send( $to, $from, $subject, $body, $replyto = null,
+ $contentType = 'text/plain; charset=UTF-8'
+ ) {
global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams, $wgAllowHTMLEmail;
$mime = null;
if ( !is_array( $to ) ) {
$body['text'] = str_replace( "\n", "\r\n", $body['text'] );
$body['html'] = str_replace( "\n", "\r\n", $body['html'] );
}
- $mime = new Mail_mime( array( 'eol' => $endl, 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8' ) );
+ $mime = new Mail_mime( array(
+ 'eol' => $endl,
+ 'text_charset' => 'UTF-8',
+ 'html_charset' => 'UTF-8'
+ ) );
$mime->setTXTBody( $body['text'] );
$mime->setHTMLBody( $body['html'] );
$body = $mime->get(); // must call get() before headers()
if ( $safeMode ) {
$sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers );
} else {
- $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
+ $sent = mail(
+ $recip,
+ self::quotedPrintable( $subject ),
+ $body,
+ $headers,
+ $wgAdditionalMailParams
+ );
}
}
} catch ( Exception $e ) {
* @param bool $oldid (default: false)
* @param string $pageStatus (default: 'changed')
*/
- public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false, $pageStatus = 'changed' ) {
+ public function notifyOnPageChange( $editor, $title, $timestamp, $summary,
+ $minorEdit, $oldid = false, $pageStatus = 'changed'
+ ) {
global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker, $wgEnotifMinorEdits,
$wgUsersNotifiedOnAllChanges, $wgEnotifUserTalk;
// Only send notification for non minor edits, unless $wgEnotifMinorEdits
if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
$isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK );
- if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) {
+ if ( $wgEnotifUserTalk
+ && $isUserTalkPage
+ && $this->canSendUserTalkEmail( $editor, $title, $minorEdit )
+ ) {
$sendEmail = true;
}
}
if ( !$sendEmail ) {
return;
}
+
if ( $wgEnotifUseJobQ ) {
$params = array(
'editor' => $editor->getName(),
$job = new EnotifNotifyJob( $title, $params );
JobQueueGroup::singleton()->push( $job );
} else {
- $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus );
+ $this->actuallyNotifyOnPageChange(
+ $editor,
+ $title,
+ $timestamp,
+ $summary,
+ $minorEdit,
+ $oldid,
+ $watchers,
+ $pageStatus
+ );
}
}
$userTalkId = false;
if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
-
- if ( $wgEnotifUserTalk && $isUserTalkPage && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) {
+ if ( $wgEnotifUserTalk
+ && $isUserTalkPage
+ && $this->canSendUserTalkEmail( $editor, $title, $minorEdit )
+ ) {
$targetUser = User::newFromName( $title->getText() );
$this->compose( $targetUser );
$userTalkId = $targetUser->getId();
->inContentLanguage()->text();
}
$keys['$OLDID'] = $this->oldid;
- // @deprecated Remove in MediaWiki 1.23.
+ // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
$keys['$CHANGEDORCREATED'] = wfMessage( 'changed' )->inContentLanguage()->text();
} else {
# clear $OLDID placeholder in the message template
$keys['$OLDID'] = '';
$keys['$NEWPAGE'] = '';
- // @deprecated Remove in MediaWiki 1.23.
+ // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
$keys['$CHANGEDORCREATED'] = wfMessage( 'created' )->inContentLanguage()->text();
}
$keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text();
} else {
- $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
+ $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== ''
+ ? $this->editor->getRealName() : $this->editor->getName();
$emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
$keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
}
$keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalURL();
+ $keys['$HELPPAGE'] = wfExpandUrl(
+ Skin::makeInternalOrExternalUrl( wfMessage( 'helppage' )->inContentLanguage()->text() )
+ );
# Replace this after transforming the message, bug 35019
$postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
function sendPersonalised( $watchingUser ) {
global $wgContLang, $wgEnotifUseRealName;
// From the PHP manual:
- // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>".
- // The mail command will not parse this properly while talking with the MTA.
+ // Note: The to parameter cannot be an address in the form of
+ // "Something <someone@example.com>". The mail command will not parse
+ // this properly while talking with the MTA.
$to = new MailAddress( $watchingUser );
# $PAGEEDITDATE is the time and date of the page change
array( '$WATCHINGUSERNAME',
'$PAGEEDITDATE',
'$PAGEEDITTIME' ),
- array( $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName(),
+ array( $wgEnotifUseRealName && $watchingUser->getRealName() !== ''
+ ? $watchingUser->getRealName() : $watchingUser->getName(),
$wgContLang->userDate( $this->timestamp, $watchingUser ),
$wgContLang->userTime( $this->timestamp, $watchingUser ) ),
$this->body );
/**
* Same as sendPersonalised but does impersonal mail suitable for bulk
* mailing. Takes an array of MailAddress objects.
- * @param array $addresses
+ * @param MailAddress[] $addresses
* @return Status|null
*/
function sendImpersonal( $addresses ) {