r15875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15874‎ | r15875 | r15876 >
Date:08:45, 29 July 2006
Author:david
Status:old
Tags:
Comment:
rudimentary deletion
Modified paths:
  • /branches/liquidthreads/extensions/LqtSpecialNamespaces.php (modified) (history)
  • /branches/liquidthreads/extensions/Post.php (modified) (history)
  • /branches/liquidthreads/extensions/ThreadView.php (modified) (history)
  • /branches/liquidthreads/maintenance/lqt.sql (modified) (history)
  • /branches/liquidthreads/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/monobook/main.css
@@ -31,6 +31,22 @@
3232 margin-bottom: 1em;
3333 }
3434
 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+
3551 .lqt_channel_body {
3652 background-color: white;
3753 }
Index: branches/liquidthreads/extensions/Post.php
@@ -212,7 +212,7 @@
213213
214214 $this->mTopic = $s;
215215
216 - return null; // FIXME return success/failure.
 216+ return $res;
217217 }
218218
219219
@@ -221,7 +221,28 @@
222222 return $this->mTopic;
223223 }
224224
 225+ function setDeleted($b) {
 226+ $this->createLqtRecord();
 227+
 228+ $new_b = $b ? 1 : 0;
225229
 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+
226247 /**
227248 * Populate $mFirstReply and $mNextPost with the appropriate Post objects.
228249 * Hits the database, but only the first time.
@@ -235,7 +256,7 @@
236257 $dbr =& wfGetDB( DB_SLAVE );
237258
238259 $line = $dbr->selectRow( array('lqt', 'page'),
239 - array('lqt_next', 'lqt_first_reply', 'lqt_thread'),
 260+ array('*'),
240261 array('lqt_this = page_id',
241262 'page_id' => $this->getID()),
242263 __METHOD__);
@@ -259,6 +280,12 @@
260281 } else {
261282 $this->mThread = null;
262283 }
 284+
 285+ if ( $line && $line->lqt_is_deleted ) {
 286+ $this->mIsDeleted = $line->lqt_is_deleted ? 1 : 0;
 287+ } else {
 288+ $this->mIsDeleted = 0;
 289+ }
263290 }
264291
265292 /**
Index: branches/liquidthreads/extensions/LqtSpecialNamespaces.php
@@ -118,6 +118,27 @@
119119
120120 $threads = Thread::threadsOfArticle($article, $first_day, $last_day);
121121
 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+
122143 // Execute move operations:
123144 // TODO find a better home for this.
124145 $post_id = $wgRequest->getInt( 'lqt_move_post_id', false );
@@ -213,6 +234,26 @@
214235 // SpecialPage::setHeaders
215236 $this->setHeaders();
216237
 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+
217258 // Execute move operations:
218259 $post_id = $wgRequest->getInt( 'lqt_move_post_id', false );
219260 $reply_to_id = $wgRequest->getInt( 'lqt_move_to_reply', false );
Index: branches/liquidthreads/extensions/ThreadView.php
@@ -99,7 +99,13 @@
100100
101101 $is_top_level = ( $this->mThread->firstPost()->getID() == $p->getID() );
102102
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() ) {
104110 $this->editForm( $p );
105111 // $this->showEditingForm($p, "lqt_editing={$p->getID()}", $is_top_level);
106112
@@ -141,6 +147,17 @@
142148 wfElementClean('a', array('href'=>$move_href),'Move') .
143149 wfCloseElement( 'li') );
144150
 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+
145162 $permalinkTitle = Title::makeTitle( LQT_NS_THREAD, $p->getTitle()->getDBkey() );
146163 $permalink_href = $permalinkTitle->getLocalURL();
147164 $wgOut->addHTML( wfOpenElement('li') .
Index: branches/liquidthreads/maintenance/lqt.sql
@@ -22,6 +22,12 @@
2323 -- lqt_thread to which this post belongs.
2424 lqt_thread int(8) unsigned NOT NULL,
2525
 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+
2632 PRIMARY KEY this_lqt_id (lqt_this, lqt_id),
2733 UNIQUE INDEX lqt_id (lqt_id),
2834 UNIQUE INDEX lqt_this (lqt_this),