// 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
}
$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)
{
}
}
- 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]");
}
|| ###################################################################
\*=====================================================================*/
+/*
+A USEFUL QUERY:
+
+DELETE FROM history WHERE field IN ('lastposttime', 'lastpostby', 'hiddenlastposttime', 'hiddenlastpostby')
+
+*/
+
/**
* Bug Change 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);
}
}
}