X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FCore_event_audit.php;h=0e578b10f1ee58be2c9e19bd296f6a9da28a5abf;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hb=HEAD;hpb=25c7f020ee64e92e240db0b387c6e710eccb0e25 diff --git a/DataObjects/Core_event_audit.php b/DataObjects/Core_event_audit.php index e69de29b..0e578b10 100644 --- a/DataObjects/Core_event_audit.php +++ b/DataObjects/Core_event_audit.php @@ -0,0 +1,87 @@ +on_table); + $ar = $x->links(); + // is the name a link.. + if (!isset($ar[$this->name])) { + return $this->value; + } + if (empty($this->value) ) { + return ''; + } + // lr = ProjecT:id + // get the current value of that... + $lr = explode(':', $ar[$this->name]); + $x = DB_DataObject::factory($lr[0]); + if (!method_exists($x, 'toEventString')) { + return $lr[0] .':'. $this->value; + } + $x->get($this->value); + + return $x->toEventString(); // big assumption.. + } + + function oldvalue($event) + { + if (!$this->old_audit_id) { + return 'Unknown'; + } + //var_dump($cg->ontable); + $x = DB_DataObject::factory('core_event_audit'); + $x->get($this->old_audit_id); + return $x->newvalue($event); + + } + function findLast($event, $name) + { + //DB_DataObject::debugLevel(1); + $x = DB_DataObject::factory('core_event_audit'); + $x->autoJoin(); + + + $x->selectAdd(); + $x->selectAdd('core_event_audit.id as id'); + + $x->name = $name; + $x->whereAdd(" + join_event_id_id.on_table = '{$event->on_table}' AND + join_event_id_id.on_id = {$event->on_id} + "); + $x->orderBy('join_event_id_id.event_when DESC'); + $x->limit(1); + if (!$x->find(true)) { + return 0; + } + return $x->id; + + } + + +} \ No newline at end of file