MediaWiki  REL1_24
PatrolLog.php
Go to the documentation of this file.
00001 <?php
00029 class PatrolLog {
00039     public static function record( $rc, $auto = false, User $user = null ) {
00040         global $wgLogAutopatrol;
00041 
00042         // do not log autopatrolled edits if setting disables it
00043         if ( $auto && !$wgLogAutopatrol ) {
00044             return false;
00045         }
00046 
00047         if ( !$rc instanceof RecentChange ) {
00048             $rc = RecentChange::newFromId( $rc );
00049             if ( !is_object( $rc ) ) {
00050                 return false;
00051             }
00052         }
00053 
00054         if ( !$user ) {
00055             global $wgUser;
00056             $user = $wgUser;
00057         }
00058 
00059         $entry = new ManualLogEntry( 'patrol', 'patrol' );
00060         $entry->setTarget( $rc->getTitle() );
00061         $entry->setParameters( self::buildParams( $rc, $auto ) );
00062         $entry->setPerformer( $user );
00063         $logid = $entry->insert();
00064         if ( !$auto ) {
00065             $entry->publish( $logid, 'udp' );
00066         }
00067 
00068         return true;
00069     }
00070 
00078     private static function buildParams( $change, $auto ) {
00079         return array(
00080             '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
00081             '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
00082             '6::auto' => (int)$auto
00083         );
00084     }
00085 }