MediaWiki  1.33.0
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(). More...
 
 compose ( $user, $source)
 Compose a mail to a given user and either queue it for sending, or send it now, depending on settings. More...
 
 getPageStatus ()
 Extensions that have hooks for UpdateUserMailerFormattedPageStatus (to provide additional pageStatus indicators) need a way to make sure that, when their hook is called in SendWatchlistemailNotification, they only handle notifications using their pageStatus indicator. More...
 
 notifyOnPageChange ( $editor, $title, $timestamp, $summary, $minorEdit, $oldid=false, $pageStatus='changed')
 Send emails corresponding to the user $editor editing the page $title. More...
 
 sendImpersonal ( $addresses)
 Same as sendPersonalised but does impersonal mail suitable for bulk mailing. More...
 
 sendMails ()
 Send any queued mails. More...
 

Public Attributes

 $body
 
 $composed_common
 
 $from
 
 $minorEdit
 
 $oldid
 
 $pageStatus
 
 $replyto
 
 $summary
 
const ALL_CHANGES = 'all_changes'
 Notification because user is notified for all changes. More...
 
const USER_TALK = 'user_talk'
 Notification is due to user's user talk being edited. More...
 
const WATCHLIST = 'watchlist'
 Notification is due to a watchlisted page being edited. More...
 

Protected Attributes

User $editor
 
 $mailTargets = []
 
 $subject
 
 $timestamp
 
Title $title
 

Private Member Functions

 canSendUserTalkEmail ( $editor, $title, $minorEdit)
 
 composeCommonMailtext ()
 Generate the generic "this page has been changed" e-mail text. More...
 
 sendPersonalised ( $watchingUser, $source)
 Does the per-user customizations to a notification e-mail (name, timestamp in proper timezone, etc) and sends it out. More...
 

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 48 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 176 of file EmailNotification.php.

References $editor, $minorEdit, $name, $oldid, $pageStatus, $summary, $timestamp, $title, $user, $wgBlockDisablesLogin, $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgEnotifWatchlist, $wgUsersNotifiedOnAllChanges, as, canSendUserTalkEmail(), compose(), User\getName(), Title\getNamespace(), Title\getText(), User\isAllowed(), UserArray\newFromIDs(), User\newFromName(), NS_USER_TALK, Hooks\run(), sendMails(), and title.

◆ canSendUserTalkEmail()

EmailNotification::canSendUserTalkEmail (   $editor,
  $title,
  $minorEdit 
)
private

◆ 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 406 of file EmailNotification.php.

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

Referenced by actuallyNotifyOnPageChange().

◆ composeCommonMailtext()

EmailNotification::composeCommonMailtext ( )
private

◆ getPageStatus()

EmailNotification::getPageStatus ( )

Extensions that have hooks for UpdateUserMailerFormattedPageStatus (to provide additional pageStatus indicators) need a way to make sure that, when their hook is called in SendWatchlistemailNotification, they only handle notifications using their pageStatus indicator.

Since
1.33
Returns
string

Definition at line 87 of file EmailNotification.php.

References $pageStatus.

◆ 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 104 of file EmailNotification.php.

References $editor, $minorEdit, $oldid, $pageStatus, $summary, $timestamp, $title, $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgUsersNotifiedOnAllChanges, canSendUserTalkEmail(), captcha-old\count, User\getId(), RequestContext\getMain(), User\getName(), Title\getNamespace(), User\isAllowed(), NS_USER_TALK, and JobQueueGroup\singleton().

◆ 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 480 of file EmailNotification.php.

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

Referenced by sendMails().

◆ sendMails()

EmailNotification::sendMails ( )

Send any queued mails.

Definition at line 423 of file EmailNotification.php.

References $wgEnotifImpersonal, and sendImpersonal().

Referenced by actuallyNotifyOnPageChange().

◆ sendPersonalised()

EmailNotification::sendPersonalised (   $watchingUser,
  $source 
)
private

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

Returns Status if email was sent successfully or not (Status::newGood() or Status::newFatal() respectively).

Parameters
User$watchingUser
string$source
Returns
Status

Definition at line 441 of file EmailNotification.php.

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

Referenced by compose().

Member Data Documentation

◆ $body

EmailNotification::$body

Definition at line 63 of file EmailNotification.php.

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

◆ $composed_common

EmailNotification::$composed_common

Definition at line 64 of file EmailNotification.php.

◆ $editor

User EmailNotification::$editor
protected

◆ $from

EmailNotification::$from

Definition at line 63 of file EmailNotification.php.

◆ $mailTargets

EmailNotification::$mailTargets = []
protected

Definition at line 65 of file EmailNotification.php.

◆ $minorEdit

EmailNotification::$minorEdit

◆ $oldid

EmailNotification::$oldid

◆ $pageStatus

EmailNotification::$pageStatus

◆ $replyto

EmailNotification::$replyto

Definition at line 63 of file EmailNotification.php.

◆ $subject

EmailNotification::$subject
protected

Definition at line 63 of file EmailNotification.php.

◆ $summary

EmailNotification::$summary

◆ $timestamp

EmailNotification::$timestamp
protected

Definition at line 64 of file EmailNotification.php.

Referenced by actuallyNotifyOnPageChange(), and notifyOnPageChange().

◆ $title

Title EmailNotification::$title
protected

◆ ALL_CHANGES

const EmailNotification::ALL_CHANGES = 'all_changes'

Notification because user is notified for all changes.

Definition at line 61 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 53 of file EmailNotification.php.

◆ WATCHLIST

const EmailNotification::WATCHLIST = 'watchlist'

Notification is due to a watchlisted page being edited.

Definition at line 57 of file EmailNotification.php.


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