r42455 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42454‎ | r42455 | r42456 >
Date:07:07, 24 October 2008
Author:david
Status:old
Tags:
Comment:
Handle no-new-messages sensibly. Fixes 16041.
Modified paths:
  • /trunk/extensions/LiquidThreads/Lqt.i18n.php (modified) (history)
  • /trunk/extensions/LiquidThreads/LqtPages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/Lqt.i18n.php
@@ -128,6 +128,7 @@
129129 'lqt-email-undo' => 'Undo',
130130 'lqt-messages-sent' => 'Messages sent to you:',
131131 'lqt-other-messages' => 'Messages on other talk pages:',
 132+ 'lqt-no-new-messages' => 'There are no new messages for you.',
132133 'lqt-new-messages' => 'There are new messages for you.',
133134 'lqt-email-info-undo' => 'Bring back the thread you just dismissed.',
134135 'lqt-date-info' => 'This link is disabled because you are viewing threads from all dates.',
Index: trunk/extensions/LiquidThreads/LqtPages.php
@@ -1154,6 +1154,8 @@
11551155 function showUndo($ids) {
11561156 if( count($ids) == 1 ) {
11571157 $t = Threads::withId($ids[0]);
 1158+ if( !$t )
 1159+ return; // empty or just bogus operand.
11581160 $msg = wfMsg( 'lqt-marked-read',$t->subject() );
11591161 } else {
11601162 $count = count($ids);
@@ -1195,17 +1197,19 @@
11961198 $ids = explode(',', $this->request->getVal('lqt_operand', ''));
11971199 if( $ids !== false ) {
11981200 foreach($ids as $id) {
1199 - NewMessages::markThreadAsUnreadByUser(Threads::withId($id), $this->user);
 1201+ $tmp_thread = Threads::withId($id); if($tmp_thread)
 1202+ NewMessages::markThreadAsReadByUser($tmp_thread, $this->user);
12001203 }
12011204 $this->output->redirect( $this->title->getFullURL() );
12021205 }
12031206 }
12041207
12051208 else if( $this->request->wasPosted() && $this->methodApplies('mark_as_read') ) {
1206 - $ids = explode(',', $this->request->getVal('lqt_operand', ''));
 1209+ $ids = explode(',', $this->request->getVal('lqt_operand'));
12071210 if( $ids !== false ) {
12081211 foreach($ids as $id) {
1209 - NewMessages::markThreadAsReadByUser(Threads::withId($id), $this->user);
 1212+ $tmp_thread = Threads::withId($id); if($tmp_thread)
 1213+ NewMessages::markThreadAsReadByUser($tmp_thread, $this->user);
12101214 }
12111215 $query = 'lqt_method=undo_mark_as_read&lqt_operand=' . implode(',', $ids);
12121216 $this->output->redirect( $this->title->getFullURL($query) );
@@ -1280,15 +1284,20 @@
12811285 $this->setHeaders();
12821286
12831287 $view = new NewUserMessagesView( $this->output, new Article($this->title),
1284 - $this->title, $this->user, $this->request );
 1288+ $this->title, $this->user, $this->request );
12851289
 1290+ $view->showOnce(); // handles POST etc.
 1291+
12861292 $first_set = NewMessages::newUserMessages($this->user);
12871293 $second_set = NewMessages::watchedThreadsForUser($this->user);
12881294 $both_sets = array_merge($first_set, $second_set);
 1295+ if( count($both_sets) == 0 ) {
 1296+ $wgOut->addWikitext( wfMsg('lqt-no-new-messages') );
 1297+ return;
 1298+ }
12891299 $view->showReadAllButton($both_sets); // ugly hack.
12901300
12911301 $view->setHeaderLevel(3);
1292 - $view->showOnce(); // handles POST etc.
12931302
12941303 $this->output->addHTML('<h2 class="lqt_newmessages_section">'.wfMsg ( 'lqt-messages-sent' ).'</h2>');
12951304 $view->setThreads( $first_set );

Status & tagging log