MediaWiki  REL1_24
RevDelLogItem.php
Go to the documentation of this file.
00001 <?php
00025 class RevDelLogItem extends RevDelItem {
00026     public function getIdField() {
00027         return 'log_id';
00028     }
00029 
00030     public function getTimestampField() {
00031         return 'log_timestamp';
00032     }
00033 
00034     public function getAuthorIdField() {
00035         return 'log_user';
00036     }
00037 
00038     public function getAuthorNameField() {
00039         return 'log_user_text';
00040     }
00041 
00042     public function canView() {
00043         return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
00044     }
00045 
00046     public function canViewContent() {
00047         return true; // none
00048     }
00049 
00050     public function getBits() {
00051         return $this->row->log_deleted;
00052     }
00053 
00054     public function setBits( $bits ) {
00055         $dbw = wfGetDB( DB_MASTER );
00056         $dbw->update( 'recentchanges',
00057             array(
00058                 'rc_deleted' => $bits,
00059                 'rc_patrolled' => 1
00060             ),
00061             array(
00062                 'rc_logid' => $this->row->log_id,
00063                 'rc_timestamp' => $this->row->log_timestamp // index
00064             ),
00065             __METHOD__
00066         );
00067         $dbw->update( 'logging',
00068             array( 'log_deleted' => $bits ),
00069             array(
00070                 'log_id' => $this->row->log_id,
00071                 'log_deleted' => $this->getBits()
00072             ),
00073             __METHOD__
00074         );
00075 
00076         return (bool)$dbw->affectedRows();
00077     }
00078 
00079     public function getHTML() {
00080         $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
00081             $this->row->log_timestamp, $this->list->getUser() ) );
00082         $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
00083         $formatter = LogFormatter::newFromRow( $this->row );
00084         $formatter->setContext( $this->list->getContext() );
00085         $formatter->setAudience( LogFormatter::FOR_THIS_USER );
00086 
00087         // Log link for this page
00088         $loglink = Linker::link(
00089             SpecialPage::getTitleFor( 'Log' ),
00090             $this->list->msg( 'log' )->escaped(),
00091             array(),
00092             array( 'page' => $title->getPrefixedText() )
00093         );
00094         $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
00095         // User links and action text
00096         $action = $formatter->getActionText();
00097         // Comment
00098         $comment = $this->list->getLanguage()->getDirMark()
00099             . Linker::commentBlock( $this->row->log_comment );
00100 
00101         if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) {
00102             $comment = '<span class="history-deleted">' . $comment . '</span>';
00103         }
00104 
00105         return "<li>$loglink $date $action $comment</li>";
00106     }
00107 
00108     public function getApiData( ApiResult $result ) {
00109         $logEntry = DatabaseLogEntry::newFromRow( $this->row );
00110         $user = $this->list->getUser();
00111         $ret = array(
00112             'id' => $logEntry->getId(),
00113             'type' => $logEntry->getType(),
00114             'action' => $logEntry->getSubtype(),
00115         );
00116         $ret += $logEntry->isDeleted( LogPage::DELETED_USER )
00117             ? array( 'userhidden' => '' )
00118             : array();
00119         $ret += $logEntry->isDeleted( LogPage::DELETED_COMMENT )
00120             ? array( 'commenthidden' => '' )
00121             : array();
00122         $ret += $logEntry->isDeleted( LogPage::DELETED_ACTION )
00123             ? array( 'actionhidden' => '' )
00124             : array();
00125 
00126         if ( LogEventsList::userCan( $this->row, LogPage::DELETED_ACTION, $user ) ) {
00127             ApiQueryLogEvents::addLogParams(
00128                 $result,
00129                 $ret,
00130                 $logEntry->getParameters(),
00131                 $logEntry->getType(),
00132                 $logEntry->getSubtype(),
00133                 $logEntry->getTimestamp(),
00134                 $logEntry->isLegacy()
00135             );
00136         }
00137         if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) {
00138             $ret += array(
00139                 'userid' => $this->row->log_user,
00140                 'user' => $this->row->log_user_text,
00141             );
00142         }
00143         if ( LogEventsList::userCan( $this->row, LogPage::DELETED_COMMENT, $user ) ) {
00144             $ret += array(
00145                 'comment' => $this->row->log_comment,
00146             );
00147         }
00148 
00149         return $ret;
00150     }
00151 }