r49750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49749‎ | r49750 | r49751 >
Date:03:31, 23 April 2009
Author:nad
Status:deferred
Tags:
Comment:
use normal watchlists enotif_body message structure
Modified paths:
  • /trunk/extensions/CategoryWatch/CategoryWatch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryWatch/CategoryWatch.php
@@ -130,7 +130,8 @@
131131 }
132132
133133 function notifyWatchers( &$title, &$editor, &$message ) {
134 - global $wgLang, $wgEmergencyContact, $wgNoReplyAddress, $wgCategoryWatchNotifyEditor;
 134+ global $wgLang, $wgEmergencyContact, $wgNoReplyAddress, $wgCategoryWatchNotifyEditor,
 135+ $wgEnotifRevealEditorAddress, $wgEnotifUseRealName, $wgPasswordSender, $wgEnotifFromEditor;
135136
136137 # Get list of users watching this category
137138 $dbr = wfGetDB( DB_SLAVE );
@@ -139,114 +140,60 @@
140141 $res = $dbr->select( 'watchlist', array( 'wl_user' ), $conds, __METHOD__ );
141142
142143 # Wrap message with common body and send to each watcher
143 - $page = $title->getText();
144 - $from = new MailAddress( $wgEmergencyContact, 'WikiAdmin' );
145 - $replyto = new MailAddress( $wgNoReplyAddress );
 144+ $page = $title->getText();
 145+ $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
 146+ $editorAddress = new MailAddress( $editor );
146147 foreach ( $res as $row ) {
147148 $watchingUser = User::newFromId( $row->wl_user );
148149 if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && $watchingUser->isEmailConfirmed() ) {
149150
150151 $to = new MailAddress( $watchingUser );
151 - $timecorrection = $watchingUser->getOption( 'timecorrection' );
152 - $editdate = $wgLang->timeanddate( wfTimestampNow(), true, false, $timecorrection );
153 - $editdat1 = $wgLang->date( wfTimestampNow(), true, false, $timecorrection );
154 - $edittim2 = $wgLang->time( wfTimestampNow(), true, false, $timecorrection );
155 - $body = wfMsg(
156 - 'categorywatch-emailbody',
157 - $watchingUser->getName(),
158 - $page,
159 - $editdate,
160 - $editor->getName(),
161 - $message,
162 - $editdat1,
163 - $edittim2
164 - );
 152+ $subject = wfMsg( 'categorywatch-emailsubject', $page );
 153+ $body = wfMsgForContent( 'enotif_body' );
165154
166 - $subject = wfMsgForContent( 'enotif_subject' );
167 - $body = wfMsgForContent( 'enotif_body' );
168 - $keys = array();
169 -
170 - if ( $this->oldid ) {
171 - $difflink = $this->title->getFullUrl( 'diff=0&oldid=' . $this->oldid );
172 - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', $difflink );
173 - $keys['$OLDID'] = $this->oldid;
174 - $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' );
175 - } else {
176 - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_newpagetext' );
177 - # clear $OLDID placeholder in the message template
178 - $keys['$OLDID'] = '';
179 - $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
180 - }
181 -
182 - if ($wgEnotifImpersonal && $this->oldid)
183 - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff', $this->title->getFullURL( "oldid={$this->oldid}&diff=prev" ) );
184 -
185 - $body = strtr( $body, $keys );
186 - $pagetitle = $this->title->getPrefixedText();
187 - $keys['$PAGETITLE'] = $pagetitle;
188 - $keys['$PAGETITLE_URL'] = $this->title->getFullUrl();
189 -
190 - $keys['$PAGEMINOREDIT'] = $medit;
191 - $keys['$PAGESUMMARY'] = $summary;
192 -
193 - $subject = strtr( $subject, $keys );
194 -
195155 # Reveal the page editor's address as REPLY-TO address only if
196156 # the user has not opted-out and the option is enabled at the
197157 # global configuration level.
198 - $editor = $this->editor;
199 - $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
200 - $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
201 - $editorAddress = new MailAddress( $editor );
202 - if( $wgEnotifRevealEditorAddress
 158+ $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
 159+ if ( $wgEnotifRevealEditorAddress
203160 && ( $editor->getEmail() != '' )
204161 && $editor->getOption( 'enotifrevealaddr' ) ) {
205 - if( $wgEnotifFromEditor ) {
206 - $from = $editorAddress;
 162+ if ( $wgEnotifFromEditor ) {
 163+ $from = $editorAddress;
207164 } else {
208 - $from = $adminAddress;
 165+ $from = $adminAddress;
209166 $replyto = $editorAddress;
210167 }
211168 } else {
212 - $from = $adminAddress;
 169+ $from = $adminAddress;
213170 $replyto = new MailAddress( $wgNoReplyAddress );
214171 }
215172
216 - if( $editor->isIP( $name ) ) {
217 - #real anon (user:xxx.xxx.xxx.xxx)
218 - $utext = wfMsgForContent('enotif_anon_editor', $name);
219 - $subject = str_replace('$PAGEEDITOR', $utext, $subject);
220 - $keys['$PAGEEDITOR'] = $utext;
 173+ # Define keys for body message
 174+ $keys = array(
 175+ '$NEWPAGE' => $message,
 176+ '$CHANGEDORCREATED' => wfMsgForContent( 'created' ),
 177+ '$OLDID' => ''
 178+ );
 179+ if ( $editor->isIP( $name ) ) {
 180+ $utext = wfMsgForContent( 'enotif_anon_editor', $name );
 181+ $subject = str_replace( '$PAGEEDITOR', $utext, $subject );
 182+ $keys['$PAGEEDITOR'] = $utext;
221183 $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
222184 } else {
223 - $subject = str_replace('$PAGEEDITOR', $name, $subject);
224 - $keys['$PAGEEDITOR'] = $name;
 185+ $subject = str_replace( '$PAGEEDITOR', $name, $subject );
 186+ $keys['$PAGEEDITOR'] = $name;
225187 $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name );
226188 $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getFullUrl();
227189 }
228190 $userPage = $editor->getUserPage();
229191 $keys['$PAGEEDITOR_WIKI'] = $userPage->getFullUrl();
 192+
 193+ # Replace keys, wrap text and send
230194 $body = strtr( $body, $keys );
231195 $body = wordwrap( $body, 72 );
232 -
233 - if ( function_exists( 'userMailer' ) ) {
234 - userMailer(
235 - $to,
236 - $from,
237 - wfMsg( 'categorywatch-emailsubject', $page ),
238 - $body,
239 - $replyto
240 - );
241 - }
242 - else {
243 - UserMailer::send(
244 - $to,
245 - $from,
246 - wfMsg( 'categorywatch-emailsubject', $page ),
247 - $body,
248 - $replyto
249 - );
250 - }
 196+ if ( function_exists( 'userMailer' ) ) userMailer( $to, $from, $subject, $body, $replyto );
 197+ else UserMailer::send( $to, $from, $subject, $body, $replyto );
251198 }
252199 }
253200

Status & tagging log