Separate out an IRC actionText field for RecentChange. The two are currently the...
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 21 Feb 2012 23:39:14 +0000 (23:39 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 21 Feb 2012 23:39:14 +0000 (23:39 +0000)
includes/RecentChange.php
includes/logging/LogPage.php

index 67bc530..bb55808 100644 (file)
@@ -503,10 +503,11 @@ class RecentChange {
         * @param $logComment
         * @param $params
         * @param $newId int
+        * @param $actionCommentIRC string
         * @return bool
         */
-       public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type,
-               $action, $target, $logComment, $params, $newId=0 )
+       public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
+               $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='' )
        {
                global $wgLogRestrictions;
                # Don't add private logs to RC!
@@ -514,7 +515,7 @@ class RecentChange {
                        return false;
                }
                $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
-                       $target, $logComment, $params, $newId );
+                       $target, $logComment, $params, $newId, $actionCommentIRC );
                $rc->save();
                return true;
        }
@@ -531,10 +532,11 @@ class RecentChange {
         * @param $logComment
         * @param $params
         * @param $newId int
+        * @param $actionCommentIRC string
         * @return RecentChange
         */
-       public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip='',
-               $type, $action, $target, $logComment, $params, $newId=0 ) {
+       public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
+               $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='' ) {
                global $wgRequest;
                if( !$ip ) {
                        $ip = $wgRequest->getIP();
@@ -575,6 +577,7 @@ class RecentChange {
                        'prefixedDBkey' => $title->getPrefixedDBkey(),
                        'lastTimestamp' => 0,
                        'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
+                       'actionCommentIRC' => $actionCommentIRC
                );
                return $rc;
        }
@@ -712,7 +715,7 @@ class RecentChange {
 
                if ( $this->mAttribs['rc_type'] == RC_LOG ) {
                        $targetText = $this->getTitle()->getPrefixedText();
-                       $comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionComment'] ) );
+                       $comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionCommentIRC'] ) );
                        $flag = $this->mAttribs['rc_log_action'];
                } else {
                        $comment = self::cleanupForIRC( $this->mAttribs['rc_comment'] );
index 193ff52..53c9b23 100644 (file)
@@ -100,7 +100,7 @@ class LogPage {
                        RecentChange::notifyLog(
                                $now, $titleObj, $this->doer, $this->getRcComment(), '',
                                $this->type, $this->action, $this->target, $this->comment,
-                               $this->params, $newId
+                               $this->params, $newId, $this->getRcCommentIRC()
                        );
                } elseif( $this->sendToUDP ) {
                        # Don't send private logs to UDP
@@ -114,7 +114,7 @@ class LogPage {
                        $rc = RecentChange::newLogEntry(
                                $now, $titleObj, $this->doer, $this->getRcComment(), '',
                                $this->type, $this->action, $this->target, $this->comment,
-                               $this->params, $newId
+                               $this->params, $newId, $this->getRcCommentIRC()
                        );
                        $rc->notifyRC2UDP();
                }
@@ -140,6 +140,25 @@ class LogPage {
                return $rcComment;
        }
 
+       /**
+        * Get the RC comment from the last addEntry() call for IRC
+        *
+        * @return string
+        */
+       public function getRcCommentIRC() {
+               $rcComment = $this->ircActionText;
+
+               if( $this->comment != '' ) {
+                       if ( $rcComment == '' ) {
+                               $rcComment = $this->comment;
+                       } else {
+                               $rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment;
+                       }
+               }
+
+               return $rcComment;
+       }
+
        /**
         * Get the comment from the last addEntry() call
         */
@@ -459,6 +478,7 @@ class LogPage {
                $formatter->setContext( $context );
 
                $this->actionText = $formatter->getPlainActionText();
+               $this->ircActionText = $formatter->getPlainActionText();
 
                return $this->saveContent();
        }