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 canView() {
43 return LogEventsList
::userCan( $this->row
, Revision
::DELETED_RESTRICTED
, $this->list->getUser() );
46 public function canViewContent() {
50 public function getBits() {
51 return $this->row
->log_deleted
;
54 public function setBits( $bits ) {
55 $dbw = wfGetDB( DB_MASTER
);
56 $dbw->update( 'recentchanges', array( 'rc_deleted' => $bits, 'rc_patrolled' => 1 ), array( 'rc_logid' => $this->row
->log_id
, 'rc_timestamp' => $this->row
->log_timestamp
// index
58 $dbw->update( 'logging', array( 'log_deleted' => $bits ), array( 'log_id' => $this->row
->log_id
, 'log_deleted' => $this->getBits() ), __METHOD__
);
60 return (bool) $dbw->affectedRows();
63 public function getHTML() {
64 $date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate( $this->row
->log_timestamp
, $this->list->getUser() ) );
65 $title = Title
::makeTitle( $this->row
->log_namespace
, $this->row
->log_title
);
66 $formatter = LogFormatter
::newFromRow( $this->row
);
67 $formatter->setContext( $this->list->getContext() );
68 $formatter->setAudience( LogFormatter
::FOR_THIS_USER
);
70 // Log link for this page
71 $loglink = Linker
::link( SpecialPage
::getTitleFor( 'Log' ), $this->list->msg( 'log' )->escaped(), array(), array( 'page' => $title->getPrefixedText() ) );
72 $loglink = $this->list->msg( 'parentheses' )->rawParams( $loglink )->escaped();
73 // User links and action text
74 $action = $formatter->getActionText();
76 $comment = $this->list->getLanguage()->getDirMark() . Linker
::commentBlock( $this->row
->log_comment
);
78 if ( LogEventsList
::isDeleted( $this->row
, LogPage
::DELETED_COMMENT
) ) {
79 $comment = '<span class="history-deleted">' . $comment . '</span>';
82 return "<li>$loglink $date $action $comment</li>";
85 public function getApiData( ApiResult
$result ) {
86 $logEntry = DatabaseLogEntry
::newFromRow( $this->row
);
87 $user = $this->list->getUser();
88 $ret = array( 'id' => $logEntry->getId(), 'type' => $logEntry->getType(), 'action' => $logEntry->getSubtype(), );
89 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_USER
) ?
array( 'userhidden' => '' ) : array();
90 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_COMMENT
) ?
array( 'commenthidden' => '' ) : array();
91 $ret +
= $logEntry->isDeleted( LogPage
::DELETED_ACTION
) ?
array( 'actionhidden' => '' ) : array();
93 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_ACTION
, $user ) ) {
94 ApiQueryLogEvents
::addLogParams( $result, $ret, $logEntry->getParameters(), $logEntry->getType(), $logEntry->getSubtype(), $logEntry->getTimestamp(), $logEntry->isLegacy() );
96 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_USER
, $user ) ) {
97 $ret +
= array( 'userid' => $this->row
->log_user
, 'user' => $this->row
->log_user_text
, );
99 if ( LogEventsList
::userCan( $this->row
, LogPage
::DELETED_COMMENT
, $user ) ) {
100 $ret +
= array( 'comment' => $this->row
->log_comment
, );