Index: trunk/extensions/LiquidThreads/classes/LqtView.php |
— | — | @@ -48,6 +48,7 @@ |
49 | 49 | |
50 | 50 | function initializeQueries() { |
51 | 51 | |
| 52 | + // Determine sort order |
52 | 53 | if ( $this->methodApplies( 'talkpage_sort_order' ) ) { |
53 | 54 | // Sort order is explicitly specified through UI |
54 | 55 | global $wgRequest; |
— | — | @@ -71,8 +72,12 @@ |
72 | 73 | $this->sort_order = $user_order; |
73 | 74 | } |
74 | 75 | } |
| 76 | + |
| 77 | + // Create query group |
75 | 78 | global $wgOut, $wgLqtThreadArchiveStartDays, $wgLqtThreadArchiveInactiveDays; |
| 79 | + $dbr = wfGetDB( DB_SLAVE ); |
76 | 80 | $g = new QueryGroup(); |
| 81 | + |
77 | 82 | $startdate = Date::now()->nDaysAgo( $wgLqtThreadArchiveStartDays )->midnight(); |
78 | 83 | $recentstartdate = $startdate->nDaysAgo( $wgLqtThreadArchiveInactiveDays ); |
79 | 84 | $article_clause = Threads::articleClause( $this->article ); |
— | — | @@ -83,6 +88,8 @@ |
84 | 89 | } elseif ( $this->sort_order == LQT_OLDEST_THREADS ) { |
85 | 90 | $sort_clause = 'ORDER BY thread.thread_created ASC'; |
86 | 91 | } |
| 92 | + |
| 93 | + // Add standard queries |
87 | 94 | $g->addQuery( 'fresh', |
88 | 95 | array( $article_clause, |
89 | 96 | 'thread.thread_parent is null', |
— | — | @@ -90,6 +97,11 @@ |
91 | 98 | ' OR (thread.thread_summary_page is NULL' . |
92 | 99 | ' AND thread.thread_type=' . Threads::TYPE_NORMAL . '))' ), |
93 | 100 | array( $sort_clause ) ); |
| 101 | + |
| 102 | + $g->extendQuery( 'fresh', 'fresh-undeleted', |
| 103 | + array( 'thread_type != '. $dbr->addQuotes( Threads::TYPE_DELETED ) ) ); |
| 104 | + |
| 105 | + |
94 | 106 | $g->addQuery( 'archived', |
95 | 107 | array( $article_clause, |
96 | 108 | 'thread.thread_parent is null', |
— | — | @@ -97,12 +109,18 @@ |
98 | 110 | ' OR thread.thread_type=' . Threads::TYPE_NORMAL . ')', |
99 | 111 | 'thread.thread_modified < ' . $startdate->text() ), |
100 | 112 | array( $sort_clause ) ); |
| 113 | + |
101 | 114 | $g->extendQuery( 'archived', 'recently-archived', |
102 | 115 | array( '( thread.thread_modified >=' . $recentstartdate->text() . |
103 | 116 | ' OR rev_timestamp >= ' . $recentstartdate->text() . ')', |
104 | 117 | 'summary_page.page_id = thread.thread_summary_page', 'summary_page.page_latest = rev_id' ), |
105 | 118 | array(), |
106 | 119 | array( 'page summary_page', 'revision' ) ); |
| 120 | + |
| 121 | + $g->addQuery( 'archived', 'archived-undeleted', |
| 122 | + array( 'thread_type != '. $dbr->addQuotes( Threads::TYPE_DELETED ) ) ); |
| 123 | + |
| 124 | + |
107 | 125 | return $g; |
108 | 126 | } |
109 | 127 | |
— | — | @@ -454,6 +472,16 @@ |
455 | 473 | 'href' => $this->permalinkUrlWithQuery( $thread, 'action=unwatch' ), |
456 | 474 | 'enabled' => true ); |
457 | 475 | } |
| 476 | + |
| 477 | + if ( $this->user->isAllowed( 'delete' ) ) { |
| 478 | + $delete_title = SpecialPage::getTitleFor( 'DeleteThread', |
| 479 | + $thread->title()->getPrefixedText() ); |
| 480 | + $delete_href = $delete_title->getFullURL(); |
| 481 | + |
| 482 | + $commands[] = array( 'label' => wfMsg( 'delete' ), |
| 483 | + 'href' => $delete_href, |
| 484 | + 'enabled' => true ); |
| 485 | + } |
458 | 486 | |
459 | 487 | return $commands; |
460 | 488 | } |
— | — | @@ -658,6 +686,7 @@ |
659 | 687 | function showThread( $thread ) { |
660 | 688 | global $wgLang; # TODO global. |
661 | 689 | |
| 690 | + // Safeguard |
662 | 691 | if ( $thread->type() == Threads::TYPE_DELETED |
663 | 692 | && ! $this->request->getBool( 'lqt_show_deleted_threads' ) ) |
664 | 693 | return; |
Index: trunk/extensions/LiquidThreads/classes/LqtThread.php |
— | — | @@ -245,28 +245,43 @@ |
246 | 246 | |
247 | 247 | function __construct( $line, $children ) { |
248 | 248 | /* SCHEMA changes must be reflected here. */ |
| 249 | + |
| 250 | + $dataLoads = array( |
| 251 | + 'thread_id' => 'id', |
| 252 | + 'thread_root' => 'rootId', |
| 253 | + 'thread_article_namespace' => 'articleNamespace', |
| 254 | + 'thread_article_title' => 'articleTitle', |
| 255 | + 'thread_summary_page' => 'summaryId', |
| 256 | + 'thread_ancestor' => 'ancestorId', |
| 257 | + 'thread_parent' => 'parentId', |
| 258 | + 'thread_modified' => 'modified', |
| 259 | + 'thread_created' => 'created', |
| 260 | + 'thread_revision' => 'revisionNumber', |
| 261 | + 'thread_type' => 'type', |
| 262 | + 'thread_change_type' => 'changeType', |
| 263 | + 'thread_change_object' => 'changeObject', |
| 264 | + 'thread_change_comment' => 'changeComment', |
| 265 | + 'thread_change_user' => 'changeUser', |
| 266 | + 'thread_change_user_text' => 'changeUserText', |
| 267 | + 'thread_editedness' => 'editedness' |
| 268 | + ); |
| 269 | + |
249 | 270 | |
250 | | - $this->id = $line->thread_id; |
251 | | - $this->rootId = $line->thread_root; |
252 | | - $this->articleNamespace = $line->thread_article_namespace; |
253 | | - $this->articleTitle = $line->thread_article_title; |
254 | | - $this->summaryId = $line->thread_summary_page; |
255 | | - $this->ancestorId = $line->thread_ancestor; |
256 | | - $this->parentId = $line->thread_parent; |
257 | | - $this->modified = $line->thread_modified; |
258 | | - $this->created = $line->thread_created; |
259 | | - $this->revisionNumber = $line->thread_revision; |
260 | | - $this->type = $line->thread_type; |
261 | | - $this->changeType = $line->thread_change_type; |
262 | | - $this->changeObject = $line->thread_change_object; |
263 | | - $this->changeComment = $line->thread_change_comment; |
264 | | - $this->changeUser = $line->thread_change_user; |
265 | | - $this->changeUserText = $line->thread_change_user_text; |
266 | | - $this->editedness = $line->thread_editedness; |
| 271 | + foreach( $dataLoads as $db_field => $member_field ) { |
| 272 | + if ( isset($line->$db_field) ) { |
| 273 | + $this->$member_field = $line->$db_field; |
| 274 | + } |
| 275 | + } |
| 276 | + |
| 277 | + if ( isset($line->page_namespace) && isset($line->page_title) ) { |
| 278 | + $root_title = Title::makeTitle( $line->page_namespace, $line->page_title ); |
| 279 | + $this->root = new Post( $root_title ); |
| 280 | + $this->root->loadPageData( $line ); |
| 281 | + } else { |
| 282 | + $root_title = Title::newFromID( $this->rootId ); |
| 283 | + $this->root = new Post( $root_title ); |
| 284 | + } |
267 | 285 | |
268 | | - $root_title = Title::makeTitle( $line->page_namespace, $line->page_title ); |
269 | | - $this->root = new Post( $root_title ); |
270 | | - $this->root->loadPageData( $line ); |
271 | 286 | $this->rootRevision = $this->root->mLatest; |
272 | 287 | } |
273 | 288 | |
— | — | @@ -359,6 +374,7 @@ |
360 | 375 | |
361 | 376 | function article() { |
362 | 377 | if ( $this->article ) return $this->article; |
| 378 | + |
363 | 379 | $title = Title::newFromID( $this->articleId ); |
364 | 380 | if ( $title ) { |
365 | 381 | $a = new Article( $title ); |
Index: trunk/extensions/LiquidThreads/pages/SpecialDeleteThread.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die; |
5 | 5 | |
6 | | -class SpecialDeleteThread extends UnlistedSpecialPage { |
| 6 | +class SpecialDeleteThread extends SpecialPage { |
7 | 7 | private $user, $output, $request, $title, $thread; |
8 | 8 | |
9 | 9 | function __construct() { |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | } |
60 | 60 | |
61 | 61 | function checkUserRights() { |
62 | | - if ( in_array( 'delete', $this->user->getRights() ) ) { |
| 62 | + if ( $this->user->isAllowed( 'delete' ) ) { |
63 | 63 | return true; |
64 | 64 | } else { |
65 | 65 | wfLoadExtensionMessages( 'LiquidThreads' ); |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -196,9 +196,12 @@ |
197 | 197 | $url = $this->talkpageUrl( $this->title, 'talkpage_new_thread' ); |
198 | 198 | $this->output->addHTML( "<strong><a class=\"lqt_start_discussion\" href=\"$url\">" . wfMsg( 'lqt_new_thread' ) . "</a></strong>" ); |
199 | 199 | } |
| 200 | + |
| 201 | + $queryType = |
| 202 | + $wgRequest->getBool( 'lqt_show_deleted_threads' ) |
| 203 | + ? 'fresh' : 'fresh-undeleted'; |
| 204 | + $threads = $this->queries->query( $queryType ); |
200 | 205 | |
201 | | - $threads = $this->queries->query( 'fresh' ); |
202 | | - |
203 | 206 | $this->openDiv( 'lqt_toc_archive_wrapper' ); |
204 | 207 | |
205 | 208 | $this->openDiv( 'lqt_archive_teaser_empty' ); |