Fix parse error from r111965
[lhc/web/wiklou.git] / includes / logging / PatrolLog.php
1 <?php
2
3 /**
4 * Class containing static functions for working with
5 * logs of patrol events
6 *
7 * @author Rob Church <robchur@gmail.com>
8 * @author Niklas Laxström
9 */
10 class PatrolLog {
11
12 /**
13 * Record a log event for a change being patrolled
14 *
15 * @param $rc Mixed: change identifier or RecentChange object
16 * @param $auto Boolean: was this patrol event automatic?
17 *
18 * @return bool
19 */
20 public static function record( $rc, $auto = false ) {
21 if ( !$rc instanceof RecentChange ) {
22 $rc = RecentChange::newFromId( $rc );
23 if ( !is_object( $rc ) ) {
24 return false;
25 }
26 }
27
28 $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
29 if( $title ) {
30 global $wgUser;
31
32 $entry = new ManualLogEntry( 'patrol', 'patrol' );
33 $entry->setTarget( $title );
34 $entry->setParameters( self::buildParams( $rc, $auto ) );
35 $entry->setPerformer( $wgUser );
36 $logid = $entry->insert();
37 if ( !$auto ) {
38 $entry->publish( $logid, 'udp' );
39 }
40 return true;
41 }
42 return false;
43 }
44
45 /**
46 * Prepare log parameters for a patrolled change
47 *
48 * @param $change RecentChange to represent
49 * @param $auto Boolean: whether the patrol event was automatic
50 * @return Array
51 */
52 private static function buildParams( $change, $auto ) {
53 return array(
54 '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
55 '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
56 '6::auto' => (int)$auto
57 );
58 }
59
60 }