Pman/Roo.php
[Pman.Base] / Pman / Roo.php
index cfa433c..c9f4740 100644 (file)
@@ -32,8 +32,8 @@ require_once 'Pman.php';
  * - beforeInsert($request,$roo) - before insert - jerr() will stop insert..
  *
  *  AFTER
- * - onUpdate($old, $request,$roo) - after update // return value ignored
- * - onInsert($request,$roo) - after insert
+ * - onUpdate($old, $request,$roo, $event) - after update // return value ignored
+ * - onInsert($request,$roo, $event) - after insert
  * - onDelete($req, $roo) - after delete
  * - onUpload($roo)
  * 
@@ -443,6 +443,20 @@ class Pman_Roo extends Pman
             'leave_open' => true
         );
         
+        if ($titles== '*') {
+            $titles= array_keys($x);
+        }
+        if ($cols== '*') {
+            $cols= array_keys($x);
+        }
+
+        if(!is_array($titles)) {
+            $titles = explode(',', $titles);
+        }
+        if(!is_array($cols)) {
+            $cols = explode(',', $cols);
+        }
+            
         
         $se = false;
         if (is_object($data)) {
@@ -454,11 +468,13 @@ class Pman_Roo extends Pman
                 if ($cols == '*') {  /// did we get cols sent to us?
                     $cols = array_keys($x);
                 }
+                
+                if(!is_array($cols)) {
+                    $cols = explode(',', $cols);
+                }
                
                 if ($titles !== false) {
-                    if ($titles== '*') {
-                        $titles= array_keys($x);
-                    }
+                    
                     foreach($cols as $i=>$col) {
                         $se_config['cols'][] = array(
                             'header'=> isset($titles[$i]) ? $titles[$i] : $col,
@@ -494,12 +510,7 @@ class Pman_Roo extends Pman
         foreach($data as $x) {
             //echo "<PRE>"; print_r(array($_REQUEST['csvCols'], $x->toArray())); exit;
             $line = array();
-            if ($titles== '*') {
-                $titles= array_keys($x);
-            }
-            if ($cols== '*') {
-                $cols= array_keys($x);
-            }
+            
             if ($titles !== false) {
                 foreach($cols as $i=>$col) {
                     $se_config['cols'][] = array(
@@ -845,7 +856,7 @@ class Pman_Roo extends Pman
         } else if (method_exists($x, 'applyFilters')) {
             // always call apply filters even after update/insert...
             // however arguments are not passed.
-            $x->applyFilters(array(), $this->authUser, $this);
+            $x->applyFilters(array('_is_update_request' => true), $this->authUser, $this);
         }
         
         // DB_DataObject::DebugLevel(1);
@@ -937,10 +948,11 @@ class Pman_Roo extends Pman
         if ($res === false) {
             $this->jerr($x->_lastError->toString());
         }
+        $ev = $this->addEvent("ADD", $x);
         if (method_exists($x, 'onInsert')) {
-            $x->onInsert($_REQUEST, $this);
+            $x->onInsert($_REQUEST, $this, $ev);
         }
-        $ev = $this->addEvent("ADD", $x);
+        
         if ($ev) { 
             $ev->audit($x);
         }
@@ -1099,11 +1111,11 @@ class Pman_Roo extends Pman
         if ($res === false) {
             $this->jerr($x->_lastError->toString());
         }
-        
+        $ev = $this->addEvent("EDIT", $x);
+
         if (method_exists($x, 'onUpdate')) {
-            $x->onUpdate($old, $req, $this);
+            $x->onUpdate($old, $req, $this, $ev);
         }
-        $ev = $this->addEvent("EDIT", $x);
         if ($ev) { 
             $ev->audit($x, $old);
         }