4 * Class containing static functions for working with
5 * logs of patrol events
7 * @author Rob Church <robchur@gmail.com>
8 * @author Niklas Laxström
13 * Record a log event for a change being patrolled
15 * @param $rc Mixed: change identifier or RecentChange object
16 * @param $auto Boolean: was this patrol event automatic?
17 * @param $performer User: user performing the action or null to use $wgUser
21 public static function record( $rc, $auto = false, User
$user = null ) {
22 if ( !$rc instanceof RecentChange
) {
23 $rc = RecentChange
::newFromId( $rc );
24 if ( !is_object( $rc ) ) {
29 $title = Title
::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
36 $entry = new ManualLogEntry( 'patrol', 'patrol' );
37 $entry->setTarget( $title );
38 $entry->setParameters( self
::buildParams( $rc, $auto ) );
39 $entry->setPerformer( $user );
40 $logid = $entry->insert();
42 $entry->publish( $logid, 'udp' );
50 * Prepare log parameters for a patrolled change
52 * @param $change RecentChange to represent
53 * @param $auto Boolean: whether the patrol event was automatic
56 private static function buildParams( $change, $auto ) {
58 '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
59 '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
60 '6::auto' => (int)$auto