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
19 * @ingroup RevisionDelete
22 use MediaWiki\Storage\RevisionRecord
;
25 * Item class for a logging table row
27 class RevDelLogItem
extends RevDelItem
{
28 public function getIdField() {
32 public function getTimestampField() {
33 return 'log_timestamp';
36 public function getAuthorIdField() {
40 public function getAuthorNameField() {
41 return 'log_user_text';
44 public function getAuthorActorField() {
48 public function canView() {
49 return LogEventsList
::userCan(
50 $this->row
, RevisionRecord
::DELETED_RESTRICTED
, $this->list->getUser()
54 public function canViewContent() {
58 public function getBits() {
59 return (int)$this->row
->log_deleted
;
62 public function setBits( $bits ) {
63 $dbw = wfGetDB( DB_MASTER
);
65 $dbw->update( 'logging',
66 [ 'log_deleted' => $bits ],
68 'log_id' => $this->row
->log_id
,
69 'log_deleted' => $this->getBits() // cas
74 if ( !$dbw->affectedRows() ) {
79 $dbw->update( 'recentchanges',
81 'rc_deleted' => $bits,
82 'rc_patrolled' => RecentChange
::PRC_AUTOPATROLLED
85 'rc_logid' => $this->row
->log_id
,
86 'rc_timestamp' => $this->row
->log_timestamp
// index
94 public function getHTML() {
95 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
96 $this->row
->log_timestamp
, $this->list->getUser() ) );
97 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
98 $formatter = LogFormatter
::newFromRow( $this->row
);
99 $formatter->setContext( $this->list->getContext() );
100 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
102 // Log link for this page
103 $loglink = $this->getLinkRenderer()->makeLink(
104 SpecialPage
::getTitleFor( 'Log' ),
105 $this->list->msg( 'log' )->text(),
107 [ 'page' => $title->getPrefixedText() ]
109 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
110 // User links and action text
111 $action = $formatter->getActionText();
113 $comment = CommentStore
::getStore()->getComment( 'log_comment', $this->row
)->text
;
114 $comment = $this->list->getLanguage()->getDirMark()
115 . Linker
::commentBlock( $comment );
117 if ( LogEventsList
::isDeleted( $this->row
, LogPage
::DELETED_COMMENT
) ) {
118 $comment = '<span class="history-deleted">' . $comment . '</span>';
121 return "<li>$loglink $date $action $comment</li>";
124 public function getApiData( ApiResult
$result ) {
125 $logEntry = DatabaseLogEntry
::newFromRow( $this->row
);
126 $user = $this->list->getUser();
128 'id' => $logEntry->getId(),
129 'type' => $logEntry->getType(),
130 'action' => $logEntry->getSubtype(),
131 'userhidden' => (bool)$logEntry->isDeleted( LogPage
::DELETED_USER
),
132 'commenthidden' => (bool)$logEntry->isDeleted( LogPage
::DELETED_COMMENT
),
133 'actionhidden' => (bool)$logEntry->isDeleted( LogPage
::DELETED_ACTION
),
136 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_ACTION
, $user ) ) {
137 $ret['params'] = LogFormatter
::newFromEntry( $logEntry )->formatParametersForApi();
139 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_USER
, $user ) ) {
141 'userid' => $this->row
->log_user
,
142 'user' => $this->row
->log_user_text
,
145 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_COMMENT
, $user ) ) {
147 'comment' => CommentStore
::getStore()->getComment( 'log_comment', $this->row
)