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
23 * Item class for a logging table row
25 class RevDelLogItem
extends RevDelItem
{
26 public function getIdField() {
30 public function getTimestampField() {
31 return 'log_timestamp';
34 public function getAuthorIdField() {
38 public function getAuthorNameField() {
39 return 'log_user_text';
42 public function getAuthorActorField() {
46 public function canView() {
47 return LogEventsList
::userCan( $this->row
, Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
50 public function canViewContent() {
54 public function getBits() {
55 return (int)$this->row
->log_deleted
;
58 public function setBits( $bits ) {
59 $dbw = wfGetDB( DB_MASTER
);
61 $dbw->update( 'logging',
62 [ 'log_deleted' => $bits ],
64 'log_id' => $this->row
->log_id
,
65 'log_deleted' => $this->getBits() // cas
70 if ( !$dbw->affectedRows() ) {
75 $dbw->update( 'recentchanges',
77 'rc_deleted' => $bits,
78 'rc_patrolled' => RecentChange
::PRC_PATROLLED
81 'rc_logid' => $this->row
->log_id
,
82 'rc_timestamp' => $this->row
->log_timestamp
// index
90 public function getHTML() {
91 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
92 $this->row
->log_timestamp
, $this->list->getUser() ) );
93 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
94 $formatter = LogFormatter
::newFromRow( $this->row
);
95 $formatter->setContext( $this->list->getContext() );
96 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
98 // Log link for this page
99 $loglink = $this->getLinkRenderer()->makeLink(
100 SpecialPage
::getTitleFor( 'Log' ),
101 $this->list->msg( 'log' )->text(),
103 [ 'page' => $title->getPrefixedText() ]
105 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
106 // User links and action text
107 $action = $formatter->getActionText();
109 $comment = CommentStore
::getStore()->getComment( 'log_comment', $this->row
)->text
;
110 $comment = $this->list->getLanguage()->getDirMark()
111 . Linker
::commentBlock( $comment );
113 if ( LogEventsList
::isDeleted( $this->row
, LogPage
::DELETED_COMMENT
) ) {
114 $comment = '<span class="history-deleted">' . $comment . '</span>';
117 return "<li>$loglink $date $action $comment</li>";
120 public function getApiData( ApiResult
$result ) {
121 $logEntry = DatabaseLogEntry
::newFromRow( $this->row
);
122 $user = $this->list->getUser();
124 'id' => $logEntry->getId(),
125 'type' => $logEntry->getType(),
126 'action' => $logEntry->getSubtype(),
127 'userhidden' => (bool)$logEntry->isDeleted( LogPage
::DELETED_USER
),
128 'commenthidden' => (bool)$logEntry->isDeleted( LogPage
::DELETED_COMMENT
),
129 'actionhidden' => (bool)$logEntry->isDeleted( LogPage
::DELETED_ACTION
),
132 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_ACTION
, $user ) ) {
133 $ret['params'] = LogFormatter
::newFromEntry( $logEntry )->formatParametersForApi();
135 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_USER
, $user ) ) {
137 'userid' => $this->row
->log_user
,
138 'user' => $this->row
->log_user_text
,
141 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_COMMENT
, $user ) ) {
143 'comment' => CommentStore
::getStore()->getComment( 'log_comment', $this->row
)