Note incorrect docs in DefaultSettings.php
[lhc/web/wiklou.git] / includes / LogPage.php
index 80280fb..d8dca6e 100644 (file)
@@ -45,17 +45,16 @@ 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
+         * @param bool $udp Whether to send to the UDP feed if NOT sent to RC
          */
-       function __construct( $type, $rc = true, $udp = true ) {
+       public function __construct( $type, $rc = true, $udp = 'skipUDP' ) {
                $this->type = $type;
                $this->updateRecentChanges = $rc;
-               $this->sendToUDP = $udp;
+               $this->sendToUDP = ($udp == 'UDP');
        }
 
        protected function saveContent() {
-               global $wgUser, $wgLogRestrictions;
-               $fname = 'LogPage::saveContent';
+               global $wgLogRestrictions;
 
                $dbw = wfGetDB( DB_MASTER );
                $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
@@ -72,29 +71,25 @@ class LogPage {
                        'log_comment' => $this->comment,
                        'log_params' => $this->params
                );
-               $dbw->insert( 'logging', $data, $fname );
+               $dbw->insert( 'logging', $data, __METHOD__ );
                $newId = !is_null($log_id) ? $log_id : $dbw->insertId();
 
-               if( !($dbw->affectedRows() > 0) ) {
-                       wfDebugLog( "logging", "LogPage::saveContent failed to insert row - Error {$dbw->lastErrno()}: {$dbw->lastError()}" );
-               }
                # And update recentchanges
                if( $this->updateRecentChanges ) {
                        $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
-                       $rcComment = $this->getRcComment();
-                       RecentChange::notifyLog( $now, $titleObj, $this->doer, $rcComment, '', $this->type,
+                       RecentChange::notifyLog( $now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type,
                                $this->action, $this->target, $this->comment, $this->params, $newId );
                } else if( $this->sendToUDP ) {
+                       # Don't send private logs to UDP
+                       if( isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] !='*' ) {
+                               return true;
+                       }
                        # 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, '',
+                       $rc = RecentChange::newLogEntry( $now, $titleObj, $this->doer, $this->getRcComment(), '',
                                $this->type, $this->action, $this->target, $this->comment, $this->params, $newId );
-                       if( $wgRC2UDPAddress && ( !$rc->getAttribute('rc_bot') || !$wgRC2UDPOmitBots ) ) {
-                               RecentChange::sendToUDP( $rc->getIRCLine() );
-                       }
+                       $rc->notifyRC2UDP();
                }
                return true;
        }
@@ -155,7 +150,7 @@ class LogPage {
         * @param string $type logtype
         * @return string Headertext of this logtype
         */
-       static function logHeader( $type ) {
+       public static function logHeader( $type ) {
                global $wgLogHeaders, $wgMessageCache;
                $wgMessageCache->loadAllMessages();
                return wfMsgExt($wgLogHeaders[$type],array('parseinline'));
@@ -165,7 +160,7 @@ class LogPage {
         * @static
         * @return HTML string
         */
-       static function actionText( $type, $action, $title = NULL, $skin = NULL, 
+       public static function actionText( $type, $action, $title = NULL, $skin = NULL, 
                $params = array(), $filterWikilinks = false ) 
        {
                global $wgLang, $wgContLang, $wgLogActions, $wgMessageCache;
@@ -218,11 +213,19 @@ class LogPage {
                                        } else if ( $type == 'protect' && count($params) == 3 ) {
                                                $details .= " {$params[1]}"; // restrictions and expiries
                                                if( $params[2] ) {
-                                                       $details .= ' ['.wfMsg('protect-summary-cascade').']';
+                                                       if ( $skin ) {
+                                                               $details .= ' ['.wfMsg('protect-summary-cascade').']';
+                                                       } else {
+                                                               $details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
+                                                       }
                                                }
                                        } else if ( $type == 'move' && count( $params ) == 3 ) {
                                                if( $params[2] ) {
-                                                       $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
+                                                       if ( $skin ) {
+                                                               $details .= ' [' . wfMsg( 'move-redirect-suppressed' ) . ']';
+                                                       } else {
+                                                               $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
+                                                       }
                                                }
                                        }
                                        $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
@@ -306,7 +309,7 @@ class LogPage {
         * @param array $params Parameters passed later to wfMsg.* functions
         * @param User $doer The user doing the action
         */
-       function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
+       public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
                if ( !is_array( $params ) ) {
                        $params = array( $params );
                }
@@ -334,7 +337,7 @@ class LogPage {
         * Create a blob from a parameter array
         * @static
         */
-       static function makeParamBlob( $params ) {
+       public static function makeParamBlob( $params ) {
                return implode( "\n", $params );
        }
 
@@ -342,7 +345,7 @@ class LogPage {
         * Extract a parameter array from a blob
         * @static
         */
-       static function extractParams( $blob ) {
+       public static function extractParams( $blob ) {
                if ( $blob === '' ) {
                        return array();
                } else {