Pman.Gnumeric.js
[Pman.Core] / Import / Core_notify.php
index 02d3f7c..5e0469b 100644 (file)
@@ -20,7 +20,9 @@ class Pman_Core_Import_Core_notify extends Pman_Roo
         
     }
 
-    function get()
+    var $defaults = array();
+    
+    function get($v, $opts=array())
     {   
         
         $this->transObj = DB_DataObject::Factory('core_enum');
@@ -31,10 +33,51 @@ class Pman_Core_Import_Core_notify extends Pman_Roo
         
         $this->modules = $this->modulesList();
         
-        $this->config();
-        
         $this->etype();
         
+        $this->defaults();
+        
+        foreach ($this->defaults as $k => $v){
+            $enum = DB_DataObject::factory('core_enum');
+            $enum->setFrom(array(
+                'etype' => $this->etype->name,
+                'name' => $k,
+                'active' => 1
+            ));
+            
+            if($enum->find(true)){
+                continue;
+            }
+            
+            $enum->display_name = $v;
+            $enum->insert();
+        }
+        
+        $notify = DB_DataObject::factory('core_notify');
+        $notify->selectAdd();
+        $notify->selectAdd("
+            DISTINCT(evtype) AS evtype
+        ");
+        
+        $types = $notify->fetchAll();
+        
+        foreach ($types as $t){
+            $enum = DB_DataObject::factory('core_enum');
+            $enum->setFrom(array(
+                'etype' => $this->etype->name,
+                'name' => $t->evtype,
+                'active' => 1
+            ));
+            
+            if($enum->find(true)){
+                continue;
+            }
+            
+            $enum->display_name = $t->evtype;
+            $enum->insert();
+        }
+        
+        $this->jok('DONE');
         
         
     }
@@ -56,11 +99,24 @@ class Pman_Core_Import_Core_notify extends Pman_Roo
         $this->etype->insert();
     }
     
-    function config()
+    function defaults()
     {
-        print_R($this->modules);exit;
         foreach ($this->modules as $m){
+            $file = $this->rootDir. "/Pman/$m/Core.NotifyType.json";
+            
+            if(!file_exists($file)){
+                continue;
+            }
             
+            $this->log("Processing $file");
+                    
+            $this->defaults = array_merge($this->defaults, json_decode(file_get_contents($file), true)) ;
         }
+        
+    }
+    
+    function log($str)
+    {
+        echo "$str \n";
     }
 }
\ No newline at end of file