X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/revisiondelete/RevDelLogItem.php diff --git a/includes/revisiondelete/RevDelLogItem.php b/includes/revisiondelete/RevDelLogItem.php new file mode 100644 index 00000000..998c695f --- /dev/null +++ b/includes/revisiondelete/RevDelLogItem.php @@ -0,0 +1,145 @@ +row, Revision::DELETED_RESTRICTED, $this->list->getUser() ); + } + + public function canViewContent() { + return true; // none + } + + public function getBits() { + return (int)$this->row->log_deleted; + } + + public function setBits( $bits ) { + $dbw = wfGetDB( DB_MASTER ); + + $dbw->update( 'logging', + [ 'log_deleted' => $bits ], + [ + 'log_id' => $this->row->log_id, + 'log_deleted' => $this->getBits() // cas + ], + __METHOD__ + ); + + if ( !$dbw->affectedRows() ) { + // Concurrent fail! + return false; + } + + $dbw->update( 'recentchanges', + [ + 'rc_deleted' => $bits, + 'rc_patrolled' => 1 + ], + [ + 'rc_logid' => $this->row->log_id, + 'rc_timestamp' => $this->row->log_timestamp // index + ], + __METHOD__ + ); + + return true; + } + + public function getHTML() { + $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( + $this->row->log_timestamp, $this->list->getUser() ) ); + $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title ); + $formatter = LogFormatter::newFromRow( $this->row ); + $formatter->setContext( $this->list->getContext() ); + $formatter->setAudience( LogFormatter::FOR_THIS_USER ); + + // Log link for this page + $loglink = $this->getLinkRenderer()->makeLink( + SpecialPage::getTitleFor( 'Log' ), + $this->list->msg( 'log' )->text(), + [], + [ 'page' => $title->getPrefixedText() ] + ); + $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped(); + // User links and action text + $action = $formatter->getActionText(); + // Comment + $comment = CommentStore::newKey( 'log_comment' )->getComment( $this->row )->text; + $comment = $this->list->getLanguage()->getDirMark() + . Linker::commentBlock( $comment ); + + if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) { + $comment = '' . $comment . ''; + } + + return "
  • $loglink $date $action $comment
  • "; + } + + public function getApiData( ApiResult $result ) { + $logEntry = DatabaseLogEntry::newFromRow( $this->row ); + $user = $this->list->getUser(); + $ret = [ + 'id' => $logEntry->getId(), + 'type' => $logEntry->getType(), + 'action' => $logEntry->getSubtype(), + 'userhidden' => (bool)$logEntry->isDeleted( LogPage::DELETED_USER ), + 'commenthidden' => (bool)$logEntry->isDeleted( LogPage::DELETED_COMMENT ), + 'actionhidden' => (bool)$logEntry->isDeleted( LogPage::DELETED_ACTION ), + ]; + + if ( LogEventsList::userCan( $this->row, LogPage::DELETED_ACTION, $user ) ) { + $ret['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi(); + } + if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) { + $ret += [ + 'userid' => $this->row->log_user, + 'user' => $this->row->log_user_text, + ]; + } + if ( LogEventsList::userCan( $this->row, LogPage::DELETED_COMMENT, $user ) ) { + $ret += [ + 'comment' => CommentStore::newKey( 'log_comment' )->getComment( $this->row )->text, + ]; + } + + return $ret; + } +}