thumb_handler.php doesn't seem to extract path_info correctly
[mediawiki.git] / includes / logging / PatrolLog.php
blobbb76d5a9596ffd1d213daa8444b87367f6c03726
1 <?php
2 /**
3 * Specific methods for the patrol log.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @author Rob Church <robchur@gmail.com>
22 * @author Niklas Laxström
25 /**
26 * Class containing static functions for working with
27 * logs of patrol events
29 class PatrolLog {
31 /**
32 * Record a log event for a change being patrolled
34 * @param $rc Mixed: change identifier or RecentChange object
35 * @param $auto Boolean: was this patrol event automatic?
36 * @param $user User: user performing the action or null to use $wgUser
38 * @return bool
40 public static function record( $rc, $auto = false, User $user = null ) {
41 global $wgLogAutopatrol;
43 // do not log autopatrolled edits if setting disables it
44 if ( $auto && !$wgLogAutopatrol ) {
45 return false;
48 if ( !$rc instanceof RecentChange ) {
49 $rc = RecentChange::newFromId( $rc );
50 if ( !is_object( $rc ) ) {
51 return false;
55 if ( !$user ) {
56 global $wgUser;
57 $user = $wgUser;
60 $entry = new ManualLogEntry( 'patrol', 'patrol' );
61 $entry->setTarget( $rc->getTitle() );
62 $entry->setParameters( self::buildParams( $rc, $auto ) );
63 $entry->setPerformer( $user );
64 $logid = $entry->insert();
65 if ( !$auto ) {
66 $entry->publish( $logid, 'udp' );
68 return true;
71 /**
72 * Prepare log parameters for a patrolled change
74 * @param $change RecentChange to represent
75 * @param $auto Boolean: whether the patrol event was automatic
76 * @return Array
78 private static function buildParams( $change, $auto ) {
79 return array(
80 '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
81 '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
82 '6::auto' => (int)$auto