Refactor a bit; move a couple methods from UserMailer (?!) to User. Use the proper...
[lhc/web/wiklou.git] / includes / User.php
index 58fb9db..5b75fad 100644 (file)
@@ -795,8 +795,52 @@ class User {
                $wl->removeWatch();
                $this->invalidateCache();
        }
+
+       /**
+        * Clear the user's notification timestamp for the given title.
+        * If e-notif e-mails are on, they will receive notification mails on
+        * the next change of the page if it's watched etc.
+        */
+       function clearNotification( $title ) {
+               $dbw =& wfGetDB( DB_MASTER );
+               $success = $dbw->update( 'watchlist',
+                               array( /* SET */
+                                       'wl_notificationtimestamp' => 0
+                               ), array( /* WHERE */
+                                       'wl_title' => $title->getDBkey(),
+                                       'wl_namespace' => $title->getNamespace(),
+                                       'wl_user' => $this->getId()
+                               ), 'User::clearLastVisited'
+               );
+       }
+       
        /**#@-*/
 
+       /**
+        * Resets all of the given user's page-change notification timestamps.
+        * If e-notif e-mails are on, they will receive notification mails on
+        * the next change of any watched page.
+        *
+        * @param int $currentUser user ID number
+        * @access public
+        */
+       function clearAllNotifications( $currentUser ) {
+               if( $currentUser != 0 )  {
+       
+                       $dbw =& wfGetDB( DB_MASTER );
+                       $success = $dbw->update( 'watchlist',
+                               array( /* SET */
+                                       'wl_notificationtimestamp' => 0
+                               ), array( /* WHERE */
+                                       'wl_user' => $currentUser
+                               ), 'UserMailer::clearAll'
+                       );
+
+               #       we also need to clear here the "you have new message" notification for the own user_talk page
+               #       This is cleared one page view later in Article::viewUpdates();
+               }
+       }
+
        /**
         * @access private
         * @return string Encoding options