MediaWiki REL1_31
RevDelLogItem.php
Go to the documentation of this file.
1<?php
26 public function getIdField() {
27 return 'log_id';
28 }
29
30 public function getTimestampField() {
31 return 'log_timestamp';
32 }
33
34 public function getAuthorIdField() {
35 return 'log_user';
36 }
37
38 public function getAuthorNameField() {
39 return 'log_user_text';
40 }
41
42 public function getAuthorActorField() {
43 return 'log_actor';
44 }
45
46 public function canView() {
47 return LogEventsList::userCan( $this->row, Revision::DELETED_RESTRICTED, $this->list->getUser() );
48 }
49
50 public function canViewContent() {
51 return true; // none
52 }
53
54 public function getBits() {
55 return (int)$this->row->log_deleted;
56 }
57
58 public function setBits( $bits ) {
59 $dbw = wfGetDB( DB_MASTER );
60
61 $dbw->update( 'logging',
62 [ 'log_deleted' => $bits ],
63 [
64 'log_id' => $this->row->log_id,
65 'log_deleted' => $this->getBits() // cas
66 ],
67 __METHOD__
68 );
69
70 if ( !$dbw->affectedRows() ) {
71 // Concurrent fail!
72 return false;
73 }
74
75 $dbw->update( 'recentchanges',
76 [
77 'rc_deleted' => $bits,
78 'rc_patrolled' => RecentChange::PRC_PATROLLED
79 ],
80 [
81 'rc_logid' => $this->row->log_id,
82 'rc_timestamp' => $this->row->log_timestamp // index
83 ],
84 __METHOD__
85 );
86
87 return true;
88 }
89
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 );
97
98 // Log link for this page
99 $loglink = $this->getLinkRenderer()->makeLink(
100 SpecialPage::getTitleFor( 'Log' ),
101 $this->list->msg( 'log' )->text(),
102 [],
103 [ 'page' => $title->getPrefixedText() ]
104 );
105 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
106 // User links and action text
107 $action = $formatter->getActionText();
108 // Comment
109 $comment = CommentStore::getStore()->getComment( 'log_comment', $this->row )->text;
110 $comment = $this->list->getLanguage()->getDirMark()
111 . Linker::commentBlock( $comment );
112
114 $comment = '<span class="history-deleted">' . $comment . '</span>';
115 }
116
117 return "<li>$loglink $date $action $comment</li>";
118 }
119
120 public function getApiData( ApiResult $result ) {
121 $logEntry = DatabaseLogEntry::newFromRow( $this->row );
122 $user = $this->list->getUser();
123 $ret = [
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 ),
130 ];
131
132 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_ACTION, $user ) ) {
133 $ret['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi();
134 }
135 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_USER, $user ) ) {
136 $ret += [
137 'userid' => $this->row->log_user,
138 'user' => $this->row->log_user_text,
139 ];
140 }
141 if ( LogEventsList::userCan( $this->row, LogPage::DELETED_COMMENT, $user ) ) {
142 $ret += [
143 'comment' => CommentStore::getStore()->getComment( 'log_comment', $this->row )
144 ->text,
145 ];
146 }
147
148 return $ret;
149 }
150}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
This class represents the result of the API operations.
Definition ApiResult.php:33
static newFromRow( $row)
Constructs new LogEntry from database result row.
Definition LogEntry.php:207
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Definition Linker.php:1455
static userCan( $row, $field, User $user=null)
Determine if the current user is allowed to view a particular field of this log row,...
static isDeleted( $row, $field)
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:34
const DELETED_COMMENT
Definition LogPage.php:33
const DELETED_ACTION
Definition LogPage.php:32
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.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2005
const DB_MASTER
Definition defines.php:29