From: River Tarnell Date: Tue, 14 Feb 2006 21:10:31 +0000 (+0000) Subject: hooks for shared new talk notifications X-Git-Tag: 1.6.0~339 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=e603747352c379e1c70ae6fee60392d483a7be5a;p=lhc%2Fweb%2Fwiklou.git hooks for shared new talk notifications --- diff --git a/includes/Article.php b/includes/Article.php index 54f37777d4..aa2faa9294 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 ); + } } } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index beeecfa9e4..4850fccf1c 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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 = ''; } diff --git a/includes/User.php b/includes/User.php index c293125fcb..9a58bc986c 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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 ); } diff --git a/languages/Messages.php b/languages/Messages.php index 527dcba002..b7255a1251 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -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' => ', ', );