r25846 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25845‎ | r25846 | r25847 >
Date:06:09, 14 September 2007
Author:david
Status:old
Tags:
Comment:
User talkpage messages that seem to work.
Modified paths:
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtPages.php (modified) (history)
  • /branches/liquidthreads/maintenance/lqt.sql (modified) (history)

Diff [purge]

Index: branches/liquidthreads/maintenance/lqt.sql
@@ -39,3 +39,12 @@
4040 hthread_change_object int(8) unsigned NULL,
4141 PRIMARY KEY hthread_id_revision (hthread_id, hthread_revision)
4242 ) TYPE=InnoDB;
 43+
 44+CREATE TABLE /*$wgDBprefix*/user_message_state (
 45+ ums_user int unsigned NOT NULL,
 46+ ums_thread int(8) unsigned NOT NULL,
 47+ ums_read_timestamp varbinary(14),
 48+
 49+ PRIMARY KEY (ums_user, ums_thread)
 50+
 51+) TYPE=InnoDB;
Index: branches/liquidthreads/extensions/LqtPages.php
@@ -910,7 +910,9 @@
911911 <table ><tr>
912912 <td style="padding-right: 1em; vertical-align: top; padding-top: 1em;" >
913913 <form method="POST">
914 - <input type="submit" value="Read" title="Remove this thread from New Messages." />
 914+ <input type="hidden" name="lqt_method" value="mark_as_read" />
 915+ <input type="hidden" name="lqt_operand" value="{$t->id()}" />
 916+ <input type="submit" value="Read" name="lqt_read_button" title="Remove this thread from New Messages." />
915917 </form>
916918 </td>
917919 <td>
@@ -925,10 +927,6 @@
926928 HTML
927929 );
928930 }
929 -
930 - private function showClearButtonForThread($thread) {
931 - $this->output->addHTML('<input type="submit">');
932 - }
933931
934932 function postDivClass($thread) {
935933
@@ -936,9 +934,16 @@
937935
938936 function show() {
939937 $this->addJSandCSS();
940 -
 938+
941939 $threads = NewMessages::newUserMessages($this->user);
942940 foreach($threads as $t) {
 941+
 942+ if( $this->request->wasPosted() && $this->methodAppliesToThread('mark_as_read', $t) ) {
 943+ NewMessages::markThreadAsReadByUser($t, $this->user);
 944+ continue;
 945+ }
 946+
 947+ // Call for POST as well as GET so that edit, reply, etc. will work.
943948 $this->preShowThread($t);
944949 $this->showThread($t);
945950 $this->postShowThread($t);
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -825,7 +825,7 @@
826826 return $newthread;
827827 }
828828
829 - static function where( $where, $options = array(), $extra_tables = array() ) {
 829+ static function where( $where, $options = array(), $extra_tables = array(), $joins = "" ) {
830830 $dbr = wfGetDB( DB_SLAVE );
831831 if ( is_array($where) ) $where = $dbr->makeList( $where, LIST_AND );
832832 if ( is_array($options) ) $options = implode(',', $options);
@@ -837,7 +837,7 @@
838838 } else {
839839 $tables = "";
840840 }
841 -
 841+
842842 /* Select the client's threads, AND all their children.
843843 The ones the client actually asked for are marked with root_test.
844844 In theory we could also grab the page and revision data, to avoid having
@@ -848,7 +848,7 @@
849849 $root_test = str_replace( 'thread.', 'children.', $where ); // TODO fragile?
850850
851851 $sql = <<< SQL
852 -SELECT children.*, child_page.*, ($root_test) as is_root FROM $tables thread, thread children, page child_page
 852+SELECT children.*, child_page.*, ($root_test) as is_root FROM $tables thread, thread children, page child_page $joins
853853 WHERE $where
854854 AND children.thread_path LIKE CONCAT(thread.thread_path, "%")
855855 AND child_page.page_id = children.thread_root
@@ -989,22 +989,20 @@
990990
991991 class NewMessages {
992992
 993+ static function markThreadAsReadByUser($thread, $user) {
 994+ $dbr =& wfGetDB( DB_MASTER );
 995+ $res = $dbr->insert('user_message_state',
 996+ array( 'ums_user' => $user->getID(),
 997+ 'ums_thread' => $thread->id(),
 998+ 'ums_read_timestamp' => wfTimestampNow() ),
 999+ __METHOD__);
 1000+ }
 1001+
9931002 static function newUserMessages($user) {
994 -/* $article_clause = Threads::articleClause(new Article($user->getUserPage()))
995 - $sql = <<< SQL
996 - select * from thread, page, recentchanges
997 - where thread_root = rc_cur_id
998 - and $article_clause
999 -SQL;
1000 - $dbr = wfGetDB( DB_SLAVE );
1001 - res = $dbr->query($sql);
1002 - while ( $line = $dbr->fetchObject($res) ) {
1003 -
1004 - }*/
1005 -
1006 - $ts = Threads::where( array('thread.thread_root = rc_cur_id',
 1003+
 1004+ $ts = Threads::where( array('ums_read_timestamp is null',
10071005 Threads::articleClause(new Article($user->getUserPage()))),
1008 - array(), array('recentchanges') );
 1006+ array(), array(), 'left outer join user_message_state on ums_user is null or (ums_user = 2 and ums_thread = thread.thread_id)' );
10091007 return $ts;
10101008 }
10111009

Status & tagging log