Refactor a bit; move a couple methods from UserMailer (?!) to User. Use the proper...
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 18 Dec 2004 07:16:11 +0000 (07:16 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 18 Dec 2004 07:16:11 +0000 (07:16 +0000)
includes/Article.php
includes/SpecialWatchlist.php
includes/User.php
includes/UserMailer.php

index 8702382..572583d 100644 (file)
@@ -808,9 +808,7 @@ class Article {
                $this->viewUpdates();
                wfProfileOut( $fname );
 
-               include_once( "UserMailer.php" );
-               $wgEnotif = new EmailNotification ();
-               $wgEnotif->Clear( $wgUser->getID(), $this->mTitle->getDBkey(), $this->mTitle->getNamespace() );
+               $wgUser->clearNotification( $this->mTitle );
        }
 
        /**
index 046dabb..f2f4378 100644 (file)
@@ -41,9 +41,9 @@ function wfSpecialWatchlist() {
 
        $wgOut->addHTML( wfMsg( "email_notification_infotext" ) );
 
-       include_once( "UserMailer.php" );
-       $wgEnotif = new EmailNotification ();
-       $wgEnotif->ClearAll($wgUser->getID());
+       if( $wgRequest->getVal( 'reset' ) == 'all' ) {
+               $wgUser->clearAllNotifications();
+       }
 
        if(($action == "submit") && isset($remove) && is_array($id)) {
                $wgOut->addHTML( wfMsg( "removingchecked" ) );
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
index 422f1a8..d1f9255 100644 (file)
@@ -335,40 +335,5 @@ function ComposeAndSendPersonalisedMail( $watchingUser, $mail, $article) {
        return (userMailer($to, $mail->from, $mail->subject, $body, $mail->replyto) == '');
 }
 
-function Clear($currentUser, $currentPage, $currentNs) {
-       $dbw =& wfGetDB( DB_MASTER );
-       $success = $dbw->update( 'watchlist',
-                       array( /* SET */
-                               'wl_notificationtimestamp' => 0
-                       ), array( /* WHERE */
-                               'wl_title' => $currentPage,
-                               'wl_namespace' => $currentNs,
-                               'wl_user' => $currentUser
-                       ), 'UserMailer::Clear'
-       );
-}
-
-function ClearAll($currentUser) {
-       global $_REQUEST;
-
-       if ($currentUser != 0)  {
-
-               if( $_REQUEST['reset'] == 'all') {
-
-                       $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();
-               }
-       }
-}
-
 } # end of class EmailNotification
 ?>