DataObjects/Core_domain.php
[Pman.Core] / RooPostTrait.php
index 8ce77cf..b71a458 100644 (file)
@@ -66,7 +66,7 @@ trait Pman_Core_RooPostTrait {
      *
      * CALLS BEFORE change occurs:
      *  
-     *      beforeDelete($dependants_array, $roo)
+     *      beforeDelete($dependants_array, $roo, $request)
      *                      Argument is an array of un-find/fetched dependant items.
      *                      - jerr() will stop insert.. (Prefered)
      *                      - return false for fail and set DO->err;
@@ -241,7 +241,7 @@ trait Pman_Core_RooPostTrait {
             $match_total = 0;
             
             if ( $has_beforeDelete ) {
-                if ($xx->beforeDelete($match_ar, $this) === false) {
+                if ($xx->beforeDelete($match_ar, $this, $req) === false) {
                     $errs[] = "Delete failed ({$xx->id})\n".
                         (isset($xx->err) ? $xx->err : '');
                     continue;
@@ -282,9 +282,7 @@ trait Pman_Core_RooPostTrait {
           
             }
             
-            DB_DataObject::Factory('Events')->logDeletedRecord($x);
-            
-            $this->addEvent("DELETE", $x);
+            $this->logDeleteEvent($x);
             
             $xx->delete();
             
@@ -301,6 +299,17 @@ trait Pman_Core_RooPostTrait {
         
     }
     
+    function logDeleteEvent($object)
+    {
+        
+        DB_DataObject::Factory('Events')->logDeletedRecord($object);
+        
+        $this->addEvent("DELETE", $object);
+          
+        
+    }
+    
+    
     function update($x, $req,  $with_perm_check = true)
     {
         if ( $with_perm_check && !$this->checkPerm($x,'E', $req) )  {
@@ -442,20 +451,17 @@ trait Pman_Core_RooPostTrait {
             {
                 $p = DB_DataObject::factory('Person');
                 $p->get($x->modified_by);
-                $this->jerr($p->name . " saved the record since you started editing,\nDo you really want to update it?", array('needs_confirm' => true)); 
+                $this->jerr($p->name . " saved the record since you started editing,\nDo you really want to update it?", array('needs_confirm' => true)); 
                 
             }
-            
-            
-            
         }
+        
         return $lock;
         
     }
     
     function insert($x, $req, $with_perm_check = true)
-    {
-        
+    {   
         if (method_exists($x, 'setFromRoo')) {
             $res = $x->setFromRoo($req, $this);
             if (is_string($res)) {