r13012 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13011‎ | r13012 | r13013 >
Date:21:10, 14 February 2006
Author:kateturner
Status:old
Tags:
Comment:
hooks for shared new talk notifications
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/languages/Messages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -811,6 +811,23 @@
812812 }
813813
814814 /**
 815+ * Return the talk page(s) this user has new messages on.
 816+ */
 817+ function getTalkPages() {
 818+ global $wgDBname;
 819+ $talks = array();
 820+ if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
 821+ return $talks;
 822+
 823+ if (!$this->getNewtalk())
 824+ return array();
 825+ $up = $this->getUserPage();
 826+ $utp = $up->getTalkPage();
 827+ return array(array("wiki" => $wgDBname, "link" => $utp->getLocalURL()));
 828+ }
 829+
 830+
 831+ /**
815832 * Perform a user_newtalk check on current slaves; if the memcached data
816833 * is funky we don't want newtalk state to get stuck on save, as that's
817834 * damn annoying.
@@ -1224,8 +1241,11 @@
12251242 function clearNotification( &$title ) {
12261243 global $wgUser, $wgUseEnotif;
12271244
 1245+
12281246 if ($title->getNamespace() == NS_USER_TALK &&
12291247 $title->getText() == $this->getName() ) {
 1248+ if (!wfRunHooks('UserClearNewTalkNotification', array(&$this)))
 1249+ return;
12301250 $this->setNewtalk( false );
12311251 }
12321252
Index: trunk/phase3/includes/Article.php
@@ -2214,15 +2214,17 @@
22152215 # If this is another user's talk page, update newtalk
22162216
22172217 if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getName()) {
2218 - $other = User::newFromName( $shortTitle );
2219 - if( is_null( $other ) && User::isIP( $shortTitle ) ) {
2220 - // An anonymous user
2221 - $other = new User();
2222 - $other->setName( $shortTitle );
 2218+ if (wfRunHooks('ArticleEditUpdateNewTalk', array(&$this)) ) {
 2219+ $other = User::newFromName( $shortTitle );
 2220+ if( is_null( $other ) && User::isIP( $shortTitle ) ) {
 2221+ // An anonymous user
 2222+ $other = new User();
 2223+ $other->setName( $shortTitle );
 2224+ }
 2225+ if( $other ) {
 2226+ $other->setNewtalk( true );
 2227+ }
22232228 }
2224 - if( $other ) {
2225 - $other->setNewtalk( true );
2226 - }
22272229 }
22282230
22292231 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
Index: trunk/phase3/includes/SkinTemplate.php
@@ -147,6 +147,7 @@
148148 global $wgMaxCredits, $wgShowCreditsIfMax;
149149 global $wgPageShowWatchingUsers;
150150 global $wgUseTrackbacks;
 151+ global $wgDBname;
151152
152153 $fname = 'SkinTemplate::outputPage';
153154 wfProfileIn( $fname );
@@ -269,7 +270,9 @@
270271 } else {
271272 $tpl->set('jsvarurl', false);
272273 }
273 - if( $wgUser->getNewtalk() ) {
 274+ $newtalks = $wgUser->getTalkPages();
 275+
 276+ if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) {
274277 $usertitle = $this->mUser->getUserPage();
275278 $usertalktitle = $usertitle->getTalkPage();
276279 if( !$usertalktitle->equals( $this->mTitle ) ) {
@@ -287,6 +290,16 @@
288291 # Disable Cache
289292 $wgOut->setSquidMaxage(0);
290293 }
 294+ } else if (count($newtalks)) {
 295+ $sep = wfMsg("newtalkseperator");
 296+ $msgs = array();
 297+ foreach ($newtalks as $newtalk) {
 298+ $msgs[] = wfElement("a",
 299+ array('href' => $newtalk["link"]), $newtalk["wiki"]);
 300+ }
 301+ $parts = implode($sep, $msgs);
 302+ $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
 303+ $wgOut->setSquidMaxage(0);
291304 } else {
292305 $ntl = '';
293306 }
Index: trunk/phase3/languages/Messages.php
@@ -1932,6 +1932,8 @@
19331933 'confirm_purge' => "Clear the cache of this page?\n\n$1",
19341934 'confirm_purge_button' => 'OK',
19351935
 1936+'youhavenewmessagesmulti' => "You have new messages on $1",
 1937+'newtalkseperator' => ', ',
19361938 );
19371939
19381940

Status & tagging log