MediaWiki REL1_35
RevDelLogItem.php
Go to the documentation of this file.
1<?php
23
28 public function getIdField() {
29 return 'log_id';
30 }
31
32 public function getTimestampField() {
33 return 'log_timestamp';
34 }
35
36 public function getAuthorIdField() {
37 return 'log_user';
38 }
39
40 public function getAuthorNameField() {
41 return 'log_user_text';
42 }
43
44 public function getAuthorActorField() {
45 return 'log_actor';
46 }
47
48 public function canView() {
49 return LogEventsList::userCan(
50 $this->row, RevisionRecord::DELETED_RESTRICTED, $this->list->getUser()
51 );
52 }
53
54 public function canViewContent() {
55 return true; // none
56 }
57
58 public function getBits() {
59 return (int)$this->row->log_deleted;
60 }
61
62 public function setBits( $bits ) {
63 $dbw = wfGetDB( DB_MASTER );
64
65 $dbw->update( 'logging',
66 [ 'log_deleted' => $bits ],
67 [
68 'log_id' => $this->row->log_id,
69 'log_deleted' => $this->getBits() // cas
70 ],
71 __METHOD__
72 );
73
74 if ( !$dbw->affectedRows() ) {
75 // Concurrent fail!
76 return false;
77 }
78
79 $dbw->update( 'recentchanges',
80 [
81 'rc_deleted' => $bits,
82 'rc_patrolled' => RecentChange::PRC_AUTOPATROLLED
83 ],
84 [
85 'rc_logid' => $this->row->log_id,
86 'rc_timestamp' => $this->row->log_timestamp // index
87 ],
88 __METHOD__
89 );
90
91 return true;
92 }
93
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 );
101
102 // Log link for this page
103 $loglink = $this->getLinkRenderer()->makeLink(
105 $this->list->msg( 'log' )->text(),
106 [],
107 [ 'page' => $title->getPrefixedText() ]
108 );
109 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
110 // User links and action text
111 $action = $formatter->getActionText();
112
113 $comment = CommentStore::getStore()->getComment( 'log_comment', $this->row )->text;
114 $comment = $this->list->getLanguage()->getDirMark()
115 . Linker::commentBlock( $comment );
116
117 if ( LogEventsList::isDeleted( $this->row, LogPage::DELETED_COMMENT ) ) {
118 $comment = '<span class="history-deleted">' . $comment . '</span>';
119 }
120
121 return "<li>$loglink $date $action $comment</li>";
122 }
123
124 public function getApiData( ApiResult $result ) {
125 $logEntry = DatabaseLogEntry::newFromRow( $this->row );
126 $user = $this->list->getUser();
127 $ret = [
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 ),
134 ];
135
136 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_ACTION, $user ) ) {
137 $ret['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
138 }
139 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) {
140 $ret += [
141 'userid' => $this->row->log_user,
142 'user' => $this->row->log_user_text,
143 ];
144 }
145 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_COMMENT, $user ) ) {
146 $ret += [
147 'comment' => CommentStore::getStore()->getComment( 'log_comment', $this->row )
148 ->text,
149 ];
150 }
151
152 return $ret;
153 }
154}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
This class represents the result of the API operations.
Definition ApiResult.php:35
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition Linker.php:1584
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
static newFromEntry(LogEntry $entry)
Constructs a new formatter suitable for given entry.
const FOR_THIS_USER
const DELETED_USER
Definition LogPage.php:40
const DELETED_COMMENT
Definition LogPage.php:39
const DELETED_ACTION
Definition LogPage.php:38
Page revision base class.
Abstract base class for deletable items.
Item class for a logging table row.
getAuthorActorField()
Get the DB field name storing actor ids.
getIdField()
Get the DB field name associated with the ID list.
getBits()
Get the current deletion bitfield value.
getAuthorNameField()
Get the DB field name storing user names.
setBits( $bits)
Set the visibility of the item.
canViewContent()
Returns true if the current user can view the item text/file.
getHTML()
Get the HTML of the list item.
canView()
Returns true if the current user can view the item.
getAuthorIdField()
Get the DB field name storing user ids.
getApiData(ApiResult $result)
Get the return information about the revision for the API.
getTimestampField()
Get the DB field name storing timestamps.
getLinkRenderer()
Returns an instance of LinkRenderer.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
const DB_MASTER
Definition defines.php:29