Index: trunk/extensions/CategoryWatch/CategoryWatch.php |
— | — | @@ -130,7 +130,8 @@ |
131 | 131 | } |
132 | 132 | |
133 | 133 | function notifyWatchers( &$title, &$editor, &$message ) { |
134 | | - global $wgLang, $wgEmergencyContact, $wgNoReplyAddress, $wgCategoryWatchNotifyEditor; |
| 134 | + global $wgLang, $wgEmergencyContact, $wgNoReplyAddress, $wgCategoryWatchNotifyEditor, |
| 135 | + $wgEnotifRevealEditorAddress, $wgEnotifUseRealName, $wgPasswordSender, $wgEnotifFromEditor; |
135 | 136 | |
136 | 137 | # Get list of users watching this category |
137 | 138 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -139,114 +140,60 @@ |
140 | 141 | $res = $dbr->select( 'watchlist', array( 'wl_user' ), $conds, __METHOD__ ); |
141 | 142 | |
142 | 143 | # 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 ); |
146 | 147 | foreach ( $res as $row ) { |
147 | 148 | $watchingUser = User::newFromId( $row->wl_user ); |
148 | 149 | if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && $watchingUser->isEmailConfirmed() ) { |
149 | 150 | |
150 | 151 | $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' ); |
165 | 154 | |
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 | | - |
195 | 155 | # Reveal the page editor's address as REPLY-TO address only if |
196 | 156 | # the user has not opted-out and the option is enabled at the |
197 | 157 | # 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 |
203 | 160 | && ( $editor->getEmail() != '' ) |
204 | 161 | && $editor->getOption( 'enotifrevealaddr' ) ) { |
205 | | - if( $wgEnotifFromEditor ) { |
206 | | - $from = $editorAddress; |
| 162 | + if ( $wgEnotifFromEditor ) { |
| 163 | + $from = $editorAddress; |
207 | 164 | } else { |
208 | | - $from = $adminAddress; |
| 165 | + $from = $adminAddress; |
209 | 166 | $replyto = $editorAddress; |
210 | 167 | } |
211 | 168 | } else { |
212 | | - $from = $adminAddress; |
| 169 | + $from = $adminAddress; |
213 | 170 | $replyto = new MailAddress( $wgNoReplyAddress ); |
214 | 171 | } |
215 | 172 | |
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; |
221 | 183 | $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' ); |
222 | 184 | } else { |
223 | | - $subject = str_replace('$PAGEEDITOR', $name, $subject); |
224 | | - $keys['$PAGEEDITOR'] = $name; |
| 185 | + $subject = str_replace( '$PAGEEDITOR', $name, $subject ); |
| 186 | + $keys['$PAGEEDITOR'] = $name; |
225 | 187 | $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name ); |
226 | 188 | $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getFullUrl(); |
227 | 189 | } |
228 | 190 | $userPage = $editor->getUserPage(); |
229 | 191 | $keys['$PAGEEDITOR_WIKI'] = $userPage->getFullUrl(); |
| 192 | + |
| 193 | + # Replace keys, wrap text and send |
230 | 194 | $body = strtr( $body, $keys ); |
231 | 195 | $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 ); |
251 | 198 | } |
252 | 199 | } |
253 | 200 | |