Fix #7796 - media outreach crm - needs distributed email sending (due to spam blocks)
[Pman.Core] / DataObjects / Core_domain.php
index 89b4587..8c6bc83 100644 (file)
@@ -15,5 +15,22 @@ class Pman_Core_DataObjects_Core_domain extends DB_DataObject
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
-    
+    function loadOrCreate($dom)
+    {
+        // should we validate domain?
+        static $cache = array();
+        if (isset($cache[$dom])) {
+            return $cache[$dom];
+        }
+        
+        $cd = DB_DataObject::Factory($dom);
+        if ($cd->get('domain', $dom)) {
+            $cache[$dom] = $cd;
+            return $cd;
+        }
+        $cd->domain = $dom;
+        $cd->insert();
+        $cache[$dom] = $cd;
+        return $cd;
+    }
 }