MediaWiki REL1_32
EmailNotification Class Reference

This module processes the email notifications when the current page is changed. More...

Collaboration diagram for EmailNotification:

Public Member Functions

 actuallyNotifyOnPageChange ( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers, $pageStatus='changed')
 Immediate version of notifyOnPageChange().
 
 compose ( $user, $source)
 Compose a mail to a given user and either queue it for sending, or send it now, depending on settings.
 
 notifyOnPageChange ( $editor, $title, $timestamp, $summary, $minorEdit, $oldid=false, $pageStatus='changed')
 Send emails corresponding to the user $editor editing the page $title.
 
 sendImpersonal ( $addresses)
 Same as sendPersonalised but does impersonal mail suitable for bulk mailing.
 
 sendMails ()
 Send any queued mails.
 
 sendPersonalised ( $watchingUser, $source)
 Does the per-user customizations to a notification e-mail (name, timestamp in proper timezone, etc) and sends it out.
 

Static Public Member Functions

static updateWatchlistTimestamp (User $editor, LinkTarget $linkTarget, $timestamp)
 

Public Attributes

const ALL_CHANGES = 'all_changes'
 Notification because user is notified for all changes.
 
const USER_TALK = 'user_talk'
 Notification is due to user's user talk being edited.
 
const WATCHLIST = 'watchlist'
 Notification is due to a watchlisted page being edited.
 

Protected Attributes

 $body
 
 $composed_common
 
User $editor
 
 $from
 
 $mailTargets = []
 
 $minorEdit
 
 $oldid
 
 $pageStatus
 
 $replyto
 
 $subject
 
 $summary
 
 $timestamp
 
Title $title
 

Private Member Functions

 canSendUserTalkEmail ( $editor, $title, $minorEdit)
 
 composeCommonMailtext ()
 Generate the generic "this page has been changed" e-mail text.
 

Detailed Description

This module processes the email notifications when the current page is changed.

It looks up the table watchlist to find out which users are watching that page.

The current implementation sends independent emails to each watching user for the following reason:

  • Each watching user will be notified about the page edit time expressed in his/her local time (UTC is shown additionally). To achieve this, we need to find the individual timeoffset of each watching user from the preferences..

Suggested improvement to slack down the number of sent emails: We could think of sending out bulk mails (bcc:user1,user2...) for all these users having the same timeoffset in their preferences.

Visit the documentation pages under https://www.mediawiki.org/wiki/Help:Watching_pages

Definition at line 49 of file EmailNotification.php.

Member Function Documentation

◆ actuallyNotifyOnPageChange()

EmailNotification::actuallyNotifyOnPageChange ( $editor,
$title,
$timestamp,
$summary,
$minorEdit,
$oldid,
$watchers,
$pageStatus = 'changed' )

Immediate version of notifyOnPageChange().

Send emails corresponding to the user $editor editing the page $title.

Note
Do not call directly. Use notifyOnPageChange so that wl_notificationtimestamp is updated.
Parameters
User$editor
Title$title
string$timestampEdit timestamp
string$summaryEdit summary
bool$minorEdit
int$oldidRevision ID
array$watchersArray of user IDs
string$pageStatus
Exceptions
MWException

Definition at line 190 of file EmailNotification.php.

References $editor, $minorEdit, $oldid, $pageStatus, $summary, $timestamp, $title, $wgBlockDisablesLogin, $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgEnotifWatchlist, $wgUsersNotifiedOnAllChanges, canSendUserTalkEmail(), compose(), User\getName(), User\isAllowed(), UserArray\newFromIDs(), User\newFromName(), NS_USER_TALK, and sendMails().

◆ canSendUserTalkEmail()

EmailNotification::canSendUserTalkEmail ( $editor,
$title,
$minorEdit )
private
Parameters
User$editor
Title$title
bool$minorEdit
Returns
bool

Definition at line 269 of file EmailNotification.php.

References $editor, $minorEdit, $wgBlockDisablesLogin, $wgEnotifUserTalk, User\getId(), User\newFromName(), NS_USER_TALK, and wfDebug().

Referenced by actuallyNotifyOnPageChange(), and notifyOnPageChange().

◆ compose()

EmailNotification::compose ( $user,
$source )

Compose a mail to a given user and either queue it for sending, or send it now, depending on settings.

Call sendMails() to send any mails that were queued.

Parameters
User$user
string$source

Definition at line 420 of file EmailNotification.php.

References $source, $wgEnotifImpersonal, composeCommonMailtext(), MailAddress\newFromUser(), and sendPersonalised().

Referenced by actuallyNotifyOnPageChange().

◆ composeCommonMailtext()

EmailNotification::composeCommonMailtext ( )
private

◆ notifyOnPageChange()

EmailNotification::notifyOnPageChange ( $editor,
$title,
$timestamp,
$summary,
$minorEdit,
$oldid = false,
$pageStatus = 'changed' )

Send emails corresponding to the user $editor editing the page $title.

May be deferred via the job queue.

Parameters
User$editor
Title$title
string$timestamp
string$summary
bool$minorEdit
bool$oldid(default: false)
string$pageStatus(default: 'changed')

Definition at line 118 of file EmailNotification.php.

References $editor, $minorEdit, $oldid, $pageStatus, $summary, $timestamp, $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgUsersNotifiedOnAllChanges, canSendUserTalkEmail(), User\getId(), User\getName(), User\isAllowed(), and NS_USER_TALK.

◆ sendImpersonal()

EmailNotification::sendImpersonal ( $addresses)

Same as sendPersonalised but does impersonal mail suitable for bulk mailing.

Takes an array of MailAddress objects.

Parameters
MailAddress[]$addresses
Returns
Status|null

Definition at line 493 of file EmailNotification.php.

References $body, UserMailer\send(), text, and wfMessage().

Referenced by sendMails().

◆ sendMails()

EmailNotification::sendMails ( )

Send any queued mails.

Definition at line 437 of file EmailNotification.php.

References $wgEnotifImpersonal, and sendImpersonal().

Referenced by actuallyNotifyOnPageChange().

◆ sendPersonalised()

EmailNotification::sendPersonalised ( $watchingUser,
$source )

Does the per-user customizations to a notification e-mail (name, timestamp in proper timezone, etc) and sends it out.

Returns true if the mail was sent successfully.

Parameters
User$watchingUser
string$source
Returns
bool
Access:\n private

Definition at line 454 of file EmailNotification.php.

References $body, $source, $wgEnotifUseRealName, MailAddress\newFromUser(), and UserMailer\send().

Referenced by compose().

◆ updateWatchlistTimestamp()

static EmailNotification::updateWatchlistTimestamp ( User $editor,
LinkTarget $linkTarget,
$timestamp )
static
Deprecated
since 1.27 use WatchedItemStore::updateNotificationTimestamp directly
Parameters
User$editorThe editor that triggered the update. Their notification timestamp will not be updated(they have already seen it)
LinkTarget$linkTargetThe link target of the title to update timestamps for
string$timestampSet the update timestamp to this value
Returns
int[] Array of user IDs

Definition at line 88 of file EmailNotification.php.

References $editor, $timestamp, and wfDeprecated().

Member Data Documentation

◆ $body

EmailNotification::$body
protected

Definition at line 64 of file EmailNotification.php.

Referenced by composeCommonMailtext(), sendImpersonal(), and sendPersonalised().

◆ $composed_common

EmailNotification::$composed_common
protected

Definition at line 65 of file EmailNotification.php.

◆ $editor

User EmailNotification::$editor
protected

◆ $from

EmailNotification::$from
protected

Definition at line 64 of file EmailNotification.php.

◆ $mailTargets

EmailNotification::$mailTargets = []
protected

Definition at line 66 of file EmailNotification.php.

◆ $minorEdit

EmailNotification::$minorEdit
protected

◆ $oldid

EmailNotification::$oldid
protected

◆ $pageStatus

EmailNotification::$pageStatus
protected

Definition at line 65 of file EmailNotification.php.

Referenced by actuallyNotifyOnPageChange(), and notifyOnPageChange().

◆ $replyto

EmailNotification::$replyto
protected

Definition at line 64 of file EmailNotification.php.

◆ $subject

EmailNotification::$subject
protected

Definition at line 64 of file EmailNotification.php.

◆ $summary

EmailNotification::$summary
protected

◆ $timestamp

EmailNotification::$timestamp
protected

◆ $title

Title EmailNotification::$title
protected

Definition at line 71 of file EmailNotification.php.

Referenced by actuallyNotifyOnPageChange().

◆ ALL_CHANGES

const EmailNotification::ALL_CHANGES = 'all_changes'

Notification because user is notified for all changes.

Definition at line 62 of file EmailNotification.php.

◆ USER_TALK

const EmailNotification::USER_TALK = 'user_talk'

Notification is due to user's user talk being edited.

Definition at line 54 of file EmailNotification.php.

◆ WATCHLIST

const EmailNotification::WATCHLIST = 'watchlist'

Notification is due to a watchlisted page being edited.

Definition at line 58 of file EmailNotification.php.


The documentation for this class was generated from the following file: