X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Flogging%2FPatrolLog.php;h=4fc76378577b6320132a61762c9bf1f3893bd8e7;hb=03cc82d698acb1eef86c95592e9fc1d1a5deecde;hp=04fdc4f2a648e0c98f88f87b3f7da133ee70c532;hpb=f2553a0c58a27285957d722bb47046abccd4902a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/logging/PatrolLog.php b/includes/logging/PatrolLog.php index 04fdc4f2a6..4fc7637857 100644 --- a/includes/logging/PatrolLog.php +++ b/includes/logging/PatrolLog.php @@ -1,12 +1,31 @@ * @author Niklas Laxström */ + +/** + * Class containing static functions for working with + * logs of patrol events + */ class PatrolLog { /** @@ -14,10 +33,11 @@ class PatrolLog { * * @param $rc Mixed: change identifier or RecentChange object * @param $auto Boolean: was this patrol event automatic? + * @param $performer User: user performing the action or null to use $wgUser * * @return bool */ - public static function record( $rc, $auto = false ) { + public static function record( $rc, $auto = false, User $user = null ) { if ( !$rc instanceof RecentChange ) { $rc = RecentChange::newFromId( $rc ); if ( !is_object( $rc ) ) { @@ -25,19 +45,20 @@ class PatrolLog { } } - $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) ); - if( $title ) { - $entry = new ManualLogEntry( 'patrol', 'patrol' ); - $entry->setTarget( $title ); - $entry->setParameters( self::buildParams( $rc, $auto ) ); - $entry->setPerformer( User::newFromName( $rc->getAttribute( 'rc_user_text' ), false ) ); - $logid = $entry->insert(); - if ( !$auto ) { - $entry->publish( $logid, 'udp' ); - } - return true; + if ( !$user ) { + global $wgUser; + $user = $wgUser; + } + + $entry = new ManualLogEntry( 'patrol', 'patrol' ); + $entry->setTarget( $rc->getTitle() ); + $entry->setParameters( self::buildParams( $rc, $auto ) ); + $entry->setPerformer( $user ); + $logid = $entry->insert(); + if ( !$auto ) { + $entry->publish( $logid, 'udp' ); } - return false; + return true; } /**