hooks for shared new talk notifications
authorRiver Tarnell <kateturner@users.mediawiki.org>
Tue, 14 Feb 2006 21:10:31 +0000 (21:10 +0000)
committerRiver Tarnell <kateturner@users.mediawiki.org>
Tue, 14 Feb 2006 21:10:31 +0000 (21:10 +0000)
includes/Article.php
includes/SkinTemplate.php
includes/User.php
languages/Messages.php

index 54f3777..aa2faa9 100644 (file)
@@ -2214,14 +2214,16 @@ class Article {
                # If this is another user's talk page, update newtalk
 
                if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getName()) {
-                       $other = User::newFromName( $shortTitle );
-                       if( is_null( $other ) && User::isIP( $shortTitle ) ) {
-                               // An anonymous user
-                               $other = new User();
-                               $other->setName( $shortTitle );
-                       }
-                       if( $other ) {
-                               $other->setNewtalk( true );
+                       if (wfRunHooks('ArticleEditUpdateNewTalk', array(&$this)) ) {
+                               $other = User::newFromName( $shortTitle );
+                               if( is_null( $other ) && User::isIP( $shortTitle ) ) {
+                                       // An anonymous user
+                                       $other = new User();
+                                       $other->setName( $shortTitle );
+                               }
+                               if( $other ) {
+                                       $other->setNewtalk( true );
+                               }
                        }
                }
 
index beeecfa..4850fcc 100644 (file)
@@ -147,6 +147,7 @@ class SkinTemplate extends Skin {
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
                global $wgUseTrackbacks;
+               global $wgDBname;
 
                $fname = 'SkinTemplate::outputPage';
                wfProfileIn( $fname );
@@ -269,7 +270,9 @@ class SkinTemplate extends Skin {
                } else {
                        $tpl->set('jsvarurl', false);
                }
-               if( $wgUser->getNewtalk() ) {
+               $newtalks = $wgUser->getTalkPages();
+
+               if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) {
                        $usertitle = $this->mUser->getUserPage();
                        $usertalktitle = $usertitle->getTalkPage();
                        if( !$usertalktitle->equals( $this->mTitle ) ) {
@@ -287,6 +290,16 @@ class SkinTemplate extends Skin {
                                # Disable Cache
                                $wgOut->setSquidMaxage(0);
                        }
+               } else if (count($newtalks)) {
+                       $sep = wfMsg("newtalkseperator");
+                       $msgs = array();
+                       foreach ($newtalks as $newtalk) {
+                               $msgs[] = wfElement("a", 
+                                       array('href' => $newtalk["link"]), $newtalk["wiki"]);
+                       }
+                       $parts = implode($sep, $msgs);
+                       $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
+                       $wgOut->setSquidMaxage(0);
                } else {
                        $ntl = '';
                }
index c293125..9a58bc9 100644 (file)
@@ -810,6 +810,23 @@ class User {
                return (bool)$this->mNewtalk;
        }
 
+       /**
+        * Return the talk page(s) this user has new messages on.
+        */
+       function getTalkPages() {
+       global  $wgDBname;
+               $talks = array();
+               if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
+                       return $talks;
+
+               if (!$this->getNewtalk())
+                       return array();
+               $up = $this->getUserPage();
+               $utp = $up->getTalkPage();
+               return array(array("wiki" => $wgDBname, "link" => $utp->getLocalURL()));
+       }
+
+               
        /**
         * Perform a user_newtalk check on current slaves; if the memcached data
         * is funky we don't want newtalk state to get stuck on save, as that's
@@ -1224,8 +1241,11 @@ class User {
        function clearNotification( &$title ) {
                global $wgUser, $wgUseEnotif;
 
+
                if ($title->getNamespace() == NS_USER_TALK &&
                        $title->getText() == $this->getName() ) {
+                       if (!wfRunHooks('UserClearNewTalkNotification', array(&$this)))
+                               return;
                        $this->setNewtalk( false );
                }
 
index 527dcba..b7255a1 100644 (file)
@@ -1932,6 +1932,8 @@ Please confirm that really want to recreate this article.',
 'confirm_purge' => "Clear the cache of this page?\n\n$1",
 'confirm_purge_button' => 'OK',
 
+'youhavenewmessagesmulti' => "You have new messages on $1",
+'newtalkseperator' => ', ',
 );