Big oops - merged to wrong branch.
[lhc/web/wiklou.git] / includes / revisiondelete / RevisionDelete.php
1 <?php
2 /**
3 * Base implementations for deletable items.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup RevisionDelete
22 */
23
24 /**
25 * List for revision table items
26 *
27 * This will check both the 'revision' table for live revisions and the
28 * 'archive' table for traditionally-deleted revisions that have an
29 * ar_rev_id saved.
30 *
31 * See RevDel_RevisionItem and RevDel_ArchivedRevisionItem for items.
32 */
33 class RevDel_RevisionList extends RevDel_List {
34 var $currentRevId;
35
36 public function getType() {
37 return 'revision';
38 }
39
40 public static function getRelationType() {
41 return 'rev_id';
42 }
43
44 /**
45 * @param $db DatabaseBase
46 * @return mixed
47 */
48 public function doQuery( $db ) {
49 $ids = array_map( 'intval', $this->ids );
50 $live = $db->select(
51 array( 'revision', 'page', 'user' ),
52 array_merge( Revision::selectFields(), Revision::selectUserFields() ),
53 array(
54 'rev_page' => $this->title->getArticleID(),
55 'rev_id' => $ids,
56 ),
57 __METHOD__,
58 array( 'ORDER BY' => 'rev_id DESC' ),
59 array(
60 'page' => Revision::pageJoinCond(),
61 'user' => Revision::userJoinCond() )
62 );
63
64 if ( $live->numRows() >= count( $ids ) ) {
65 // All requested revisions are live, keeps things simple!
66 return $live;
67 }
68
69 // Check if any requested revisions are available fully deleted.
70 $archived = $db->select( array( 'archive' ), '*',
71 array(
72 'ar_rev_id' => $ids
73 ),
74 __METHOD__,
75 array( 'ORDER BY' => 'ar_rev_id DESC' )
76 );
77
78 if ( $archived->numRows() == 0 ) {
79 return $live;
80 } elseif ( $live->numRows() == 0 ) {
81 return $archived;
82 } else {
83 // Combine the two! Whee
84 $rows = array();
85 foreach ( $live as $row ) {
86 $rows[$row->rev_id] = $row;
87 }
88 foreach ( $archived as $row ) {
89 $rows[$row->ar_rev_id] = $row;
90 }
91 krsort( $rows );
92 return new FakeResultWrapper( array_values( $rows ) );
93 }
94 }
95
96 public function newItem( $row ) {
97 if ( isset( $row->rev_id ) ) {
98 return new RevDel_RevisionItem( $this, $row );
99 } elseif ( isset( $row->ar_rev_id ) ) {
100 return new RevDel_ArchivedRevisionItem( $this, $row );
101 } else {
102 // This shouldn't happen. :)
103 throw new MWException( 'Invalid row type in RevDel_RevisionList' );
104 }
105 }
106
107 public function getCurrent() {
108 if ( is_null( $this->currentRevId ) ) {
109 $dbw = wfGetDB( DB_MASTER );
110 $this->currentRevId = $dbw->selectField(
111 'page', 'page_latest', $this->title->pageCond(), __METHOD__ );
112 }
113 return $this->currentRevId;
114 }
115
116 public function getSuppressBit() {
117 return Revision::DELETED_RESTRICTED;
118 }
119
120 public function doPreCommitUpdates() {
121 $this->title->invalidateCache();
122 return Status::newGood();
123 }
124
125 public function doPostCommitUpdates() {
126 $this->title->purgeSquid();
127 // Extensions that require referencing previous revisions may need this
128 wfRunHooks( 'ArticleRevisionVisibilitySet', array( &$this->title ) );
129 return Status::newGood();
130 }
131 }
132
133 /**
134 * Item class for a live revision table row
135 */
136 class RevDel_RevisionItem extends RevDel_Item {
137 var $revision;
138
139 public function __construct( $list, $row ) {
140 parent::__construct( $list, $row );
141 $this->revision = new Revision( $row );
142 }
143
144 public function getIdField() {
145 return 'rev_id';
146 }
147
148 public function getTimestampField() {
149 return 'rev_timestamp';
150 }
151
152 public function getAuthorIdField() {
153 return 'rev_user';
154 }
155
156 public function getAuthorNameField() {
157 return 'user_name'; // see Revision::selectUserFields()
158 }
159
160 public function canView() {
161 return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->list->getUser() );
162 }
163
164 public function canViewContent() {
165 return $this->revision->userCan( Revision::DELETED_TEXT, $this->list->getUser() );
166 }
167
168 public function getBits() {
169 return $this->revision->getVisibility();
170 }
171
172 public function setBits( $bits ) {
173 $dbw = wfGetDB( DB_MASTER );
174 // Update revision table
175 $dbw->update( 'revision',
176 array( 'rev_deleted' => $bits ),
177 array(
178 'rev_id' => $this->revision->getId(),
179 'rev_page' => $this->revision->getPage(),
180 'rev_deleted' => $this->getBits()
181 ),
182 __METHOD__
183 );
184 if ( !$dbw->affectedRows() ) {
185 // Concurrent fail!
186 return false;
187 }
188 // Update recentchanges table
189 $dbw->update( 'recentchanges',
190 array(
191 'rc_deleted' => $bits,
192 'rc_patrolled' => 1
193 ),
194 array(
195 'rc_this_oldid' => $this->revision->getId(), // condition
196 // non-unique timestamp index
197 'rc_timestamp' => $dbw->timestamp( $this->revision->getTimestamp() ),
198 ),
199 __METHOD__
200 );
201 return true;
202 }
203
204 public function isDeleted() {
205 return $this->revision->isDeleted( Revision::DELETED_TEXT );
206 }
207
208 public function isHideCurrentOp( $newBits ) {
209 return ( $newBits & Revision::DELETED_TEXT )
210 && $this->list->getCurrent() == $this->getId();
211 }
212
213 /**
214 * Get the HTML link to the revision text.
215 * Overridden by RevDel_ArchiveItem.
216 * @return string
217 */
218 protected function getRevisionLink() {
219 $date = $this->list->getLanguage()->userTimeAndDate(
220 $this->revision->getTimestamp(), $this->list->getUser() );
221 if ( $this->isDeleted() && !$this->canViewContent() ) {
222 return $date;
223 }
224 return Linker::link(
225 $this->list->title,
226 $date,
227 array(),
228 array(
229 'oldid' => $this->revision->getId(),
230 'unhide' => 1
231 )
232 );
233 }
234
235 /**
236 * Get the HTML link to the diff.
237 * Overridden by RevDel_ArchiveItem
238 * @return string
239 */
240 protected function getDiffLink() {
241 if ( $this->isDeleted() && !$this->canViewContent() ) {
242 return $this->list->msg( 'diff' )->escaped();
243 } else {
244 return
245 Linker::link(
246 $this->list->title,
247 $this->list->msg( 'diff' )->escaped(),
248 array(),
249 array(
250 'diff' => $this->revision->getId(),
251 'oldid' => 'prev',
252 'unhide' => 1
253 ),
254 array(
255 'known',
256 'noclasses'
257 )
258 );
259 }
260 }
261
262 public function getHTML() {
263 $difflink = wfMessage( 'parentheses' )->rawParams( $this->getDiffLink() );
264 $revlink = $this->getRevisionLink();
265 $userlink = Linker::revUserLink( $this->revision );
266 $comment = Linker::revComment( $this->revision );
267 if ( $this->isDeleted() ) {
268 $revlink = "<span class=\"history-deleted\">$revlink</span>";
269 }
270 return "<li>$difflink $revlink $userlink $comment</li>";
271 }
272 }
273
274 /**
275 * List for archive table items, i.e. revisions deleted via action=delete
276 */
277 class RevDel_ArchiveList extends RevDel_RevisionList {
278 public function getType() {
279 return 'archive';
280 }
281
282 public static function getRelationType() {
283 return 'ar_timestamp';
284 }
285
286 /**
287 * @param $db DatabaseBase
288 * @return mixed
289 */
290 public function doQuery( $db ) {
291 $timestamps = array();
292 foreach ( $this->ids as $id ) {
293 $timestamps[] = $db->timestamp( $id );
294 }
295 return $db->select( 'archive', '*',
296 array(
297 'ar_namespace' => $this->title->getNamespace(),
298 'ar_title' => $this->title->getDBkey(),
299 'ar_timestamp' => $timestamps
300 ),
301 __METHOD__,
302 array( 'ORDER BY' => 'ar_timestamp DESC' )
303 );
304 }
305
306 public function newItem( $row ) {
307 return new RevDel_ArchiveItem( $this, $row );
308 }
309
310 public function doPreCommitUpdates() {
311 return Status::newGood();
312 }
313
314 public function doPostCommitUpdates() {
315 return Status::newGood();
316 }
317 }
318
319 /**
320 * Item class for a archive table row
321 */
322 class RevDel_ArchiveItem extends RevDel_RevisionItem {
323 public function __construct( $list, $row ) {
324 RevDel_Item::__construct( $list, $row );
325 $this->revision = Revision::newFromArchiveRow( $row,
326 array( 'page' => $this->list->title->getArticleID() ) );
327 }
328
329 public function getIdField() {
330 return 'ar_timestamp';
331 }
332
333 public function getTimestampField() {
334 return 'ar_timestamp';
335 }
336
337 public function getAuthorIdField() {
338 return 'ar_user';
339 }
340
341 public function getAuthorNameField() {
342 return 'ar_user_text';
343 }
344
345 public function getId() {
346 # Convert DB timestamp to MW timestamp
347 return $this->revision->getTimestamp();
348 }
349
350 public function setBits( $bits ) {
351 $dbw = wfGetDB( DB_MASTER );
352 $dbw->update( 'archive',
353 array( 'ar_deleted' => $bits ),
354 array(
355 'ar_namespace' => $this->list->title->getNamespace(),
356 'ar_title' => $this->list->title->getDBkey(),
357 // use timestamp for index
358 'ar_timestamp' => $this->row->ar_timestamp,
359 'ar_rev_id' => $this->row->ar_rev_id,
360 'ar_deleted' => $this->getBits()
361 ),
362 __METHOD__ );
363 return (bool)$dbw->affectedRows();
364 }
365
366 protected function getRevisionLink() {
367 $undelete = SpecialPage::getTitleFor( 'Undelete' );
368 $date = $this->list->getLanguage()->userTimeAndDate(
369 $this->revision->getTimestamp(), $this->list->getUser() );
370 if ( $this->isDeleted() && !$this->canViewContent() ) {
371 return $date;
372 }
373 return Linker::link( $undelete, $date, array(),
374 array(
375 'target' => $this->list->title->getPrefixedText(),
376 'timestamp' => $this->revision->getTimestamp()
377 ) );
378 }
379
380 protected function getDiffLink() {
381 if ( $this->isDeleted() && !$this->canViewContent() ) {
382 return $this->list->msg( 'diff' )->escaped();
383 }
384 $undelete = SpecialPage::getTitleFor( 'Undelete' );
385 return Linker::link( $undelete, $this->list->msg( 'diff' )->escaped(), array(),
386 array(
387 'target' => $this->list->title->getPrefixedText(),
388 'diff' => 'prev',
389 'timestamp' => $this->revision->getTimestamp()
390 ) );
391 }
392 }
393
394
395 /**
396 * Item class for a archive table row by ar_rev_id -- actually
397 * used via RevDel_RevisionList.
398 */
399 class RevDel_ArchivedRevisionItem extends RevDel_ArchiveItem {
400 public function __construct( $list, $row ) {
401 RevDel_Item::__construct( $list, $row );
402
403 $this->revision = Revision::newFromArchiveRow( $row,
404 array( 'page' => $this->list->title->getArticleID() ) );
405 }
406
407 public function getIdField() {
408 return 'ar_rev_id';
409 }
410
411 public function getId() {
412 return $this->revision->getId();
413 }
414
415 public function setBits( $bits ) {
416 $dbw = wfGetDB( DB_MASTER );
417 $dbw->update( 'archive',
418 array( 'ar_deleted' => $bits ),
419 array( 'ar_rev_id' => $this->row->ar_rev_id,
420 'ar_deleted' => $this->getBits()
421 ),
422 __METHOD__ );
423 return (bool)$dbw->affectedRows();
424 }
425 }
426
427 /**
428 * List for oldimage table items
429 */
430 class RevDel_FileList extends RevDel_List {
431 public function getType() {
432 return 'oldimage';
433 }
434
435 public static function getRelationType() {
436 return 'oi_archive_name';
437 }
438
439 var $storeBatch, $deleteBatch, $cleanupBatch;
440
441 /**
442 * @param $db DatabaseBase
443 * @return mixed
444 */
445 public function doQuery( $db ) {
446 $archiveNames = array();
447 foreach( $this->ids as $timestamp ) {
448 $archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
449 }
450 return $db->select( 'oldimage', '*',
451 array(
452 'oi_name' => $this->title->getDBkey(),
453 'oi_archive_name' => $archiveNames
454 ),
455 __METHOD__,
456 array( 'ORDER BY' => 'oi_timestamp DESC' )
457 );
458 }
459
460 public function newItem( $row ) {
461 return new RevDel_FileItem( $this, $row );
462 }
463
464 public function clearFileOps() {
465 $this->deleteBatch = array();
466 $this->storeBatch = array();
467 $this->cleanupBatch = array();
468 }
469
470 public function doPreCommitUpdates() {
471 $status = Status::newGood();
472 $repo = RepoGroup::singleton()->getLocalRepo();
473 if ( $this->storeBatch ) {
474 $status->merge( $repo->storeBatch( $this->storeBatch, FileRepo::OVERWRITE_SAME ) );
475 }
476 if ( !$status->isOK() ) {
477 return $status;
478 }
479 if ( $this->deleteBatch ) {
480 $status->merge( $repo->deleteBatch( $this->deleteBatch ) );
481 }
482 if ( !$status->isOK() ) {
483 // Running cleanupDeletedBatch() after a failed storeBatch() with the DB already
484 // modified (but destined for rollback) causes data loss
485 return $status;
486 }
487 if ( $this->cleanupBatch ) {
488 $status->merge( $repo->cleanupDeletedBatch( $this->cleanupBatch ) );
489 }
490 return $status;
491 }
492
493 public function doPostCommitUpdates() {
494 $file = wfLocalFile( $this->title );
495 $file->purgeCache();
496 $file->purgeDescription();
497 return Status::newGood();
498 }
499
500 public function getSuppressBit() {
501 return File::DELETED_RESTRICTED;
502 }
503 }
504
505 /**
506 * Item class for an oldimage table row
507 */
508 class RevDel_FileItem extends RevDel_Item {
509
510 /**
511 * @var File
512 */
513 var $file;
514
515 public function __construct( $list, $row ) {
516 parent::__construct( $list, $row );
517 $this->file = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
518 }
519
520 public function getIdField() {
521 return 'oi_archive_name';
522 }
523
524 public function getTimestampField() {
525 return 'oi_timestamp';
526 }
527
528 public function getAuthorIdField() {
529 return 'oi_user';
530 }
531
532 public function getAuthorNameField() {
533 return 'oi_user_text';
534 }
535
536 public function getId() {
537 $parts = explode( '!', $this->row->oi_archive_name );
538 return $parts[0];
539 }
540
541 public function canView() {
542 return $this->file->userCan( File::DELETED_RESTRICTED, $this->list->getUser() );
543 }
544
545 public function canViewContent() {
546 return $this->file->userCan( File::DELETED_FILE, $this->list->getUser() );
547 }
548
549 public function getBits() {
550 return $this->file->getVisibility();
551 }
552
553 public function setBits( $bits ) {
554 # Queue the file op
555 # @todo FIXME: Move to LocalFile.php
556 if ( $this->isDeleted() ) {
557 if ( $bits & File::DELETED_FILE ) {
558 # Still deleted
559 } else {
560 # Newly undeleted
561 $key = $this->file->getStorageKey();
562 $srcRel = $this->file->repo->getDeletedHashPath( $key ) . $key;
563 $this->list->storeBatch[] = array(
564 $this->file->repo->getVirtualUrl( 'deleted' ) . '/' . $srcRel,
565 'public',
566 $this->file->getRel()
567 );
568 $this->list->cleanupBatch[] = $key;
569 }
570 } elseif ( $bits & File::DELETED_FILE ) {
571 # Newly deleted
572 $key = $this->file->getStorageKey();
573 $dstRel = $this->file->repo->getDeletedHashPath( $key ) . $key;
574 $this->list->deleteBatch[] = array( $this->file->getRel(), $dstRel );
575 }
576
577 # Do the database operations
578 $dbw = wfGetDB( DB_MASTER );
579 $dbw->update( 'oldimage',
580 array( 'oi_deleted' => $bits ),
581 array(
582 'oi_name' => $this->row->oi_name,
583 'oi_timestamp' => $this->row->oi_timestamp,
584 'oi_deleted' => $this->getBits()
585 ),
586 __METHOD__
587 );
588 return (bool)$dbw->affectedRows();
589 }
590
591 public function isDeleted() {
592 return $this->file->isDeleted( File::DELETED_FILE );
593 }
594
595 /**
596 * Get the link to the file.
597 * Overridden by RevDel_ArchivedFileItem.
598 * @return string
599 */
600 protected function getLink() {
601 $date = $this->list->getLanguage()->userTimeAndDate(
602 $this->file->getTimestamp(), $this->list->getUser() );
603 if ( $this->isDeleted() ) {
604 # Hidden files...
605 if ( !$this->canViewContent() ) {
606 $link = $date;
607 } else {
608 $revdelete = SpecialPage::getTitleFor( 'Revisiondelete' );
609 $link = Linker::link(
610 $revdelete,
611 $date, array(),
612 array(
613 'target' => $this->list->title->getPrefixedText(),
614 'file' => $this->file->getArchiveName(),
615 'token' => $this->list->getUser()->getEditToken(
616 $this->file->getArchiveName() )
617 )
618 );
619 }
620 return '<span class="history-deleted">' . $link . '</span>';
621 } else {
622 # Regular files...
623 return Xml::element( 'a', array( 'href' => $this->file->getUrl() ), $date );
624 }
625 }
626 /**
627 * Generate a user tool link cluster if the current user is allowed to view it
628 * @return string HTML
629 */
630 protected function getUserTools() {
631 if( $this->file->userCan( Revision::DELETED_USER, $this->list->getUser() ) ) {
632 $link = Linker::userLink( $this->file->user, $this->file->user_text ) .
633 Linker::userToolLinks( $this->file->user, $this->file->user_text );
634 } else {
635 $link = $this->list->msg( 'rev-deleted-user' )->escaped();
636 }
637 if( $this->file->isDeleted( Revision::DELETED_USER ) ) {
638 return '<span class="history-deleted">' . $link . '</span>';
639 }
640 return $link;
641 }
642
643 /**
644 * Wrap and format the file's comment block, if the current
645 * user is allowed to view it.
646 *
647 * @return string HTML
648 */
649 protected function getComment() {
650 if( $this->file->userCan( File::DELETED_COMMENT, $this->list->getUser() ) ) {
651 $block = Linker::commentBlock( $this->file->description );
652 } else {
653 $block = ' ' . $this->list->msg( 'rev-deleted-comment' )->escaped();
654 }
655 if( $this->file->isDeleted( File::DELETED_COMMENT ) ) {
656 return "<span class=\"history-deleted\">$block</span>";
657 }
658 return $block;
659 }
660
661 public function getHTML() {
662 $data =
663 $this->list->msg( 'widthheight' )->numParams(
664 $this->file->getWidth(), $this->file->getHeight() )->text() .
665 ' (' . $this->list->msg( 'nbytes' )->numParams( $this->file->getSize() )->text() . ')';
666
667 return '<li>' . $this->getLink() . ' ' . $this->getUserTools() . ' ' .
668 $data . ' ' . $this->getComment(). '</li>';
669 }
670 }
671
672 /**
673 * List for filearchive table items
674 */
675 class RevDel_ArchivedFileList extends RevDel_FileList {
676 public function getType() {
677 return 'filearchive';
678 }
679
680 public static function getRelationType() {
681 return 'fa_id';
682 }
683
684 /**
685 * @param $db DatabaseBase
686 * @return mixed
687 */
688 public function doQuery( $db ) {
689 $ids = array_map( 'intval', $this->ids );
690 return $db->select( 'filearchive', '*',
691 array(
692 'fa_name' => $this->title->getDBkey(),
693 'fa_id' => $ids
694 ),
695 __METHOD__,
696 array( 'ORDER BY' => 'fa_id DESC' )
697 );
698 }
699
700 public function newItem( $row ) {
701 return new RevDel_ArchivedFileItem( $this, $row );
702 }
703 }
704
705 /**
706 * Item class for a filearchive table row
707 */
708 class RevDel_ArchivedFileItem extends RevDel_FileItem {
709 public function __construct( $list, $row ) {
710 RevDel_Item::__construct( $list, $row );
711 $this->file = ArchivedFile::newFromRow( $row );
712 }
713
714 public function getIdField() {
715 return 'fa_id';
716 }
717
718 public function getTimestampField() {
719 return 'fa_timestamp';
720 }
721
722 public function getAuthorIdField() {
723 return 'fa_user';
724 }
725
726 public function getAuthorNameField() {
727 return 'fa_user_text';
728 }
729
730 public function getId() {
731 return $this->row->fa_id;
732 }
733
734 public function setBits( $bits ) {
735 $dbw = wfGetDB( DB_MASTER );
736 $dbw->update( 'filearchive',
737 array( 'fa_deleted' => $bits ),
738 array(
739 'fa_id' => $this->row->fa_id,
740 'fa_deleted' => $this->getBits(),
741 ),
742 __METHOD__
743 );
744 return (bool)$dbw->affectedRows();
745 }
746
747 protected function getLink() {
748 $date = $this->list->getLanguage()->userTimeAndDate(
749 $this->file->getTimestamp(), $this->list->getUser() );
750 $undelete = SpecialPage::getTitleFor( 'Undelete' );
751 $key = $this->file->getKey();
752 # Hidden files...
753 if( !$this->canViewContent() ) {
754 $link = $date;
755 } else {
756 $link = Linker::link( $undelete, $date, array(),
757 array(
758 'target' => $this->list->title->getPrefixedText(),
759 'file' => $key,
760 'token' => $this->list->getUser()->getEditToken( $key )
761 )
762 );
763 }
764 if( $this->isDeleted() ) {
765 $link = '<span class="history-deleted">' . $link . '</span>';
766 }
767 return $link;
768 }
769 }
770
771 /**
772 * List for logging table items
773 */
774 class RevDel_LogList extends RevDel_List {
775 public function getType() {
776 return 'logging';
777 }
778
779 public static function getRelationType() {
780 return 'log_id';
781 }
782
783 /**
784 * @param $db DatabaseBase
785 * @return mixed
786 */
787 public function doQuery( $db ) {
788 $ids = array_map( 'intval', $this->ids );
789 return $db->select( 'logging', '*',
790 array( 'log_id' => $ids ),
791 __METHOD__,
792 array( 'ORDER BY' => 'log_id DESC' )
793 );
794 }
795
796 public function newItem( $row ) {
797 return new RevDel_LogItem( $this, $row );
798 }
799
800 public function getSuppressBit() {
801 return Revision::DELETED_RESTRICTED;
802 }
803
804 public function getLogAction() {
805 return 'event';
806 }
807
808 public function getLogParams( $params ) {
809 return array(
810 implode( ',', $params['ids'] ),
811 "ofield={$params['oldBits']}",
812 "nfield={$params['newBits']}"
813 );
814 }
815 }
816
817 /**
818 * Item class for a logging table row
819 */
820 class RevDel_LogItem extends RevDel_Item {
821 public function getIdField() {
822 return 'log_id';
823 }
824
825 public function getTimestampField() {
826 return 'log_timestamp';
827 }
828
829 public function getAuthorIdField() {
830 return 'log_user';
831 }
832
833 public function getAuthorNameField() {
834 return 'log_user_text';
835 }
836
837 public function canView() {
838 return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
839 }
840
841 public function canViewContent() {
842 return true; // none
843 }
844
845 public function getBits() {
846 return $this->row->log_deleted;
847 }
848
849 public function setBits( $bits ) {
850 $dbw = wfGetDB( DB_MASTER );
851 $dbw->update( 'recentchanges',
852 array(
853 'rc_deleted' => $bits,
854 'rc_patrolled' => 1
855 ),
856 array(
857 'rc_logid' => $this->row->log_id,
858 'rc_timestamp' => $this->row->log_timestamp // index
859 ),
860 __METHOD__
861 );
862 $dbw->update( 'logging',
863 array( 'log_deleted' => $bits ),
864 array(
865 'log_id' => $this->row->log_id,
866 'log_deleted' => $this->getBits()
867 ),
868 __METHOD__
869 );
870 return (bool)$dbw->affectedRows();
871 }
872
873 public function getHTML() {
874 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
875 $this->row->log_timestamp, $this->list->getUser() ) );
876 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
877 $formatter = LogFormatter::newFromRow( $this->row );
878 $formatter->setContext( $this->list->getContext() );
879 $formatter->setAudience( LogFormatter::FOR_THIS_USER );
880
881 // Log link for this page
882 $loglink = Linker::link(
883 SpecialPage::getTitleFor( 'Log' ),
884 $this->list->msg( 'log' )->escaped(),
885 array(),
886 array( 'page' => $title->getPrefixedText() )
887 );
888 $loglink = wfMessage( 'parentheses' )->rawParams( $loglink );
889 // User links and action text
890 $action = $formatter->getActionText();
891 // Comment
892 $comment = $this->list->getLanguage()->getDirMark() . Linker::commentBlock( $this->row->log_comment );
893 if( LogEventsList::isDeleted($this->row,LogPage::DELETED_COMMENT) ) {
894 $comment = '<span class="history-deleted">' . $comment . '</span>';
895 }
896
897 return "<li>$loglink $date $action $comment</li>";
898 }
899 }