supported updated_id to be set to event id
[Pman.Base] / Pman / Roo.php
index 05dfb94..25c9edc 100644 (file)
@@ -42,7 +42,14 @@ require_once 'Pman.php';
 
 class Pman_Roo extends Pman
 {
-    /**
+    
+   /* EVENTUALLY - move this stuff here..
+    * use Pman_Core_RooTrait,
+        Pman_Core_RooGetTrait,
+        Pman_Core_RooPostTrait,
+        Pman_Core_RooJsonOutputTrait;
+    */
+     /**
      * if set to an array (when extending this, then you can restrict which tables are available
      */
     var $validTables = false; 
@@ -980,6 +987,13 @@ class Pman_Roo extends Pman
             $this->jerr($x->_lastError->toString());
         }
         $ev = $this->addEvent("ADD", $x);
+        
+        if (isset($cols['updated_id'])) {
+            $old = clone($x);
+            $x->updated_id = $ev->id;
+            $x->update($old);
+        }
+        
         if (method_exists($x, 'onInsert')) {
                     
             $x->onInsert($_REQUEST, $this, $ev);
@@ -994,6 +1008,7 @@ class Pman_Roo extends Pman
             $x->onUpload($this, $_REQUEST);
         }
         
+        
         return $this->selectSingle(
             DB_DataObject::factory($x->tableName()),
             $x->pid()
@@ -1144,14 +1159,19 @@ class Pman_Roo extends Pman
             $this->jerr($x->_lastError->toString());
         }
         $ev = $this->addEvent("EDIT", $x);
-
+        
+        if (isset($cols['updated_id'])) {
+            $old = clone($x);
+            $x->updated_id = $ev->id;
+            $x->update($old);
+        }
         if (method_exists($x, 'onUpdate')) {
             $x->onUpdate($old, $req, $this, $ev);
         }
         if ($ev) { 
             $ev->audit($x, $old);
         }
-        
+       
         
         return $this->selectSingle(
             DB_DataObject::factory($x->tableName()),
@@ -1588,7 +1608,8 @@ class Pman_Roo extends Pman
         }
         $tab = str_replace('/', '',$tab); // basic protection??
         
-        $pm = HTML_FlexyFramework::get()->Pman;
+        $ff = HTML_FlexyFramework::get();
+        $pm = isset($ff->Pman) ? $ff->Pman : array();
         
         if (isset($pm['roo_alias'])) {
             $map = array_flip($pm['roo_alias']);