3 require_once 'Pman/Roo.php';
5 class Pman_Core_Import_Core_notify extends Pman_Roo
7 static $cli_desc = "Create Core.NotifyType from core notify";
9 static $cli_opts = array(
15 if (!HTML_FlexyFramework::get()->cli) {
23 var $defaults = array();
28 $this->transObj = DB_DataObject::Factory('core_enum');
30 $this->transObj->query('BEGIN');
32 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
34 $this->modules = $this->modulesList();
40 foreach ($this->defaults as $k => $v){
41 $enum = DB_DataObject::factory('core_enum');
43 'etype' => $this->etype->name,
48 if($enum->find(true)){
52 $enum->display_name = $v;
56 $notify = DB_DataObject::factory('core_notify');
59 DISTINCT(evtype) AS evtype
62 $types = $notify->fetchAll();
64 foreach ($types as $t){
65 $enum = DB_DataObject::factory('core_enum');
67 'etype' => $this->etype->name,
72 if($enum->find(true)){
76 $enum->display_name = $t->evtype;
87 $this->etype = DB_DataObject::factory('core_enum');
88 $this->etype->setFrom(array(
90 'name' => 'Core.NotifyType',
91 'display_name' => 'Core.NotifyType',
95 if($this->etype->find(true)){
99 $this->etype->insert();
104 foreach ($this->modules as $m){
105 $file = $this->rootDir. "/Pman/$m/Core.NotifyType.json";
107 if(!file_exists($file)){
111 $this->log("Processing $file");
113 $this->defaults = array_merge($this->defaults, json_decode(file_get_contents($file), true)) ;