Index: trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlist.css |
— | — | @@ -10,4 +10,8 @@ |
11 | 11 | |
12 | 12 | .swl-watchlist-deletions { |
13 | 13 | display: inline; |
| 14 | +} |
| 15 | + |
| 16 | +.swl-watchlist-prop { |
| 17 | + |
14 | 18 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticWatchlist/specials/SpecialSemanticWatchlist.php |
— | — | @@ -172,8 +172,17 @@ |
173 | 173 | * @param array of SWLChangeSet $sets |
174 | 174 | */ |
175 | 175 | protected function displayWatchlist( array $sets ) { |
176 | | - global $wgOut, $wgLang; |
| 176 | + global $wgOut, $wgLang, $wgUser; |
177 | 177 | |
| 178 | + $lastViewed = $wgUser->getOption( 'swl_last_view' ); |
| 179 | + |
| 180 | + if ( is_null( $lastViewed ) ) { |
| 181 | + $lastViewed = wfTimestampNow(); |
| 182 | + } |
| 183 | + |
| 184 | + $wgUser->setOption( 'swl_last_view', wfTimestampNow() ); |
| 185 | + $wgUser->saveSettings(); |
| 186 | + |
178 | 187 | $changeSetsHTML = array(); |
179 | 188 | |
180 | 189 | foreach ( $sets as $set ) { |
— | — | @@ -183,7 +192,7 @@ |
184 | 193 | $changeSetsHTML[$dayKey] = array(); |
185 | 194 | } |
186 | 195 | |
187 | | - $changeSetsHTML[$dayKey][] = $this->getChangeSetHTML( $set ); |
| 196 | + $changeSetsHTML[$dayKey][] = $this->getChangeSetHTML( $set, $lastViewed ); |
188 | 197 | } |
189 | 198 | |
190 | 199 | krsort( $changeSetsHTML ); |
— | — | @@ -240,10 +249,11 @@ |
241 | 250 | * @since 0.1 |
242 | 251 | * |
243 | 252 | * @param SWLChangeSet $changeSet |
| 253 | + * @param integer $lastViewed The MW timestamp of when the user last viewed the watchlist |
244 | 254 | * |
245 | 255 | * @return string |
246 | 256 | */ |
247 | | - protected function getChangeSetHTML( SWLChangeSet $changeSet ) { |
| 257 | + protected function getChangeSetHTML( SWLChangeSet $changeSet, $lastViewed ) { |
248 | 258 | global $wgLang; |
249 | 259 | |
250 | 260 | $html = ''; |
— | — | @@ -284,7 +294,8 @@ |
285 | 295 | 'a', |
286 | 296 | array( 'href' => SpecialPage::getTitleFor( 'Block', $changeSet->getUser()->getName() )->getLocalURL() ), |
287 | 297 | wfMsg( 'blocklink' ) |
288 | | - ) . ')' . |
| 298 | + ) . ')' . |
| 299 | + ( $changeSet->getTime() > $lastViewed ? ' [NEW]' : '' ) . |
289 | 300 | '</p>' |
290 | 301 | ; |
291 | 302 | |
— | — | @@ -333,7 +344,7 @@ |
334 | 345 | $lines[] = Html::element( 'div', array( 'class' => 'swl-watchlist-deletions' ), wfMsg( 'swl-watchlist-deletions' ) ) . ' ' . implode( ', ', $deletions ); |
335 | 346 | } |
336 | 347 | |
337 | | - $html = Html::element( 'b', array(), $property->getLabel() ); |
| 348 | + $html = Html::element( 'span', array( 'class' => 'swl-watchlist-prop' ), $property->getLabel() ); |
338 | 349 | |
339 | 350 | $html .= Html::rawElement( |
340 | 351 | 'div', |
Index: trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | */ |
158 | 158 | public function __construct( SMWChangeSet $changeSet, /* User */ $user = null, $time = null, $id = null ) { |
159 | 159 | $this->changeSet = $changeSet; |
160 | | - $this->time = $time; |
| 160 | + $this->time = is_null( $time ) ? wfTimestampNow() : $time; |
161 | 161 | $this->user = is_null( $user ) ? $GLOBALS['wgUser'] : $user; |
162 | 162 | $this->id = $id; |
163 | 163 | } |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php |
— | — | @@ -39,6 +39,10 @@ |
40 | 40 | 'swl-watchlist-pagincontrol' => 'View ($1) ($2)', |
41 | 41 | 'swl-watchlist-firstn' => 'First $1', |
42 | 42 | 'swl-watchlist-firstn-title' => 'First $1 {{PLURAL:$1|result|results}}', |
| 43 | + |
| 44 | + // Email |
| 45 | + 'swl-email-propschanged' => 'Properties have changed', |
| 46 | + 'swl-email-propschanged' => 'Properties have changed', |
43 | 47 | ); |
44 | 48 | |
45 | 49 | /** German (Deutsch) |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php |
— | — | @@ -40,8 +40,7 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | | - * Determines and returns if the specified watchlist group covers |
45 | | - * the provided page or not. |
| 44 | + * Handles group notification. |
46 | 45 | * |
47 | 46 | * @since 0.1 |
48 | 47 | * |
— | — | @@ -52,17 +51,42 @@ |
53 | 52 | * @return true |
54 | 53 | */ |
55 | 54 | public static function onGroupNotify( SWLGroup $group, array $userIDs, SWLChangeSet $changes ) { |
56 | | - |
57 | 55 | foreach ( $userIDs as $userID ) { |
58 | | - self::notifyUser( $group, User::newFromId( $userID ), $changes ); |
| 56 | + $user = User::newFromId( $userID ); |
| 57 | + |
| 58 | + if ( Sanitizer::validateEmail( $user->getEmail() ) ) { |
| 59 | + $lastNotify = $user->getOption( 'swl_last_notify' ); |
| 60 | + $lastWatch = $user->getOption( 'swl_last_watch' ); |
| 61 | + |
| 62 | + if ( is_null( $lastNotify ) || is_null( $lastWatch ) || $lastNotify < $lastWatch ) { |
| 63 | + self::notifyUser( $group, $user, $changes ); |
| 64 | + $user->setOption( 'swl_last_notify', wfTimestampNow() ); |
| 65 | + $user->saveSettings(); |
| 66 | + } |
| 67 | + } |
59 | 68 | } |
60 | 69 | |
61 | 70 | return true; |
62 | 71 | } |
63 | 72 | |
| 73 | + /** |
| 74 | + * Notifies a single user of the changes made to properties in a single edit. |
| 75 | + * |
| 76 | + * @param SWLGroup $group |
| 77 | + * @param User $user |
| 78 | + * @param SWLChangeSet $changes |
| 79 | + * |
| 80 | + * @return Status |
| 81 | + */ |
64 | 82 | protected static function notifyUser( SWLGroup $group, User $user, SWLChangeSet $changes ) { |
| 83 | + $emailText = ''; |
| 84 | + |
65 | 85 | // TODO |
66 | | - //var_dump($group);var_dump($user);var_dump($changes);exit; |
| 86 | + |
| 87 | + return $user->sendMail( |
| 88 | + wfMsgReal( 'swl-email-propschanged', array(), true, $user->getOption( 'language' ) ), |
| 89 | + $emailText |
| 90 | + ); |
67 | 91 | } |
68 | 92 | |
69 | 93 | /** |