[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Specific methods for the patrol log. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 * http://www.gnu.org/copyleft/gpl.html 19 * 20 * @file 21 * @author Rob Church <[email protected]> 22 * @author Niklas Laxström 23 */ 24 25 /** 26 * Class containing static functions for working with 27 * logs of patrol events 28 */ 29 class PatrolLog { 30 /** 31 * Record a log event for a change being patrolled 32 * 33 * @param int|RecentChange $rc Change identifier or RecentChange object 34 * @param bool $auto Was this patrol event automatic? 35 * @param User $user User performing the action or null to use $wgUser 36 * 37 * @return bool 38 */ 39 public static function record( $rc, $auto = false, User $user = null ) { 40 global $wgLogAutopatrol; 41 42 // do not log autopatrolled edits if setting disables it 43 if ( $auto && !$wgLogAutopatrol ) { 44 return false; 45 } 46 47 if ( !$rc instanceof RecentChange ) { 48 $rc = RecentChange::newFromId( $rc ); 49 if ( !is_object( $rc ) ) { 50 return false; 51 } 52 } 53 54 if ( !$user ) { 55 global $wgUser; 56 $user = $wgUser; 57 } 58 59 $entry = new ManualLogEntry( 'patrol', 'patrol' ); 60 $entry->setTarget( $rc->getTitle() ); 61 $entry->setParameters( self::buildParams( $rc, $auto ) ); 62 $entry->setPerformer( $user ); 63 $logid = $entry->insert(); 64 if ( !$auto ) { 65 $entry->publish( $logid, 'udp' ); 66 } 67 68 return true; 69 } 70 71 /** 72 * Prepare log parameters for a patrolled change 73 * 74 * @param RecentChange $change RecentChange to represent 75 * @param bool $auto Whether the patrol event was automatic 76 * @return array 77 */ 78 private static function buildParams( $change, $auto ) { 79 return array( 80 '4::curid' => $change->getAttribute( 'rc_this_oldid' ), 81 '5::previd' => $change->getAttribute( 'rc_last_oldid' ), 82 '6::auto' => (int)$auto 83 ); 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |