r13015 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13014‎ | r13015 | r13016 >
Date:21:49, 14 February 2006
Author:kateturner
Status:old
Tags:
Comment:
MFC: shared new talk notification
Modified paths:
  • /branches/REL1_5/phase3/includes/Article.php (modified) (history)
  • /branches/REL1_5/phase3/includes/SkinTemplate.php (modified) (history)
  • /branches/REL1_5/phase3/includes/User.php (modified) (history)
  • /branches/REL1_5/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: branches/REL1_5/phase3/includes/User.php
@@ -785,6 +785,22 @@
786786 return ( 0 != $this->mNewtalk );
787787 }
788788
 789+ /**
 790+ * Return the talk page(s) this user has new messages on.
 791+ */
 792+ function getNewMessageLinks() {
 793+ global $wgDBname;
 794+ $talks = array();
 795+ if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
 796+ return $talks;
 797+
 798+ if (!$this->getNewtalk())
 799+ return array();
 800+ $up = $this->getUserPage();
 801+ $utp = $up->getTalkPage();
 802+ return array(array("wiki" => $wgDBname, "link" => $utp->getLocalURL()));
 803+ }
 804+
789805 function setNewtalk( $val ) {
790806 $this->loadFromDatabase();
791807 $this->mNewtalk = $val;
Index: branches/REL1_5/phase3/includes/Article.php
@@ -2070,21 +2070,27 @@
20712071 # Update newtalk status if user is reading their own
20722072 # talk page
20732073
 2074+ if (!wfRunHooks('UserClearNewTalkNotification', array(&$this)))
 2075+ return;
 2076+
20742077 global $wgUser;
2075 - if ($this->mTitle->getNamespace() == NS_USER_TALK &&
2076 - $this->mTitle->getText() == $wgUser->getName())
2077 - {
2078 - if ( $wgUseEnotif ) {
2079 - require_once( 'UserTalkUpdate.php' );
2080 - $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
2081 - } else {
2082 - $wgUser->setNewtalk(0);
2083 - $wgUser->saveNewtalk();
 2078+ if (wfRunHooks('ArticleEditUpdateNewTalk', array(&$this)) ) {
 2079+ if ($this->mTitle->getNamespace() == NS_USER_TALK &&
 2080+ $this->mTitle->getText() == $wgUser->getName())
 2081+ {
 2082+
 2083+ if ( $wgUseEnotif ) {
 2084+ require_once( 'UserTalkUpdate.php' );
 2085+ $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(),
 2086+ $this->mTitle->getDBkey(), false, false, false );
 2087+ } else {
 2088+ $wgUser->setNewtalk(0);
 2089+ $wgUser->saveNewtalk();
 2090+ }
 2091+ } elseif ( $wgUseEnotif ) {
 2092+ $wgUser->clearNotification( $this->mTitle );
20842093 }
2085 - } elseif ( $wgUseEnotif ) {
2086 - $wgUser->clearNotification( $this->mTitle );
20872094 }
2088 -
20892095 }
20902096
20912097 /**
Index: branches/REL1_5/phase3/includes/SkinTemplate.php
@@ -150,6 +150,7 @@
151151 global $wgMaxCredits, $wgShowCreditsIfMax;
152152 global $wgPageShowWatchingUsers;
153153 global $wgUseTrackbacks;
 154+ global $wgDBname;
154155
155156 $fname = 'SkinTemplate::outputPage';
156157 wfProfileIn( $fname );
@@ -264,7 +265,9 @@
265266 } else {
266267 $tpl->set('jsvarurl', false);
267268 }
268 - if( $wgUser->getNewtalk() ) {
 269+ $newtalks = $wgUser->getNewMessageLinks();
 270+
 271+ if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) {
269272 $usertitle = $this->mUser->getUserPage();
270273 $usertalktitle = $usertitle->getTalkPage();
271274 if( !$usertalktitle->equals( $this->mTitle ) ) {
@@ -277,6 +280,16 @@
278281 # Disable Cache
279282 $wgOut->setSquidMaxage(0);
280283 }
 284+ } else if (count($newtalks)) {
 285+ $sep = wfMsgHtml("newtalkseperator");
 286+ $msgs = array();
 287+ foreach ($newtalks as $newtalk) {
 288+ $msgs[] = wfElement("a",
 289+ array('href' => $newtalk["link"]), $newtalk["wiki"]);
 290+ }
 291+ $parts = implode($sep, $msgs);
 292+ $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
 293+ $wgOut->setSquidMaxage(0);
281294 } else {
282295 $ntl = '';
283296 }
Index: branches/REL1_5/phase3/languages/Language.php
@@ -2127,6 +2127,8 @@
21282128
21292129 'unit-pixel' => 'px',
21302130
 2131+'youhavenewmessagesmulti' => "You have new messages on $1",
 2132+'newtalkseperator' => ', ',
21312133 );
21322134
21332135 /* a fake language converter */

Status & tagging log