Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php |
— | — | @@ -187,6 +187,11 @@ |
188 | 188 | 'lqt-split-submit' => 'Split', |
189 | 189 | 'lqt_split_badsubject' => 'The subject you entered is invalid.', |
190 | 190 | 'lqt-no-threads' => 'There are no threads on this page yet.', |
| 191 | + 'lqt-delete-parent-warning'=> 'This is a top-level thread with replies. |
| 192 | +Its replies will also be deleted automatically. |
| 193 | +To avoid this, split them from this thread before deleting it.', |
| 194 | + 'lqt-delete-parent-deleted'=> 'Parent thread deleted ($1)', |
| 195 | + 'lqt-delete-replies-done' => 'All replies to this thread have also been deleted.', |
191 | 196 | |
192 | 197 | // Rights |
193 | 198 | 'right-lqt-split' => 'Split threads', |
Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $wgHooks['ArticleDeleteComplete'][] = 'LqtDeletionController::onArticleDeleteComplete'; |
74 | 74 | $wgHooks['ArticleRevisionUndeleted'][] = 'LqtDeletionController::onArticleRevisionUndeleted'; |
75 | 75 | $wgHooks['ArticleUndelete'][] = 'LqtDeletionController::onArticleUndelete'; |
76 | | -$wgHooks['ArticleDelete'][] = 'LqtDeletionController::onArticleDelete'; |
| 76 | +$wgHooks['ArticleConfirmDelete'][] = 'LqtDeletionController::onArticleConfirmDelete'; |
77 | 77 | |
78 | 78 | // Search |
79 | 79 | $wgHooks['ShowSearchHitTitle'][] = 'LqtHooks::customiseSearchResultTitle'; |
Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -584,16 +584,6 @@ |
585 | 585 | 'enabled' => true ); |
586 | 586 | } |
587 | 587 | |
588 | | - if ( $this->user->isAllowed( 'delete' ) ) { |
589 | | - $delete_title = SpecialPage::getTitleFor( 'DeleteThread', |
590 | | - $thread->title()->getPrefixedText() ); |
591 | | - $delete_href = $delete_title->getFullURL(); |
592 | | - |
593 | | - $commands['delete'] = array( 'label' => wfMsg( 'delete' ), |
594 | | - 'href' => $delete_href, |
595 | | - 'enabled' => true ); |
596 | | - } |
597 | | - |
598 | 588 | $summarizeUrl = self::permalinkUrl( $thread, 'summarize', $thread->id() ); |
599 | 589 | $commands['summarize'] = array( |
600 | 590 | 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ), |
Index: trunk/extensions/LiquidThreads/classes/DeletionController.php |
— | — | @@ -23,25 +23,24 @@ |
24 | 24 | $thread->delete($reason); |
25 | 25 | |
26 | 26 | // Avoid orphaning subthreads, update their parentage. |
27 | | - foreach( $thread->replies() as $reply ) { |
28 | | - $reply->setSuperthread( $thread->superthread() ); |
29 | | - $reply->save( ); |
| 27 | + wfLoadExtensionMessages( 'LiquidThreads' ); |
| 28 | + if ( $thread->replies() && $thread->isTopmostThread() ) { |
| 29 | + $reason = wfMsg('lqt-delete-parent-deleted', $reason ); |
| 30 | + foreach( $thread->replies() as $reply ) { |
| 31 | + $reply->root()->doDeleteArticle( $reason, false, $reply->root()->getId() ); |
| 32 | + } |
| 33 | + global $wgOut; |
| 34 | + $wgOut->addWikiMsg( 'lqt-delete-replies-done' ); |
| 35 | + } elseif ( $thread->replies() ) { |
| 36 | + foreach( $thread->replies() as $reply ) { |
| 37 | + $reply->setSuperthread( $thread->superthread() ); |
| 38 | + $reply->save( ); |
| 39 | + } |
30 | 40 | } |
31 | 41 | |
32 | 42 | return true; |
33 | 43 | } |
34 | 44 | |
35 | | - static function onArticleDelete( &$article, &$user, &$reason, &$error ) { |
36 | | - $thread = Threads::withRoot( $article ); |
37 | | - |
38 | | - if ( is_object( $thread ) && $thread->isTopmostThread() && count($thread->replies())) { |
39 | | - $error = wfMsgExt( 'lqt-delete-has-subthreads', 'parse' ); |
40 | | - return false; |
41 | | - } |
42 | | - |
43 | | - return true; |
44 | | - } |
45 | | - |
46 | 45 | static function onArticleRevisionUndeleted( &$title, $revision, $page_id ) { |
47 | 46 | if ( $title->getNamespace() == NS_LQT_THREAD ) { |
48 | 47 | self::$pageids_to_revive[$page_id] = $title; |
— | — | @@ -68,7 +67,7 @@ |
69 | 68 | $threads = Threads::loadFromResult( $res, $dbw ); |
70 | 69 | |
71 | 70 | if ( count($threads) ) { |
72 | | - $thread = $threads[0]; |
| 71 | + $thread = array_pop($threads); |
73 | 72 | $thread->setRoot( new Article( $title ) ); |
74 | 73 | $thread->undelete( $comment ); |
75 | 74 | } else { |
— | — | @@ -78,4 +77,18 @@ |
79 | 78 | |
80 | 79 | return true; |
81 | 80 | } |
| 81 | + |
| 82 | + static function onArticleConfirmDelete( $article, $out, &$reason ) { |
| 83 | + if ($article->getTitle()->getNamespace() != NS_LQT_THREAD) return true; |
| 84 | + |
| 85 | + $thread = Threads::withRoot( $article ); |
| 86 | + |
| 87 | + if ( $thread->isTopmostThread() && count($thread->replies()) ) { |
| 88 | + wfLoadExtensionMessages( 'LiquidThreads' ); |
| 89 | + $out->wrapWikiMsg( '<strong>$1</strong>', |
| 90 | + 'lqt-delete-parent-warning' ); |
| 91 | + } |
| 92 | + |
| 93 | + return true; |
| 94 | + } |
82 | 95 | } |