Merge "Remove not used private member variable mParserWarnings from OutputPage"
[mediawiki.git] / includes / revisiondelete / RevDelLogItem.php
blob65b03097425b4deadc05c360c33e97ecd3b778ce
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup RevisionDelete
22 /**
23 * Item class for a logging table row
25 class RevDelLogItem extends RevDelItem {
26 public function getIdField() {
27 return 'log_id';
30 public function getTimestampField() {
31 return 'log_timestamp';
34 public function getAuthorIdField() {
35 return 'log_user';
38 public function getAuthorNameField() {
39 return 'log_user_text';
42 public function canView() {
43 return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
46 public function canViewContent() {
47 return true; // none
50 public function getBits() {
51 return (int)$this->row->log_deleted;
54 public function setBits( $bits ) {
55 $dbw = wfGetDB( DB_MASTER );
57 $dbw->update( 'logging',
58 array( 'log_deleted' => $bits ),
59 array(
60 'log_id' => $this->row->log_id,
61 'log_deleted' => $this->getBits() // cas
63 __METHOD__
66 if ( !$dbw->affectedRows() ) {
67 // Concurrent fail!
68 return false;
71 $dbw->update( 'recentchanges',
72 array(
73 'rc_deleted' => $bits,
74 'rc_patrolled' => 1
76 array(
77 'rc_logid' => $this->row->log_id,
78 'rc_timestamp' => $this->row->log_timestamp // index
80 __METHOD__
83 return true;
86 public function getHTML() {
87 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
88 $this->row->log_timestamp, $this->list->getUser() ) );
89 $title = Title::makeTitle( $this->row->log_namespace, $this->row->log_title );
90 $formatter = LogFormatter::newFromRow( $this->row );
91 $formatter->setContext( $this->list->getContext() );
92 $formatter->setAudience( LogFormatter::FOR_THIS_USER );
94 // Log link for this page
95 $loglink = Linker::link(
96 SpecialPage::getTitleFor( 'Log' ),
97 $this->list->msg( 'log' )->escaped(),
98 array(),
99 array( 'page' => $title->getPrefixedText() )
101 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
102 // User links and action text
103 $action = $formatter->getActionText();
104 // Comment
105 $comment = $this->list->getLanguage()->getDirMark()
106 . Linker::commentBlock( $this->row->log_comment );
108 if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) {
109 $comment = '<span class="history-deleted">' . $comment . '</span>';
112 return "<li>$loglink $date $action $comment</li>";
115 public function getApiData( ApiResult $result ) {
116 $logEntry = DatabaseLogEntry::newFromRow( $this->row );
117 $user = $this->list->getUser();
118 $ret = array(
119 'id' => $logEntry->getId(),
120 'type' => $logEntry->getType(),
121 'action' => $logEntry->getSubtype(),
123 $ret += $logEntry->isDeleted( LogPage::DELETED_USER )
124 ? array( 'userhidden' => '' )
125 : array();
126 $ret += $logEntry->isDeleted( LogPage::DELETED_COMMENT )
127 ? array( 'commenthidden' => '' )
128 : array();
129 $ret += $logEntry->isDeleted( LogPage::DELETED_ACTION )
130 ? array( 'actionhidden' => '' )
131 : array();
133 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_ACTION, $user ) ) {
134 $ret['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
136 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) {
137 $ret += array(
138 'userid' => $this->row->log_user,
139 'user' => $this->row->log_user_text,
142 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_COMMENT, $user ) ) {
143 $ret += array(
144 'comment' => $this->row->log_comment,
148 return $ret;