Revert r45605 and generalize the ability to have logs go to UDP.
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 9 Jan 2009 18:30:47 +0000 (18:30 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 9 Jan 2009 18:30:47 +0000 (18:30 +0000)
includes/LogPage.php
includes/PatrolLog.php
includes/RecentChange.php

index 3f38301..d3016c0 100644 (file)
@@ -37,7 +37,7 @@ class LogPage {
        /* @access private */
        var $type, $action, $comment, $params, $target, $doer;
        /* @acess public */
-       var $updateRecentChanges;
+       var $updateRecentChanges, $sendToUDP;
 
        /**
          * Constructor
@@ -45,10 +45,12 @@ class LogPage {
          * @param string $type One of '', 'block', 'protect', 'rights', 'delete',
          *               'upload', 'move'
          * @param bool $rc Whether to update recent changes as well as the logging table
+         * @param bool $udp Whether to send to the UDP feed
          */
-       function __construct( $type, $rc = true ) {
+       function __construct( $type, $rc = true, $udp = true ) {
                $this->type = $type;
                $this->updateRecentChanges = $rc;
+               $this->sendToUDP = $udp;
        }
 
        protected function saveContent() {
@@ -85,6 +87,17 @@ class LogPage {
                                RecentChange::notifyLog( $now, $titleObj, $this->doer, $rcComment, '',
                                        $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
                        }
+               } else if( $this->sendToUDP ) {
+                       # Notify external application via UDP.
+                       # We send this to IRC but do not want to add it the RC table.
+                       global $wgRC2UDPAddress, $wgRC2UDPOmitBots;
+                       $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
+                       $rcComment = $this->getRcComment();
+                       $rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $rcComment, '',
+                               $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
+                       if( $wgRC2UDPAddress && ( !$rc->getAttribute('rc_bot') || !$wgRC2UDPOmitBots ) ) {
+                               RecentChange::sendToUDP( $rc->getIRCLine() );
+                       }
                }
                return true;
        }
index 561438e..3b9a369 100644 (file)
@@ -23,14 +23,8 @@ class PatrolLog {
                $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
                if( is_object( $title ) ) {
                        $params = self::buildParams( $rc, $auto );
-                       $log = new LogPage( 'patrol', false ); # False suppresses RC entries
+                       $log = new LogPage( 'patrol', false, true ); # False suppresses RC entries
                        $log->addEntry( 'patrol', $title, '', $params );
-                       # Notify external application via UDP.
-                       # We send this to IRC but do not want to add it the RC table.
-                       global $wgRC2UDPAddress, $wgRC2UDPOmitBots;
-                       if( $wgRC2UDPAddress && ( !$rc->getAttribute('rc_bot') || !$wgRC2UDPOmitBots ) ) {
-                               RecentChange::sendToUDP( $rc->getIRCLine() );
-                       }
                        return true;
                }
                return false;
index 5c6bddd..4a8fa8f 100644 (file)
@@ -475,6 +475,14 @@ class RecentChange
 
        public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='',
           $type, $action, $target, $logComment, $params, $newId=0 )
+       {
+               $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
+                       $target, $logComment, $params, $newId );
+               $rc->save();
+       }
+
+       public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip='',
+          $type, $action, $target, $logComment, $params, $newId=0 )
        {
                global $wgRequest;
 
@@ -518,7 +526,7 @@ class RecentChange
                        'lastTimestamp' => 0,
                        'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
                );
-               $rc->save();
+               return $rc;
        }
 
        # Initialises the members of this object from a mysql row object