Index: branches/liquidthreads/maintenance/lqt.sql |
— | — | @@ -17,6 +17,9 @@ |
18 | 18 | |
19 | 19 | thread_change_type int(4) unsigned NOT NULL, |
20 | 20 | thread_change_object int(8) unsigned NULL, |
| 21 | + thread_change_comment tinyblob NOT NULL, |
| 22 | + thread_change_user int unsigned NOT NULL default '0', |
| 23 | + thread_change_user_text varchar(255) binary NOT NULL default '', |
21 | 24 | |
22 | 25 | PRIMARY KEY thread_id (thread_id), |
23 | 26 | UNIQUE INDEX thread_id (thread_id), |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -284,8 +284,8 @@ |
285 | 285 | } |
286 | 286 | |
287 | 287 | $e = new EditPage($article); |
| 288 | + |
288 | 289 | $e->suppressIntro = true; |
289 | | - |
290 | 290 | $e->editFormTextBeforeContent .= |
291 | 291 | $this->perpetuate('lqt_method', 'hidden') . |
292 | 292 | $this->perpetuate('lqt_operand', 'hidden'); |
— | — | @@ -316,28 +316,28 @@ |
317 | 317 | // For replies and new posts, insert the associated thread object into the DB. |
318 | 318 | if ($edit_type != 'editExisting' && $edit_type != 'summarize' && $e->didSave) { |
319 | 319 | if ( $edit_type == 'reply' ) { |
320 | | - $thread = Threads::newThread( $article, $this->article, $edit_applies_to ); |
321 | | - $edit_applies_to->commitRevision(Threads::CHANGE_REPLY_CREATED, $thread); |
| 320 | + $thread = Threads::newThread( $article, $this->article, $edit_applies_to, $e->summary ); |
| 321 | + $edit_applies_to->commitRevision(Threads::CHANGE_REPLY_CREATED, $thread, $e->summary); |
322 | 322 | } else { |
323 | | - $thread = Threads::newThread( $article, $this->article ); |
| 323 | + $thread = Threads::newThread( $article, $this->article, $e->summary ); |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | 327 | if ($edit_type == 'summarize' && $e->didSave) { |
328 | 328 | $edit_applies_to->setSummary( $article ); |
329 | | - $edit_applies_to->commitRevision(Threads::CHANGE_EDITED_SUMMARY, $edit_applies_to); |
| 329 | + $edit_applies_to->commitRevision(Threads::CHANGE_EDITED_SUMMARY, $edit_applies_to, $e->summary); |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Move the thread and replies if subject changed. |
333 | 333 | if( $edit_type == 'editExisting' && $e->didSave ) { |
334 | 334 | $subject = $this->request->getVal('lqt_subject_field', ''); |
335 | 335 | if ( $subject && $subject != $thread->subjectWithoutIncrement() ) { |
336 | | - $reason = $this->request->getVal("wpSummary", ""); |
337 | | - $this->renameThread($thread, $subject, $reason); |
| 336 | +// $reason = $this->request->getVal("wpSummary", ""); |
| 337 | + $this->renameThread($thread, $subject, $e->summary); |
338 | 338 | } |
339 | 339 | // this is unrelated to the subject change and is for all edits: |
340 | 340 | $thread->setRootRevision( Revision::newFromTitle($thread->root()->getTitle()) ); |
341 | | - $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread ); |
| 341 | + $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $e->summary ); |
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
— | — | @@ -991,16 +991,27 @@ |
992 | 992 | * @return string HTML output for the row |
993 | 993 | */ |
994 | 994 | function historyLine( $row, $next, $counter = '', $notificationtimestamp = false, $latest = false, $firstInList = false ) { |
| 995 | + global $wgLang, $wgOut; // TODO global. |
| 996 | + |
| 997 | + $hthread = HistoricalThread::fromTextRepresentation($row->hthread_contents); |
| 998 | + |
995 | 999 | /* TODO: best not to refer to LqtView class directly. */ |
996 | 1000 | /* We don't use oldid because that has side-effects. */ |
997 | 1001 | $result = array(); |
998 | | - $change_names = array(Threads::CHANGE_EDITED_ROOT => "Comment text edited", |
999 | | - Threads::CHANGE_EDITED_SUMMARY => "Summary changed", |
1000 | | - Threads::CHANGE_REPLY_CREATED => "New reply created", |
1001 | | - Threads::CHANGE_NEW_THREAD => "New thread created"); |
| 1002 | + $change_names = array(Threads::CHANGE_EDITED_ROOT => "Comment text edited:", |
| 1003 | + Threads::CHANGE_EDITED_SUMMARY => "Summary changed:", |
| 1004 | + Threads::CHANGE_REPLY_CREATED => "New reply created:", |
| 1005 | + Threads::CHANGE_NEW_THREAD => "New thread created:"); |
1002 | 1006 | $url = LqtView::permalinkUrlWithQuery( $this->thread, 'lqt_oldid=' . $row->hthread_revision ); |
1003 | | - $result[] = "<tr><td><a href=\"$url\">" . $row->hthread_revision . '</a></td>'; |
1004 | | - $result[] = "<td>Revision type: {$change_names[$row->hthread_change_type]}.</td></tr>"; |
| 1007 | + |
| 1008 | + $p = new Parser(); $sig = $wgOut->parse( $p->getUserSig( $hthread->changeUser() ), false ); |
| 1009 | + |
| 1010 | + $result[] = "<tr>"; |
| 1011 | + $result[] = "<td><a href=\"$url\">" . $wgLang->timeanddate($this->thread->timestamp()) . "</a></td>"; |
| 1012 | + $result[] = "<td>" . $sig . "</td>"; |
| 1013 | + $result[] = "<td>{$change_names[$row->hthread_change_type]}</td>"; |
| 1014 | + $result[] = "<td>" . $hthread->changeComment() . "</td>"; |
| 1015 | + $result[] = "</tr>"; |
1005 | 1016 | return implode('', $result); |
1006 | 1017 | } |
1007 | 1018 | function getNotificationTimestamp() { |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -100,6 +100,7 @@ |
101 | 101 | |
102 | 102 | class HistoricalThread extends Thread { |
103 | 103 | function __construct($t) { |
| 104 | + /* SCHEMA changes must be reflected here. */ |
104 | 105 | $this->rootId = $t->rootId; |
105 | 106 | $this->rootRevision = $t->rootRevision; |
106 | 107 | $this->articleId = $t->articleId; |
— | — | @@ -112,6 +113,9 @@ |
113 | 114 | $this->revisionNumber = $t->revisionNumber; |
114 | 115 | $this->changeType = $t->changeType; |
115 | 116 | $this->changeObject = $t->changeObject; |
| 117 | + $this->changeComment = $t->changeComment; |
| 118 | + $this->changeUser = $t->changeUser; |
| 119 | + $this->changeUserText = $t->changeUserText; |
116 | 120 | |
117 | 121 | $this->replies = array(); |
118 | 122 | foreach ($t->replies as $r) { |
— | — | @@ -154,6 +158,8 @@ |
155 | 159 | } |
156 | 160 | |
157 | 161 | class Thread { |
| 162 | + /* SCHEMA changes must be reflected here. */ |
| 163 | + |
158 | 164 | /* ID references to other objects that are loaded on demand: */ |
159 | 165 | protected $rootId; |
160 | 166 | protected $articleId; |
— | — | @@ -180,6 +186,9 @@ |
181 | 187 | |
182 | 188 | protected $changeType; |
183 | 189 | protected $changeObject; |
| 190 | + protected $changeComment; |
| 191 | + protected $changeUser; |
| 192 | + protected $changeUserText; |
184 | 193 | |
185 | 194 | /* Only used by $double to be saved into a historical thread. */ |
186 | 195 | protected $rootRevision; |
— | — | @@ -232,14 +241,20 @@ |
233 | 242 | __METHOD__); |
234 | 243 | } |
235 | 244 | |
236 | | - function commitRevision($change_type, $change_object = null) { |
| 245 | + function commitRevision($change_type, $change_object = null, $reason = "") { |
237 | 246 | global $wgUser; // TODO global. |
238 | 247 | |
| 248 | + $this->changeComment = $reason; |
| 249 | + $this->changeUser = $wgUser->getID(); |
| 250 | + $this->changeUserText = $wgUser->getName(); |
| 251 | + |
239 | 252 | // TODO open a transaction. |
240 | 253 | HistoricalThread::create( $this->double ); |
241 | 254 | |
242 | 255 | $this->bumpRevisionsOnAncestors($change_type, $change_object); |
243 | 256 | |
| 257 | + /* SCHEMA changes must be reflected here. */ |
| 258 | + |
244 | 259 | $dbr =& wfGetDB( DB_MASTER ); |
245 | 260 | $res = $dbr->update( 'thread', |
246 | 261 | /* SET */array( 'thread_root' => $this->rootId, |
— | — | @@ -251,7 +266,11 @@ |
252 | 267 | 'thread_article_namespace' => $this->articleNamespace, |
253 | 268 | 'thread_article_title' => $this->articleTitle, |
254 | 269 | 'thread_change_type' => $this->changeType, |
255 | | - 'thread_change_object' => $this->changeObject), |
| 270 | + 'thread_change_object' => $this->changeObject, |
| 271 | + 'thread_change_comment' => $this->changeComment, |
| 272 | + 'thread_change_user' => $this->changeUser, |
| 273 | + 'thread_change_user_text' => $this->changeUserText, |
| 274 | + ), |
256 | 275 | /* WHERE */ array( 'thread_id' => $this->id, ), |
257 | 276 | __METHOD__); |
258 | 277 | |
— | — | @@ -337,6 +356,8 @@ |
338 | 357 | |
339 | 358 | |
340 | 359 | function __construct($line, $children) { |
| 360 | + /* SCHEMA changes must be reflected here. */ |
| 361 | + |
341 | 362 | $this->id = $line->thread_id; |
342 | 363 | $this->rootId = $line->thread_root; |
343 | 364 | $this->articleId = $line->thread_article; |
— | — | @@ -349,6 +370,9 @@ |
350 | 371 | $this->type = $line->thread_type; |
351 | 372 | $this->changeType = $line->thread_change_type; |
352 | 373 | $this->changeObject = $line->thread_change_object; |
| 374 | + $this->changeComment = $line->thread_change_comment; |
| 375 | + $this->changeUser = $line->thread_change_user; |
| 376 | + $this->changeUserText = $line->thread_change_user_text; |
353 | 377 | |
354 | 378 | $this->replies = $children; |
355 | 379 | |
— | — | @@ -567,6 +591,18 @@ |
568 | 592 | $this->changeObject = $o->id(); |
569 | 593 | } |
570 | 594 | } |
| 595 | + |
| 596 | + function changeUser() { |
| 597 | + if( $this->changeUser == 0 ) { |
| 598 | + return User::newFromName($this->changeUserText); |
| 599 | + } else { |
| 600 | + return User::newFromId($this->changeUser); |
| 601 | + } |
| 602 | + } |
| 603 | + |
| 604 | + function changeComment() { |
| 605 | + return $this->changeComment; |
| 606 | + } |
571 | 607 | } |
572 | 608 | |
573 | 609 | |