DataObjects/Images.php
authorChris <chris@roojs.com>
Tue, 9 Oct 2012 11:17:06 +0000 (19:17 +0800)
committerChris <chris@roojs.com>
Tue, 9 Oct 2012 11:17:06 +0000 (19:17 +0800)
DataObjects/Images.php

index a15f4a8..d328709 100644 (file)
@@ -148,7 +148,29 @@ class Pman_Core_DataObjects_Images extends DB_DataObject
         ));
           
     }
+    
+    function onInsert($request,$roo)
+    {
+        
+        
+        if(!empty($this->imgtype)){
+            $c = DB_DataObject::factory('Companies');
+
+            if(!$c->get($this->onid)){
+                return;
+            }
 
+            if(!empty($c->logo_id)){
+                $xx = DB_DataObject::factory('Images');
+                $xx->get($c->logo_id);
+                $xx->delete();
+            }
+
+            $c->logo_id = $this->id;
+            $c->update();
+        }
+        
+    }
      
     /**
      * deletes all the image instances of it...