r811: More logging... man this must be bad for the environment. End deforestation...
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 10 May 2006 02:21:50 +0000 (02:21 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 10 May 2006 02:21:50 +0000 (02:21 +0000)
editreport.php
includes/class_logging.php

index 2c1726ab115d87bd5e0d0a009d8c784a9eb9d3de..daaaf78068bc9aa9124b4b0265c42d85e48cd7d4 100644 (file)
@@ -147,7 +147,12 @@ if ($_POST['do'] == 'update')
        // do update stuff
        $pcv = parse_pcv_select($bugsys->in['pcv_select'], true);
        
-       $hist2[0] = (array)$temp = $noinitialcustom = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
+       $nocustomfields = true;
+       if ($fields = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]"))
+       {
+               $nocustomfields = false;
+               $log2->add_data(true, $fields, array('bugid'), true, 'custom', 'custom');
+       }
        
        // -------------------------------------------------------------------
        // start updates
@@ -178,65 +183,14 @@ if ($_POST['do'] == 'update')
        }
        
        $log2->add_data(false, $bugapi->values, $bugfields);
-       print_r($log2); exit;
        
-       $bugapi->update();
+       
+       //$bugapi->update();
        
        // -------------------------------------------------------------------
        // do diff history
        
-       $hist2[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
-       
-       $diff[0] = array_diff_assoc($bugapi->objdata, $bugapi->values);
-       $diff[1] = array_diff_assoc($bugapi->values, $bugapi->objdata);
-       
-       $lookupindex = array(
-               'status' => 'status',
-               'severity' => 'severity',
-               'priority' => 'priority',
-               'versionid' => 'version',
-               'assignedto' => 'assignto',
-               'resolution' => 'resolution',
-               'productid' => 'product',
-               'componentid' => 'product'
-       );
-               
-       foreach ($diff AS $num => $diffs)
-       {
-               foreach ($diffs AS $key => $value)
-               {
-                       if (!isset($lookupindex["$key"]))
-                       {
-                               continue;
-                       }
-                       
-                       $ref = $lookupindex["$key"];
-                       $temp =& $bugsys->datastore["$ref"]["$value"];
-                       $thevalue = $temp["$ref"];
-                       $idbit = ' (id: ' . $temp["$ref" . 'id'] . ')';
-                       
-                       if ($key == 'assignedto')
-                       {
-                               $thevalue = (($temp['userid']) ? construct_user_display($temp) : '');
-                               $idbit = '';
-                       }
-                       else if ($key == 'productid' OR $key == 'componentid')
-                       {
-                               $ref = 'product';
-                               $thevalue = $temp['title'];
-                       }
-                       
-                       $diff["$num"]["$key"] = (($thevalue) ? $thevalue . $idbit : '');
-               }
-       }
-       
-       foreach ($diff[1] AS $key => $value)
-       {
-               $log->log($log->diff($key, $diff[0]["$key"], $diff[1]["$key"]));
-       }
-       
-       $diff2[0] = array_diff_assoc($hist2[0], $hist2[1]);
-       $diff2[1] = array_diff_assoc($hist2[1], $hist2[0]);
+       $hist[1] = (array)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill WHERE bugid = $bug[bugid]");
        
        if ($noinitialcustom === false)
        {
@@ -248,26 +202,9 @@ if ($_POST['do'] == 'update')
                }
        }
        
-       foreach ($diff2[1] AS $key => $value)
-       {
-               if (in_array($key, $boxlist) AND $canallowempty)
-               {
-                       $log->allowempty = true;
-               }
-               else
-               {
-                       $log->allowempty = false;
-               }
-               
-               if ($key == 'bugid')
-               {
-                       continue;
-               }
-               
-               $log->log($log->diff('custom_' . $key, $diff2[0]["$key"], $diff2[1]["$key"]));
-       }
+       $log2->add_data(false, $hist[1], array('bugid'), true, 'custom', 'custom');
        
-       $log->allowempty = false;
+       print_r($log2); exit;
        
        $message->redirect($lang->string('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
 }
index 66e3949a0ca1b85e3cd97ef733620fce0f3b6178..7cc4932cae7ec4e7b89cc658904b4e67b3f76ac3 100644 (file)
 || ###################################################################
 \*=====================================================================*/
 
+/*
+A USEFUL QUERY:
+
+DELETE FROM history WHERE field IN ('lastposttime', 'lastpostby', 'hiddenlastposttime', 'hiddenlastpostby')
+
+*/
+
 /**
 * Bug Change Logging
 *
@@ -78,46 +85,34 @@ class Logging
        * @param        bool    TRUE for original, FALSE for modified
        * @param        array   Data array
        * @param        array   List of fields in the data array to add; in format of array('field name' => 'display name', 'display name 2', 'display name 3')
+       * @param        bool    If TRUE, then the list of fields is used to exclude, not include
        * @param        string  Element to add to
        * @param        string  Field prefix
        */
-       function add_data($orig, $data, $fields, $element = '', $prefix = '')
+       function add_data($orig, $data, $fields, $exclude = false, $element = '', $prefix = '')
        {
                $array = ($orig ? 'original' : 'modified');
-               $prefix .= ($prefix != '' ? '.' : '');
+               $prefix .= '.';
                
-               foreach ($fields AS $fname => $fdisplay)
+               if ($exclude == false)
                {
-                       if (is_numeric($fname))
+                       foreach ($fields AS $fname => $fdisplay)
                        {
-                               $fname = $fdisplay;
+                               if (is_numeric($fname))
+                               {
+                                       $fname = $fdisplay;
+                               }
+                               
+                               $this->{$array}["$element"]["$prefix$fdisplay"] = array('name' => $fname, 'value' => $data["$fname"]);
                        }
-                       
-                       $this->{$array}["$element"]["$prefix$fdisplay"] = $data["$fname"];
                }
-       }
-       
-       // ###################################################################
-       /**
-       * Adds strings to the IDs so that it's human-readable and that's
-       * stored in the database so that if whatever value is deleted,
-       * the text still exists in the end. This takes the element and a list
-       * of fields to prossess in order to work.
-       *
-       * @access       public
-       *
-       * @param        string  Element name
-       * @param        array   List of fields to use
-       */
-       function process_fields($element, $fields)
-       {
-               foreach (array('original', 'modified') AS $array)
+               else
                {
-                       foreach ($this->{$array}["$element"] AS $display => $fname)
+                       foreach ($data AS $fname => $value)
                        {
-                               if (in_array($fname, $fields))
+                               if (!in_array($fname, $fields))
                                {
-                                       
+                                       $this->{$array}["$element"]["$prefix$fname"] = array('name' => $fname, 'value' => $value);
                                }
                        }
                }