X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FCore_event_audit.php;h=ccb5a521ee8a95ee6b93e092387554433bfb15dc;hb=0639931e628a515f194475abaa4b70bf82a4bc9a;hp=da326ad3568dce78e1c18275875b96cb75d55a1e;hpb=f788b6891a4f0e47547a58d106e3f524ffa86c52;p=Pman.Core diff --git a/DataObjects/Core_event_audit.php b/DataObjects/Core_event_audit.php index da326ad3..ccb5a521 100644 --- a/DataObjects/Core_event_audit.php +++ b/DataObjects/Core_event_audit.php @@ -25,7 +25,7 @@ class Pman_Core_DataObjects_Core_event_audit extends DB_DataObject * */ - function value($event) + function newvalue($event) { $x = DB_DataObject::factory($event->on_table); $ar = $x->links(); @@ -45,107 +45,22 @@ class Pman_Core_DataObjects_Core_event_audit extends DB_DataObject } $x->get($this->value); - return $x->toEventString(); // big assumption.. - - } - function oldvalue($cg) - { - //var_dump($cg->ontable); - $x = DB_DataObject::factory($cg->ontable); - - $ar = $x->links(); - if ( !isset($ar[$this->field()])) { - return $this->oldvalue; - } - // lr = ProjecT:id - if (empty($this->oldvalue)) { - return ''; - } - $lr = explode(':', $ar[$this->field()]); - $x = DB_DataObject::factory($lr[0]); - $x->get($this->oldvalue); - return isset($x->name) ? $x->name : $this->oldvalue; - + return $x->toEventString(); // big assumption.. } - function toAuditString($change) + function oldvalue($event) { - $field = $this->field(); - switch($field) { - case 'id': - case 'created_id': - - return false; //??? ignore? - case '@components': - return false; - // $old = array(); - // foreach (preg_split("/\s*,\s*/", $old_values[$field]) as $id) { - /* if (!strlen($id)) continue; - $c = get_component($id); - $old[$id] = $c->name; - } - $value = $T->getComponents(); - $field = 'Component'; - break; - */ - case '@milestones': - return false; - // $old = array(); - // foreach (preg_split("/\s*,\s*/", $old_values[$field]) as $id) { - /* if (!strlen($id)) continue; - $m = get_milestone($id); - $old[$id] = $m->name; - } - $value = array(); - $value = $T->getMilestones(); - $field = 'Milestone'; - break; - */ - case '@keywords': - return false; - - default: - $oldvalue = $this->oldvalue($change); - $value = $this->value($change); - - $field = preg_replace('/_id$/', '', $this->field()); - $field = ucfirst(str_replace('_', ' ', $field)); - - if ( ($oldvalue == $value) || - (!strlen($oldvalue) && !strlen($value))) { - return false; - } - $lb = strpos($oldvalue,"\n") > -1 || strpos($value,"\n") > -1 ? "\n\n" : ''; - $lbs = $lb == '' ? '' : "\n\n---\n\n"; - if (!strlen($oldvalue)) { - return " * Set {$field} to: {$lbs}{$value}{$lbs}"; - } - - if (!strlen($value)) { - return " * Removed {$lb}{$field} - was: {$lbs}{$oldvalue}"; - - } - - return " * Changed {$field} from : {$lbs}{$oldvalue} {$lbs} to {$lbs}{$value}{$lbs}"; - + if (!$this->old_audit_id) { + return 'Unknown'; } - } - - function toJSONArray($change) - { - $ret= $this->toArray(); - // now add the value strings.. - - $field = preg_replace('/_id$/', '', $this->field()); - $field = ucfirst(str_replace('_', ' ', $field)); - - $ret['field_str'] = $field; - - $ret['oldvalue_str'] = $this->oldvalue($change); - $ret['value_str'] = $this->value($change); - return $ret; + //var_dump($cg->ontable); + $x = DB_DataObject::factory('core_event_audit'); + $x->get($this->old_audit_id); + return $x->newvalue($event); } + +