Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -31,6 +31,22 @@ |
32 | 32 | margin-bottom: 1em; |
33 | 33 | } |
34 | 34 | |
| 35 | +.lqt_deleted_notice { |
| 36 | + color: #999; |
| 37 | + font-style: italic; |
| 38 | +} |
| 39 | + |
| 40 | +.lqt_deleted_notice a { |
| 41 | + color: #5874d1; |
| 42 | +} |
| 43 | +.lqt_deleted_notice a:visited { |
| 44 | + color: #937cba; |
| 45 | +} |
| 46 | +.lqt_deleted_notice a:active { |
| 47 | + color: #faa700; |
| 48 | +} |
| 49 | +} |
| 50 | + |
35 | 51 | .lqt_channel_body { |
36 | 52 | background-color: white; |
37 | 53 | } |
Index: branches/liquidthreads/extensions/Post.php |
— | — | @@ -212,7 +212,7 @@ |
213 | 213 | |
214 | 214 | $this->mTopic = $s; |
215 | 215 | |
216 | | - return null; // FIXME return success/failure. |
| 216 | + return $res; |
217 | 217 | } |
218 | 218 | |
219 | 219 | |
— | — | @@ -221,7 +221,28 @@ |
222 | 222 | return $this->mTopic; |
223 | 223 | } |
224 | 224 | |
| 225 | + function setDeleted($b) { |
| 226 | + $this->createLqtRecord(); |
| 227 | + |
| 228 | + $new_b = $b ? 1 : 0; |
225 | 229 | |
| 230 | + $dbr =& wfGetDB( DB_MASTER ); |
| 231 | + |
| 232 | + $res = $dbr->update( 'lqt', |
| 233 | + /* SET */ array( 'lqt_is_deleted' => $new_b ), |
| 234 | + /* WHERE */ array( 'lqt_this' => $this->getID(), ), |
| 235 | + __METHOD__); |
| 236 | + |
| 237 | + $this->mIsDeleted = $new_b; |
| 238 | + |
| 239 | + return $res; |
| 240 | + } |
| 241 | + |
| 242 | + function isDeleted() { |
| 243 | + $this->loadLinks(); |
| 244 | + return $this->mIsDeleted; |
| 245 | + } |
| 246 | + |
226 | 247 | /** |
227 | 248 | * Populate $mFirstReply and $mNextPost with the appropriate Post objects. |
228 | 249 | * Hits the database, but only the first time. |
— | — | @@ -235,7 +256,7 @@ |
236 | 257 | $dbr =& wfGetDB( DB_SLAVE ); |
237 | 258 | |
238 | 259 | $line = $dbr->selectRow( array('lqt', 'page'), |
239 | | - array('lqt_next', 'lqt_first_reply', 'lqt_thread'), |
| 260 | + array('*'), |
240 | 261 | array('lqt_this = page_id', |
241 | 262 | 'page_id' => $this->getID()), |
242 | 263 | __METHOD__); |
— | — | @@ -259,6 +280,12 @@ |
260 | 281 | } else { |
261 | 282 | $this->mThread = null; |
262 | 283 | } |
| 284 | + |
| 285 | + if ( $line && $line->lqt_is_deleted ) { |
| 286 | + $this->mIsDeleted = $line->lqt_is_deleted ? 1 : 0; |
| 287 | + } else { |
| 288 | + $this->mIsDeleted = 0; |
| 289 | + } |
263 | 290 | } |
264 | 291 | |
265 | 292 | /** |
Index: branches/liquidthreads/extensions/LqtSpecialNamespaces.php |
— | — | @@ -118,6 +118,27 @@ |
119 | 119 | |
120 | 120 | $threads = Thread::threadsOfArticle($article, $first_day, $last_day); |
121 | 121 | |
| 122 | + // Execute deletes and undeletes: |
| 123 | + $delete_id = $wgRequest->getInt( 'lqt_do_delete_id', false ); |
| 124 | + $undelete_id = $wgRequest->getInt( 'lqt_do_undelete_id', false ); |
| 125 | + $t = null; |
| 126 | + if( $delete_id ) { |
| 127 | + $t = Title::newFromID($delete_id); |
| 128 | + $p = new Post( $t ); |
| 129 | + $p->setDeleted(true); |
| 130 | + } else if ($undelete_id) { |
| 131 | + $t = Title::newFromID($undelete_id); |
| 132 | + $p = new Post( $t ); |
| 133 | + $p->setDeleted(false); |
| 134 | + } |
| 135 | + if ( $delete_id || $undelete_id ) { |
| 136 | + $query = "lqt_highlight={$t->getPartialURL()}#lqt_post_{$t->getPartialURL()}"; |
| 137 | + $wgOut->redirect( $this->talkTitle->getFullURL($query) ); |
| 138 | + } |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
122 | 143 | // Execute move operations: |
123 | 144 | // TODO find a better home for this. |
124 | 145 | $post_id = $wgRequest->getInt( 'lqt_move_post_id', false ); |
— | — | @@ -213,6 +234,26 @@ |
214 | 235 | // SpecialPage::setHeaders |
215 | 236 | $this->setHeaders(); |
216 | 237 | |
| 238 | + // Execute deletes and undeletes: |
| 239 | + $delete_id = $wgRequest->getInt( 'lqt_do_delete_id', false ); |
| 240 | + $undelete_id = $wgRequest->getInt( 'lqt_do_undelete_id', false ); |
| 241 | + $t = null; |
| 242 | + if( $delete_id ) { |
| 243 | + $t = Title::newFromID($delete_id); |
| 244 | + $p = new Post( $t ); |
| 245 | + $p->setDeleted(true); |
| 246 | + } else if ($undelete_id) { |
| 247 | + $t = Title::newFromID($undelete_id); |
| 248 | + $p = new Post( $t ); |
| 249 | + $p->setDeleted(false); |
| 250 | + } |
| 251 | + if ( $delete_id || $undelete_id ) { |
| 252 | + $query = "lqt_highlight={$t->getPartialURL()}#lqt_post_{$t->getPartialURL()}"; |
| 253 | + $wgOut->redirect( $this->pageTitle->getFullURL($query) ); |
| 254 | + } |
| 255 | + |
| 256 | + |
| 257 | + |
217 | 258 | // Execute move operations: |
218 | 259 | $post_id = $wgRequest->getInt( 'lqt_move_post_id', false ); |
219 | 260 | $reply_to_id = $wgRequest->getInt( 'lqt_move_to_reply', false ); |
Index: branches/liquidthreads/extensions/ThreadView.php |
— | — | @@ -99,7 +99,13 @@ |
100 | 100 | |
101 | 101 | $is_top_level = ( $this->mThread->firstPost()->getID() == $p->getID() ); |
102 | 102 | |
103 | | - if ( $this->editingId == $p->getID() ) { |
| 103 | + if ( $p->isDeleted() && !$wgRequest->getVal('lqt_show_deleted', false) ) { |
| 104 | + // Render deleted posts: |
| 105 | + $author = $p->originalAuthor(); |
| 106 | + $show_href = $this->talkTitle->getLocalURL('lqt_show_deleted=true&lqt_highlight='.$t.'#lqt_post_'.$t); |
| 107 | + $wgOut->addHTML( '<span class="lqt_deleted_notice">Deleted post by '.$author.'.<a href='.$show_href.'>Show</a></span>' ); |
| 108 | + } |
| 109 | + elseif ( $this->editingId == $p->getID() ) { |
104 | 110 | $this->editForm( $p ); |
105 | 111 | // $this->showEditingForm($p, "lqt_editing={$p->getID()}", $is_top_level); |
106 | 112 | |
— | — | @@ -141,6 +147,17 @@ |
142 | 148 | wfElementClean('a', array('href'=>$move_href),'Move') . |
143 | 149 | wfCloseElement( 'li') ); |
144 | 150 | |
| 151 | + if ($p->isDeleted()) { |
| 152 | + $delete_href = $this->talkTitle->getLocalURL( "lqt_do_undelete_id={$p->getID()}" ); |
| 153 | + $delete_message = "Undelete"; |
| 154 | + } else { |
| 155 | + $delete_href = $this->talkTitle->getLocalURL( "lqt_do_delete_id={$p->getID()}" ); |
| 156 | + $delete_message = "Delete"; |
| 157 | + } |
| 158 | + $wgOut->addHTML( wfOpenElement('li') . |
| 159 | + wfElementClean('a', array('href'=>$delete_href), $delete_message) . |
| 160 | + wfCloseElement('li') ); |
| 161 | + |
145 | 162 | $permalinkTitle = Title::makeTitle( LQT_NS_THREAD, $p->getTitle()->getDBkey() ); |
146 | 163 | $permalink_href = $permalinkTitle->getLocalURL(); |
147 | 164 | $wgOut->addHTML( wfOpenElement('li') . |
Index: branches/liquidthreads/maintenance/lqt.sql |
— | — | @@ -22,6 +22,12 @@ |
23 | 23 | -- lqt_thread to which this post belongs. |
24 | 24 | lqt_thread int(8) unsigned NOT NULL, |
25 | 25 | |
| 26 | + -- Rudementary deletion. |
| 27 | + lqt_is_deleted boolean NOT NULL, |
| 28 | + |
| 29 | + -- Who deleted the post? == user_text. |
| 30 | + lqt_deleted_by varchar(255) binary NULL, |
| 31 | + |
26 | 32 | PRIMARY KEY this_lqt_id (lqt_this, lqt_id), |
27 | 33 | UNIQUE INDEX lqt_id (lqt_id), |
28 | 34 | UNIQUE INDEX lqt_this (lqt_this), |