elaborate fix for bug 1156: Block log: missing expiry time. Changed schema for loggin...
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 14 Jan 2005 13:47:19 +0000 (13:47 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 14 Jan 2005 13:47:19 +0000 (13:47 +0000)
includes/LogPage.php
includes/SpecialBlockip.php
includes/SpecialLog.php
maintenance/archives/patch-log_params.sql [new file with mode: 0644]
maintenance/tables.sql

index fbe245a..373e9a1 100644 (file)
@@ -32,7 +32,7 @@
  * @package MediaWiki
  */
 class LogPage {
-       /* private */ var $type, $action, $comment;
+       /* private */ var $type, $action, $comment, $params;
        var $updateRecentChanges = true;
 
        function LogPage( $type ) {
@@ -58,7 +58,8 @@ class LogPage {
                                'log_user' => $uid,
                                'log_namespace' => $this->target->getNamespace(),
                                'log_title' => $this->target->getDBkey(),
-                               'log_comment' => $this->comment
+                               'log_comment' => $this->comment,
+                               'log_params' => $this->params
                        ), $fname
                );
                
@@ -137,7 +138,7 @@ class LogPage {
        /**
         * @static
         */
-       function actionText( $type, $action, $titleLink = NULL ) {
+       function actionText( $type, $action, $titleLink = NULL, $params = array() ) {
                static $actions = array(
                        'block/block' => 'blocklogentry',
                        'block/unblock' => 'unblocklogentry',
@@ -152,9 +153,12 @@ class LogPage {
                $key = "$type/$action";
                if( isset( $actions[$key] ) ) {
                        if( is_null( $titleLink ) ) {
-                               return wfMsg( $actions[$key] );
+                               return wfMsgForContent( $actions[$key] );
+                       } elseif ( count( $params ) == 0 ) {
+                               return wfMsgForContent( $actions[$key], $titleLink );
                        } else {
-                               return wfMsg( $actions[$key], $titleLink );
+                               array_unshift( $params, $titleLink );
+                               return wfMsgReal( $actions[$key], $params, true, true );
                        }
                } else {
                        wfDebug( "LogPage::actionText - unknown action $key\n" );
@@ -168,17 +172,44 @@ class LogPage {
         * @param &$target
         * @param string $comment Description associated
         */
-       function addEntry( $action, &$target, $comment ) {
+       function addEntry( $action, &$target, $comment, $params = array() ) {
                global $wgLang, $wgUser;
                
+               if ( !is_array( $params ) ) {
+                       $params = array( $params );
+               }
+               
                $this->action = $action;
                $this->target =& $target;
                $this->comment = $comment;
-               $this->actionText = LogPage::actionText( $this->type, $action,
-                       $target->getPrefixedText() );
-                               
+               $this->params = LogPage::makeParamBlob( $params );
+               
+               $this->actionText = LogPage::actionText( $this->type, $action, 
+                 $target->getPrefixedText(), $params );
                return $this->saveContent();
        }
+
+       /** 
+        * Create a blob from a parameter array
+        * @static
+        */
+       function makeParamBlob( $params )
+       {
+               return implode( "\n", $params );
+       }
+
+       /**
+        * Extract a parameter array from a blob
+        * @static
+        */
+       function extractParams( $blob )
+       {
+               if ( $blob === '' ) {
+                       return array();
+               } else {
+                       return explode( "\n", $blob );
+               }
+       }
 }
 
 ?>
index 9c698f5..e95f8aa 100644 (file)
@@ -170,7 +170,8 @@ class IPBlockForm {
                        
                        # Make log entry
                        $log = new LogPage( 'block' );
-                       $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), $this->BlockReason );
+                       $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), 
+                         $this->BlockReason, $this->BlockExpiry );
 
                        # Report to the user
                        $titleObj = Title::makeTitle( NS_SPECIAL, 'Blockip' );
index 1e0a193..4481d02 100644 (file)
@@ -146,7 +146,7 @@ class LogReader {
                $sql = "SELECT log_type, log_action, log_timestamp,
                        log_user, user_name,
                        log_namespace, log_title, page_id,
-                       log_comment FROM $user, $logging ";
+                       log_comment, log_params FROM $user, $logging ";
                if( !empty( $this->joinClauses ) ) {
                        $sql .= implode( ',', $this->joinClauses );
                }
@@ -261,8 +261,9 @@ class LogViewer {
                } else {
                        $comment = '(<em>' . $this->skin->formatComment( $s->log_comment ) . '</em>)';
                }
+               $paramArray = LogPage::extractParams( $s->log_params );
                
-               $action = LogPage::actionText( $s->log_type, $s->log_action, $titleLink );
+               $action = LogPage::actionText( $s->log_type, $s->log_action, $titleLink, $paramArray );
                $out = "<li>$time $userLink $action $comment</li>\n";
                return $out;
        }
diff --git a/maintenance/archives/patch-log_params.sql b/maintenance/archives/patch-log_params.sql
new file mode 100644 (file)
index 0000000..aa00a67
--- /dev/null
@@ -0,0 +1 @@
+ALTER TABLE /*$wgDBprefix*/logging ADD log_params blob NOT NULL default '';
index 9ddddb7..1935fcc 100644 (file)
@@ -333,6 +333,9 @@ CREATE TABLE /*$wgDBprefix*/logging (
   -- Freeform text. Interpreted as edit history comments.
   log_comment varchar(255) NOT NULL default '',
   
+  -- LF separated list of miscellaneous parameters
+  log_params blob NOT NULL default '',
+
   KEY type_time (log_type, log_timestamp),
   KEY user_time (log_user, log_timestamp),
   KEY page_time (log_namespace, log_title, log_timestamp)