Index: trunk/extensions/CategoryWatch/CategoryWatch.i18n.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Internationalisation file for extension CategoryWatch. |
5 | 5 | * |
6 | 6 | * @addtogroup Extensions |
7 | | -*/ |
| 7 | + */ |
8 | 8 | |
9 | 9 | $messages = array(); |
10 | 10 | |
Index: trunk/extensions/CategoryWatch/CategoryWatch.php |
— | — | @@ -13,9 +13,9 @@ |
14 | 14 | * @licence GNU General Public Licence 2.0 or later |
15 | 15 | */ |
16 | 16 | |
17 | | -if ( !defined('MEDIAWIKI' ) ) die( 'Not an entry point.' ); |
| 17 | +if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' ); |
18 | 18 | |
19 | | -define( 'CATEGORYWATCH_VERSION', '1.1.0, 2009-04-21' ); |
| 19 | +define( 'CATEGORYWATCH_VERSION', '1.1.1, 2010-04-21' ); |
20 | 20 | |
21 | 21 | $wgCategoryWatchNotifyEditor = true; |
22 | 22 | $wgCategoryWatchUseAutoCat = false; |
— | — | @@ -30,10 +30,9 @@ |
31 | 31 | 'version' => CATEGORYWATCH_VERSION, |
32 | 32 | ); |
33 | 33 | |
34 | | -$wgExtensionMessagesFiles['CategoryWatch'] = dirname(__FILE__) . '/CategoryWatch.i18n.php'; |
| 34 | +$wgExtensionMessagesFiles['CategoryWatch'] = dirname( __FILE__ ) . '/CategoryWatch.i18n.php'; |
35 | 35 | |
36 | 36 | class CategoryWatch { |
37 | | - |
38 | 37 | function __construct() { |
39 | 38 | global $wgHooks; |
40 | 39 | $wgHooks['ArticleSave'][] = $this; |
— | — | @@ -45,7 +44,7 @@ |
46 | 45 | */ |
47 | 46 | function onArticleSave( &$article, &$user, &$text ) { |
48 | 47 | global $wgCategoryWatchUseAutoCat; |
49 | | - |
| 48 | + |
50 | 49 | $this->before = array(); |
51 | 50 | $dbr = wfGetDB( DB_SLAVE ); |
52 | 51 | $cl = $dbr->tableName( 'categorylinks' ); |
— | — | @@ -64,7 +63,7 @@ |
65 | 64 | $wtbl = $dbr->tableName( 'watchlist' ); |
66 | 65 | $sql = "SELECT user_id FROM $utbl LEFT JOIN $wtbl ON user_id=wl_user AND wl_title LIKE '%$like%' WHERE wl_user IS NULL"; |
67 | 66 | $res = $dbr->query( $sql ); |
68 | | - |
| 67 | + |
69 | 68 | # Insert an entry into watchlist for each |
70 | 69 | while ( $row = $dbr->fetchRow( $res ) ) { |
71 | 70 | $uname = User::newFromId( $row[0] )->getName(); |
— | — | @@ -72,7 +71,7 @@ |
73 | 72 | $dbr->insert( $wtbl, array( 'wl_user' => $row[0], 'wl_namespace' => NS_CATEGORY, 'wl_title' => $wl_title ) ); |
74 | 73 | } |
75 | 74 | $dbr->freeResult( $res ); |
76 | | - } |
| 75 | + } |
77 | 76 | |
78 | 77 | return true; |
79 | 78 | } |
— | — | @@ -81,7 +80,6 @@ |
82 | 81 | * Find changes in categorisation and send messages to watching users |
83 | 82 | */ |
84 | 83 | function onArticleSaveComplete( &$article, &$user, &$text, &$summary, &$medit ) { |
85 | | - |
86 | 84 | # Get cats after update |
87 | 85 | $this->after = array(); |
88 | 86 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -97,12 +95,11 @@ |
98 | 96 | |
99 | 97 | # Notify watchers of each cat about the addition or removal of this article |
100 | 98 | if ( count( $add ) > 0 || count( $sub ) > 0 ) { |
101 | | - |
102 | 99 | $page = $article->getTitle(); |
103 | 100 | $pagename = $page->getPrefixedText(); |
104 | 101 | $pageurl = $page->getFullUrl(); |
105 | 102 | $page = "$pagename ($pageurl)"; |
106 | | - |
| 103 | + |
107 | 104 | if ( count( $add ) == 1 && count( $sub ) == 1 ) { |
108 | 105 | $add = array_shift( $add ); |
109 | 106 | $sub = array_shift( $sub ); |
— | — | @@ -111,23 +108,21 @@ |
112 | 109 | $message = wfMsg( 'categorywatch-catmovein', $page, $this->friendlyCat( $add ), $this->friendlyCat( $sub ) ); |
113 | 110 | $this->notifyWatchers( $title, $user, $message, $summary, $medit ); |
114 | 111 | |
115 | | - #$title = Title::newFromText( $sub, NS_CATEGORY ); |
116 | | - #$message = wfMsg( 'categorywatch-catmoveout', $page, $this->friendlyCat( $sub ), $this->friendlyCat( $add ) ); |
117 | | - #$this->notifyWatchers( $title, $user, $message, $summary, $medit ); |
118 | | - } |
119 | | - else { |
120 | | - |
| 112 | + # $title = Title::newFromText( $sub, NS_CATEGORY ); |
| 113 | + # $message = wfMsg( 'categorywatch-catmoveout', $page, $this->friendlyCat( $sub ), $this->friendlyCat( $add ) ); |
| 114 | + # $this->notifyWatchers( $title, $user, $message, $summary, $medit ); |
| 115 | + } else { |
121 | 116 | foreach ( $add as $cat ) { |
122 | 117 | $title = Title::newFromText( $cat, NS_CATEGORY ); |
123 | 118 | $message = wfMsg( 'categorywatch-catadd', $page, $this->friendlyCat( $cat ) ); |
124 | 119 | $this->notifyWatchers( $title, $user, $message, $summary, $medit ); |
125 | 120 | } |
126 | 121 | |
127 | | - #foreach ( $sub as $cat ) { |
| 122 | + # foreach ( $sub as $cat ) { |
128 | 123 | # $title = Title::newFromText( $cat, NS_CATEGORY ); |
129 | 124 | # $message = wfMsg( 'categorywatch-catsub', $page, $this->friendlyCat( $cat ) ); |
130 | 125 | # $this->notifyWatchers( $title, $user, $message, $summary, $medit ); |
131 | | - #} |
| 126 | + # } |
132 | 127 | } |
133 | 128 | } |
134 | 129 | |
— | — | @@ -151,7 +146,7 @@ |
152 | 147 | # Get list of users watching this category |
153 | 148 | $dbr = wfGetDB( DB_SLAVE ); |
154 | 149 | $conds = array( 'wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace() ); |
155 | | - if ( !$wgCategoryWatchNotifyEditor) $conds[] = 'wl_user <> ' . intval( $editor->getId() ); |
| 150 | + if ( !$wgCategoryWatchNotifyEditor ) $conds[] = 'wl_user <> ' . intval( $editor->getId() ); |
156 | 151 | $res = $dbr->select( 'watchlist', array( 'wl_user' ), $conds, __METHOD__ ); |
157 | 152 | |
158 | 153 | # Wrap message with common body and send to each watcher |
— | — | @@ -164,8 +159,8 @@ |
165 | 160 | $watchingUser = User::newFromId( $row[0] ); |
166 | 161 | $timecorrection = $watchingUser->getOption( 'timecorrection' ); |
167 | 162 | $editdate = $wgLang->timeanddate( wfTimestampNow(), true, false, $timecorrection ); |
| 163 | + |
168 | 164 | if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && $watchingUser->isEmailConfirmed() ) { |
169 | | - |
170 | 165 | $to = new MailAddress( $watchingUser ); |
171 | 166 | $subject = wfMsg( 'categorywatch-emailsubject', $page ); |
172 | 167 | $body = wfMsgForContent( 'enotif_body' ); |
— | — | @@ -218,8 +213,11 @@ |
219 | 214 | # Replace keys, wrap text and send |
220 | 215 | $body = strtr( $body, $keys ); |
221 | 216 | $body = wordwrap( $body, 72 ); |
222 | | - if ( function_exists( 'userMailer' ) ) userMailer( $to, $from, $subject, $body, $replyto ); |
223 | | - else UserMailer::send( $to, $from, $subject, $body, $replyto ); |
| 217 | + if ( function_exists( 'userMailer' ) ) { |
| 218 | + userMailer( $to, $from, $subject, $body, $replyto ); |
| 219 | + } else { |
| 220 | + UserMailer::send( $to, $from, $subject, $body, $replyto ); |
| 221 | + } |
224 | 222 | } |
225 | 223 | } |
226 | 224 | |
— | — | @@ -239,5 +237,4 @@ |
240 | 238 | |
241 | 239 | # Instantiate the CategoryWatch singleton now that the environment is prepared |
242 | 240 | $wgCategoryWatch = new CategoryWatch(); |
243 | | - |
244 | 241 | } |