MediaWiki  REL1_20
PatrolLog.php
Go to the documentation of this file.
00001 <?php
00029 class PatrolLog {
00030 
00040         public static function record( $rc, $auto = false, User $user = null ) {
00041                 if ( !$rc instanceof RecentChange ) {
00042                         $rc = RecentChange::newFromId( $rc );
00043                         if ( !is_object( $rc ) ) {
00044                                 return false;
00045                         }
00046                 }
00047 
00048                 if ( !$user ) {
00049                         global $wgUser;
00050                         $user = $wgUser;
00051                 }
00052 
00053                 $entry = new ManualLogEntry( 'patrol', 'patrol' );
00054                 $entry->setTarget( $rc->getTitle() );
00055                 $entry->setParameters( self::buildParams( $rc, $auto ) );
00056                 $entry->setPerformer( $user );
00057                 $logid = $entry->insert();
00058                 if ( !$auto ) {
00059                         $entry->publish( $logid, 'udp' );
00060                 }
00061                 return true;
00062         }
00063 
00071         private static function buildParams( $change, $auto ) {
00072                 return array(
00073                         '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
00074                         '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
00075                         '6::auto' => (int)$auto
00076                 );
00077         }
00078 
00079 }