API: added query parameter indexpageids to list the page ids of all returned page...
[lhc/web/wiklou.git] / includes / LogPage.php
index a0b45e7..b8ef781 100644 (file)
@@ -21,7 +21,6 @@
 /**
  * Contain log classes
  *
- * @package MediaWiki
  */
 
 /**
@@ -29,7 +28,6 @@
  * The logs are now kept in a table which is easier to manage and trim
  * than ever-growing wiki pages.
  *
- * @package MediaWiki
  */
 class LogPage {
        /* @access private */
@@ -44,7 +42,7 @@ class LogPage {
          *               'upload', 'move'
          * @param bool $rc Whether to update recent changes as well as the logging table
          */
-       function LogPage( $type, $rc = true ) {
+       function __construct( $type, $rc = true ) {
                $this->type = $type;
                $this->updateRecentChanges = $rc;
        }
@@ -55,23 +53,29 @@ class LogPage {
                global $wgUser;
                $fname = 'LogPage::saveContent';
 
-               $dbw =& wfGetDB( DB_MASTER );
+               $dbw = wfGetDB( DB_MASTER );
                $uid = $wgUser->getID();
+               $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' );
 
                $this->timestamp = $now = wfTimestampNow();
-               $dbw->insert( 'logging',
-                       array(
-                               'log_type' => $this->type,
-                               'log_action' => $this->action,
-                               'log_timestamp' => $dbw->timestamp( $now ),
-                               'log_user' => $uid,
-                               'log_namespace' => $this->target->getNamespace(),
-                               'log_title' => $this->target->getDBkey(),
-                               'log_comment' => $this->comment,
-                               'log_params' => $this->params
-                       ), $fname
+               $data = array(
+                       'log_type' => $this->type,
+                       'log_action' => $this->action,
+                       'log_timestamp' => $dbw->timestamp( $now ),
+                       'log_user' => $uid,
+                       'log_namespace' => $this->target->getNamespace(),
+                       'log_title' => $this->target->getDBkey(),
+                       'log_comment' => $this->comment,
+                       'log_params' => $this->params
                );
 
+               # log_id doesn't exist on Wikimedia servers yet, and it's a tricky 
+               # schema update to do. Hack it for now to ignore the field on MySQL.
+               if ( !is_null( $log_id ) ) {
+                       $data['log_id'] = $log_id;
+               }
+               $dbw->insert( 'logging', $data, $fname );
+
                # And update recentchanges
                if ( $this->updateRecentChanges ) {
                        $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
@@ -92,7 +96,7 @@ class LogPage {
        /**
         * @static
         */
-       function validTypes() {
+       public static function validTypes() {
                global $wgLogTypes;
                return $wgLogTypes;
        }
@@ -100,7 +104,7 @@ class LogPage {
        /**
         * @static
         */
-       function isLogType( $type ) {
+       public static function isLogType( $type ) {
                return in_array( $type, LogPage::validTypes() );
        }
 
@@ -119,10 +123,10 @@ class LogPage {
        }
 
        /**
-        * @fixme: handle missing log types
+        * @todo handle missing log types
         * @static
         */
-       function logHeader( $type ) {
+       static function logHeader( $type ) {
                global $wgLogHeaders;
                return wfMsg( $wgLogHeaders[$type] );
        }
@@ -130,10 +134,14 @@ class LogPage {
        /**
         * @static
         */
-       function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) {
+       static function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) {
                global $wgLang, $wgContLang, $wgLogActions;
 
                $key = "$type/$action";
+               
+               if( $key == 'patrol/patrol' )
+                       return PatrolLog::makeActionText( $title, $params, $skin );
+               
                if( isset( $wgLogActions[$key] ) ) {
                        if( is_null( $title ) ) {
                                $rv=wfMsg( $wgLogActions[$key] );
@@ -183,8 +191,10 @@ class LogPage {
                                        }
                                } else {
                                        array_unshift( $params, $titleLink );
-                                       if ( $translate && $key == 'block/block' ) {
-                                               $params[1] = $wgLang->translateBlockExpiry( $params[1] );
+                                       if ( $key == 'block/block' ) {
+                                               if ( $translate ) {
+                                                       $params[1] = $wgLang->translateBlockExpiry( $params[1] );
+                                               }
                                                $params[2] = isset( $params[2] )
                                                                                ? self::formatBlockFlags( $params[2] )
                                                                                : '';
@@ -229,7 +239,7 @@ class LogPage {
         * Create a blob from a parameter array
         * @static
         */
-       function makeParamBlob( $params ) {
+       static function makeParamBlob( $params ) {
                return implode( "\n", $params );
        }
 
@@ -237,7 +247,7 @@ class LogPage {
         * Extract a parameter array from a blob
         * @static
         */
-       function extractParams( $blob ) {
+       static function extractParams( $blob ) {
                if ( $blob === '' ) {
                        return array();
                } else {