Index: trunk/phase3/includes/PatrolLog.php |
— | — | @@ -1,58 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Class containing static functions for working with |
6 | | - * logs of patrol events |
7 | | - * |
8 | | - * @author Rob Church <robchur@gmail.com> |
9 | | - * @author Niklas Laxström |
10 | | - */ |
11 | | -class PatrolLog { |
12 | | - |
13 | | - /** |
14 | | - * Record a log event for a change being patrolled |
15 | | - * |
16 | | - * @param $rc Mixed: change identifier or RecentChange object |
17 | | - * @param $auto Boolean: was this patrol event automatic? |
18 | | - * |
19 | | - * @return bool |
20 | | - */ |
21 | | - public static function record( $rc, $auto = false ) { |
22 | | - if ( !$rc instanceof RecentChange ) { |
23 | | - $rc = RecentChange::newFromId( $rc ); |
24 | | - if ( !is_object( $rc ) ) { |
25 | | - return false; |
26 | | - } |
27 | | - } |
28 | | - |
29 | | - $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) ); |
30 | | - if( $title ) { |
31 | | - $entry = new ManualLogEntry( 'patrol', 'patrol' ); |
32 | | - $entry->setTarget( $title ); |
33 | | - $entry->setParameters( self::buildParams( $rc, $auto ) ); |
34 | | - $entry->setPerformer( User::newFromName( $rc->getAttribute( 'rc_user_text' ), false ) ); |
35 | | - $logid = $entry->insert(); |
36 | | - if ( !$auto ) { |
37 | | - $entry->publish( $logid, 'udp' ); |
38 | | - } |
39 | | - return true; |
40 | | - } |
41 | | - return false; |
42 | | - } |
43 | | - |
44 | | - /** |
45 | | - * Prepare log parameters for a patrolled change |
46 | | - * |
47 | | - * @param $change RecentChange to represent |
48 | | - * @param $auto Boolean: whether the patrol event was automatic |
49 | | - * @return Array |
50 | | - */ |
51 | | - private static function buildParams( $change, $auto ) { |
52 | | - return array( |
53 | | - '4::curid' => $change->getAttribute( 'rc_this_oldid' ), |
54 | | - '5::previd' => $change->getAttribute( 'rc_last_oldid' ), |
55 | | - '6::auto' => (int)$auto |
56 | | - ); |
57 | | - } |
58 | | - |
59 | | -} |
Index: trunk/phase3/includes/logging/PatrolLog.php |
— | — | @@ -0,0 +1,58 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class containing static functions for working with |
| 6 | + * logs of patrol events |
| 7 | + * |
| 8 | + * @author Rob Church <robchur@gmail.com> |
| 9 | + * @author Niklas Laxström |
| 10 | + */ |
| 11 | +class PatrolLog { |
| 12 | + |
| 13 | + /** |
| 14 | + * Record a log event for a change being patrolled |
| 15 | + * |
| 16 | + * @param $rc Mixed: change identifier or RecentChange object |
| 17 | + * @param $auto Boolean: was this patrol event automatic? |
| 18 | + * |
| 19 | + * @return bool |
| 20 | + */ |
| 21 | + public static function record( $rc, $auto = false ) { |
| 22 | + if ( !$rc instanceof RecentChange ) { |
| 23 | + $rc = RecentChange::newFromId( $rc ); |
| 24 | + if ( !is_object( $rc ) ) { |
| 25 | + return false; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) ); |
| 30 | + if( $title ) { |
| 31 | + $entry = new ManualLogEntry( 'patrol', 'patrol' ); |
| 32 | + $entry->setTarget( $title ); |
| 33 | + $entry->setParameters( self::buildParams( $rc, $auto ) ); |
| 34 | + $entry->setPerformer( User::newFromName( $rc->getAttribute( 'rc_user_text' ), false ) ); |
| 35 | + $logid = $entry->insert(); |
| 36 | + if ( !$auto ) { |
| 37 | + $entry->publish( $logid, 'udp' ); |
| 38 | + } |
| 39 | + return true; |
| 40 | + } |
| 41 | + return false; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Prepare log parameters for a patrolled change |
| 46 | + * |
| 47 | + * @param $change RecentChange to represent |
| 48 | + * @param $auto Boolean: whether the patrol event was automatic |
| 49 | + * @return Array |
| 50 | + */ |
| 51 | + private static function buildParams( $change, $auto ) { |
| 52 | + return array( |
| 53 | + '4::curid' => $change->getAttribute( 'rc_this_oldid' ), |
| 54 | + '5::previd' => $change->getAttribute( 'rc_last_oldid' ), |
| 55 | + '6::auto' => (int)$auto |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | +} |
Property changes on: trunk/phase3/includes/logging/PatrolLog.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 60 | + native |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -164,7 +164,6 @@ |
165 | 165 | 'PageQueryPage' => 'includes/PageQueryPage.php', |
166 | 166 | 'Pager' => 'includes/Pager.php', |
167 | 167 | 'PasswordError' => 'includes/User.php', |
168 | | - 'PatrolLog' => 'includes/PatrolLog.php', |
169 | 168 | 'PermissionsError' => 'includes/Exception.php', |
170 | 169 | 'PhpHttpRequest' => 'includes/HttpFunctions.php', |
171 | 170 | 'PoolCounter' => 'includes/PoolCounter.php', |
— | — | @@ -538,16 +537,17 @@ |
539 | 538 | 'JSParser' => 'includes/libs/jsminplus.php', |
540 | 539 | |
541 | 540 | # includes/logging |
| 541 | + 'DatabaseLogEntry' => 'includes/logging/LogEntry.php', |
| 542 | + 'DeleteLogFormatter' => 'includes/logging/LogFormatter.php', |
| 543 | + 'LegacyLogFormatter' => 'includes/logging/LogFormatter.php', |
542 | 544 | 'LogEntry' => 'includes/logging/LogEntry.php', |
543 | 545 | 'LogEntryBase' => 'includes/logging/LogEntry.php', |
544 | | - 'DatabaseLogEntry' => 'includes/logging/LogEntry.php', |
545 | | - 'RCDatabaseLogEntry' => 'includes/logging/LogEntry.php', |
| 546 | + 'LogFormatter' => 'includes/logging/LogFormatter.php', |
546 | 547 | 'ManualLogEntry' => 'includes/logging/LogEntry.php', |
547 | | - 'LogFormatter' => 'includes/logging/LogFormatter.php', |
548 | | - 'LegacyLogFormatter' => 'includes/logging/LogFormatter.php', |
549 | | - 'DeleteLogFormatter' => 'includes/logging/LogFormatter.php', |
550 | 548 | 'MoveLogFormatter' => 'includes/logging/LogFormatter.php', |
| 549 | + 'PatrolLog' => 'includes/logging/PatrolLog.php', |
551 | 550 | 'PatrolLogFormatter' => 'includes/logging/LogFormatter.php', |
| 551 | + 'RCDatabaseLogEntry' => 'includes/logging/LogEntry.php', |
552 | 552 | |
553 | 553 | # includes/media |
554 | 554 | 'BitmapHandler' => 'includes/media/Bitmap.php', |