r49810 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49809‎ | r49810 | r49811 >
Date:09:48, 24 April 2009
Author:nad
Status:deferred
Tags:
Comment:
$WATCHINGUSERNAME was not set in emailed message, plus bug fixes
Modified paths:
  • /trunk/extensions/CategoryWatch/CategoryWatch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryWatch/CategoryWatch.php
@@ -98,19 +98,6 @@
9999 # Notify watchers of each cat about the addition or removal of this article
100100 if ( count( $add ) > 0 || count( $sub ) > 0 ) {
101101
102 - # Add urls to article and cat names
103 - foreach ( $add as $i => $v ) {
104 - $cat = Title::newFromText( $v, NS_CATEGORY );
105 - $catname = $cat->getPrefixedText();
106 - $caturl = $cat->getFullUrl();
107 - $add[$i] = "$catname ($caturl)";
108 - }
109 - foreach ( $sub as $i => $v ) {
110 - $cat = Title::newFromText( $v, NS_CATEGORY );
111 - $catname = $cat->getPrefixedText();
112 - $caturl = $cat->getFullUrl();
113 - $sub[$i] = "$catname ($caturl)";
114 - }
115102 $page = $article->getTitle();
116103 $pagename = $page->getPrefixedText();
117104 $pageurl = $page->getFullUrl();
@@ -121,24 +108,24 @@
122109 $sub = array_shift( $sub );
123110
124111 $title = Title::newFromText( $add, NS_CATEGORY );
125 - $message = wfMsg( 'categorywatch-catmovein', $page, $add, $sub );
 112+ $message = wfMsg( 'categorywatch-catmovein', $page, $this->friendlyCat( $add ), $this->friendlyCat( $sub ) );
126113 $this->notifyWatchers( $title, $user, $message );
127114
128115 #$title = Title::newFromText( $sub, NS_CATEGORY );
129 - #$message = wfMsg( 'categorywatch-catmoveout', $page, $sub, $add );
 116+ #$message = wfMsg( 'categorywatch-catmoveout', $page, $this->friendlyCat( $sub ), $this->friendlyCat( $add ) );
130117 #$this->notifyWatchers( $title, $user, $message );
131118 }
132119 else {
133120
134121 foreach ( $add as $cat ) {
135122 $title = Title::newFromText( $cat, NS_CATEGORY );
136 - $message = wfMsg( 'categorywatch-catadd', $page, $cat );
 123+ $message = wfMsg( 'categorywatch-catadd', $page, $this->friendlyCat( $cat ) );
137124 $this->notifyWatchers( $title, $user, $message );
138125 }
139126
140127 #foreach ( $sub as $cat ) {
141128 # $title = Title::newFromText( $cat, NS_CATEGORY );
142 - # $message = wfMsg( 'categorywatch-catsub', $page, $cat );
 129+ # $message = wfMsg( 'categorywatch-catsub', $page, $this->friendlyCat( $cat ) );
143130 # $this->notifyWatchers( $title, $user, $message );
144131 #}
145132 }
@@ -147,6 +134,16 @@
148135 return true;
149136 }
150137
 138+ /**
 139+ * Return "Category:Cat (URL)" from "Cat"
 140+ */
 141+ function friendlyCat( $cat ) {
 142+ $cat = Title::newFromText( $cat, NS_CATEGORY );
 143+ $catname = $cat->getPrefixedText();
 144+ $caturl = $cat->getFullUrl();
 145+ return "$catname ($caturl)";
 146+ }
 147+
151148 function notifyWatchers( &$title, &$editor, &$message ) {
152149 global $wgLang, $wgEmergencyContact, $wgNoReplyAddress, $wgCategoryWatchNotifyEditor,
153150 $wgEnotifRevealEditorAddress, $wgEnotifUseRealName, $wgPasswordSender, $wgEnotifFromEditor;
@@ -161,8 +158,8 @@
162159 $page = $title->getPrefixedText();
163160 $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
164161 $editorAddress = new MailAddress( $editor );
165 - foreach ( $res as $row ) {
166 - $watchingUser = User::newFromId( $row->wl_user );
 162+ while ( $row = $dbr->fetchRow( $res ) ) {
 163+ $watchingUser = User::newFromId( $row[0] );
167164 $timecorrection = $watchingUser->getOption( 'timecorrection' );
168165 $editdate = $wgLang->timeanddate( wfTimestampNow(), true, false, $timecorrection );
169166 if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && $watchingUser->isEmailConfirmed() ) {
@@ -192,10 +189,11 @@
193190 # Define keys for body message
194191 $userPage = $editor->getUserPage();
195192 $keys = array(
 193+ '$WATCHINGUSERNAME' => $name,
196194 '$NEWPAGE' => $message,
197195 '$PAGETITLE' => $page,
198196 '$PAGEEDITDATE' => $editdate,
199 - '$CHANGEDORCREATED' => wfMsgForContent( 'created' ),
 197+ '$CHANGEDORCREATED' => wfMsgForContent( 'changed' ),
200198 '$PAGETITLE_URL' => $title->getFullUrl(),
201199 '$PAGEEDITOR_WIKI' => $userPage->getFullUrl(),
202200 '$OLDID' => '',

Status & tagging log