useless call
[lhc/web/wiklou.git] / includes / RecentChange.php
index 48dcf12..2f03675 100644 (file)
@@ -104,7 +104,7 @@ class RecentChange
        # Writes the data in this object to the database
        function save()
        {
-               global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix;
+               global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPort, $wgRC2UDPPrefix, $wgUseRCPatrol;
                $fname = 'RecentChange::save';
 
                $dbw =& wfGetDB( DB_MASTER );
@@ -125,6 +125,11 @@ class RecentChange
                # Insert new row
                $dbw->insert( 'recentchanges', $this->mAttribs, $fname );
 
+               if ( $wgUseRCPatrol ) {
+                       # Retrieve the id assigned by the db, but only if we'll use it later
+                       $this->mAttribs['rc_id'] = $dbw->insertId();
+               }
+
                # Update old rows, if necessary
                if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
                        $oldid = $this->mAttribs['rc_last_oldid'];
@@ -153,8 +158,8 @@ class RecentChange
                        }
 
                        # Update rc_cur_time
-                       $dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
-                               array( 'rc_cur_id' => $curId ), $fname );
+                       #$dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
+                       #       array( 'rc_cur_id' => $curId ), $fname );
                }
 
                # Notify external application via UDP
@@ -194,8 +199,10 @@ class RecentChange
                }
 
                if ( !$ip ) {
-                       global $wgIP;
-                       $ip = empty( $wgIP ) ? '' : $wgIP;
+                       $ip = wfGetIP();
+                       if ( !$ip ) {
+                               $ip = '';
+                       }
                }
 
                $rc = new RecentChange;
@@ -235,8 +242,10 @@ class RecentChange
          $ip='', $size = 0, $newId = 0 )
        {
                if ( !$ip ) {
-                       global $wgIP;
-                       $ip = empty( $wgIP ) ? '' : $wgIP;
+                       $ip = wfGetIP();
+                       if ( !$ip ) {
+                               $ip = '';
+                       }
                }
                if ( $bot == 'default' ) {
                        $bot = $user->isBot();
@@ -277,9 +286,12 @@ class RecentChange
        /*static*/ function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
        {
                if ( !$ip ) {
-                       global $wgIP;
-                       $ip = empty( $wgIP ) ? '' : $wgIP;
+                       $ip = wfGetIP();
+                       if ( !$ip ) {
+                               $ip = '';
+                       }
                }
+
                $rc = new RecentChange;
                $rc->mAttribs = array(
                        'rc_timestamp'  => $timestamp,
@@ -323,9 +335,12 @@ class RecentChange
        /*static*/ function notifyLog( $timestamp, &$title, &$user, $comment, $ip='' )
        {
                if ( !$ip ) {
-                       global $wgIP;
-                       $ip = empty( $wgIP ) ? '' : $wgIP;
+                       $ip = wfGetIP();
+                       if ( !$ip ) {
+                               $ip = '';
+                       }
                }
+
                $rc = new RecentChange;
                $rc->mAttribs = array(
                        'rc_timestamp'  => $timestamp,
@@ -340,7 +355,7 @@ class RecentChange
                        'rc_comment'    => $comment,
                        'rc_this_oldid' => 0,
                        'rc_last_oldid' => 0,
-                       'rc_bot'        => 0,
+                       'rc_bot'        => $user->isBot() ? 1 : 0,
                        'rc_moved_to_ns'        => 0,
                        'rc_moved_to_title'     => '',
                        'rc_ip' => $ip,
@@ -412,6 +427,8 @@ class RecentChange
        }
 
        function getIRCLine() {
+               global $wgUseRCPatrol;
+
                extract($this->mAttribs);
                extract($this->mExtra);
 
@@ -422,8 +439,12 @@ class RecentChange
                $title = $titleObj->getPrefixedText();
                $title = str_replace($bad, $empty, $title);
 
-               if ( $rc_new ) {
+               if ( $rc_new && $wgUseRCPatrol ) {
+                       $url = $titleObj->getFullURL("rcid=$rc_id");
+               } else if ( $rc_new ) {
                        $url = $titleObj->getFullURL();
+               } else if ( $wgUseRCPatrol ) {
+                       $url = $titleObj->getFullURL("diff=0&oldid=$rc_last_oldid&rcid=$rc_id");
                } else {
                        $url = $titleObj->getFullURL("diff=0&oldid=$rc_last_oldid");
                }