- static function notify($editor, $timestamp, $userListFunction, $messageCompositionFunction) {
- global $wgEnotifUseRealName, $wgEnotifImpersonal;
- global $wgLang;
-
- $common_keys = self::commonMessageKeys($editor);
- $users = wfInvoke("userList", $userListFunction);
- foreach($users as $u) {
- list($user_keys, $body_msg_name, $subj_msg_name) =
- wfInvoke("message", $messageCompositionFunction, array($u));
- $keys = array_merge($common_keys, $user_keys);
-
- if( $wgEnotifImpersonal ) {
- $keys['$WATCHINGUSERNAME'] = wfMsgForContent('enotif_impersonal_salutation');
- $keys['$PAGEEDITDATE'] = $wgLang->timeanddate($timestamp, true, false, false);
- } else {
- $keys['$WATCHINGUSERNAME'] = $wgEnotifUseRealName ? $u->getRealName() : $u->getName();
- $keys['$PAGEEDITDATE'] = $wgLang->timeAndDate($timestamp, true, false,
- $u->getOption('timecorrection'));
- }
-
- $subject = strtr(wfMsgForContent( $subj_msg_name ), $keys);
- $body = wordwrap( strtr( wfMsgForContent( $body_msg_name ), $keys ), 72 );
-
- $to = new MailAddress($u);
- $from = $keys['$FROM_HEADER'];
- $replyto = $keys['$REPLYTO_HEADER'];
- UserMailer::send($to, $from, $subject, $body, $replyto);
- }
- }
-
-
- static function commonMessageKeys($editor) {
- global $wgEnotifUseRealName, $wgEnotifRevealEditorAddress;
- global $wgNoReplyAddress, $wgPasswordSender;
-
- $keys = array();
-
- $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
-
- $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
- $editorAddress = new MailAddress( $editor );
- if( $wgEnotifRevealEditorAddress
- && $editor->getEmail() != ''
- && $editor->getOption( 'enotifrevealaddr' ) ) {
- if( $wgEnotifFromEditor ) {
- $from = $editorAddress;
- } else {
- $from = $adminAddress;
- $replyto = $editorAddress;
- }
- } else {
- $from = $adminAddress;
- $replyto = new MailAddress( $wgNoReplyAddress );