3 * Table Definition for mtrack_change_audit
5 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
7 class Pman_MTrack_DataObjects_Mtrack_change_audit extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'mtrack_change_audit'; // table name
13 public $id; // int(11) not_null primary_key auto_increment
14 public $change_id; // int(11) not_null multiple_key
15 public $ticket_change_id; // int(11) not_null multiple_key
17 public $fieldname; // string(128)
18 public $action; // string(16)
19 public $oldvalue; // blob(65535) blob
20 public $value; // blob(65535) blob
23 /* the code above is auto generated do not remove the tag below */
27 $ar = explode(':', $this->fieldname);
28 return array_pop($ar);
33 $x = DB_DataObject::factory($cg->ontable);
35 if (!isset($ar[$this->field()])) {
38 if (empty($this->value) ) {
44 $lr = explode(':', $ar[$this->field()]);
45 $x = DB_DataObject::factory($lr[0]);
46 $x->get($this->value);
47 return isset($x->name) ? $x->name : $this->value; // big assumption..
52 function oldvalue($cg)
54 //var_dump($cg->ontable);
55 $x = DB_DataObject::factory($cg->ontable);
58 if ( !isset($ar[$this->field()])) {
59 return $this->oldvalue;
62 if (empty($this->oldvalue)) {
66 $lr = explode(':', $ar[$this->field()]);
67 $x = DB_DataObject::factory($lr[0]);
68 $x->get($this->oldvalue);
69 return isset($x->name) ? $x->name : $this->oldvalue;
73 function toAuditString($change)
75 $field = $this->field();
80 return false; //??? ignore?
84 // foreach (preg_split("/\s*,\s*/", $old_values[$field]) as $id) {
85 /* if (!strlen($id)) continue;
86 $c = get_component($id);
89 $value = $T->getComponents();
96 // foreach (preg_split("/\s*,\s*/", $old_values[$field]) as $id) {
97 /* if (!strlen($id)) continue;
98 $m = get_milestone($id);
102 $value = $T->getMilestones();
103 $field = 'Milestone';
110 $oldvalue = $this->oldvalue($change);
111 $value = $this->value($change);
115 $field = preg_replace('/_id$/', '', $this->field());
116 $field = ucfirst(str_replace('_', ' ', $field));
118 if ( ($oldvalue == $value) ||
119 (!strlen($oldvalue) && !strlen($value))) {
122 $lb = strpos($oldvalue,"\n") > -1 || strpos($value,"\n") > -1 ? "\n\n" : '';
123 $lbs = $lb == '' ? '' : "\n\n---\n\n";
124 if (!strlen($oldvalue)) {
125 return " * Set {$field} to: {$lbs}{$value}{$lbs}";
128 if (!strlen($value)) {
129 return " * Removed {$lb}{$field} - was: {$lbs}{$oldvalue}";
133 return " * Changed {$field} from : {$lbs}{$oldvalue} {$lbs} to {$lbs}{$value}{$lbs}";
138 function toJSONArray($change)
140 $ret= $this->toArray();
141 // now add the value strings..
143 $field = preg_replace('/_id$/', '', $this->field());
144 $field = ucfirst(str_replace('_', ' ', $field));
146 $ret['field_str'] = $field;
148 $ret['oldvalue_str'] = $this->oldvalue($change);
149 $ret['value_str'] = $this->value($change);
151 if ($this->value == $this->oldvalue) {