Import/Core_notify.php
[Pman.Core] / Import / Core_notify.php
1 <?php
2
3 require_once 'Pman/Roo.php';
4
5 class Pman_Core_Import_Core_notify extends Pman_Roo 
6 {
7     static $cli_desc = "Create Core.NotifyType from core notify"; 
8     
9     static $cli_opts = array(
10         
11     );
12     
13     function getAuth()
14     {
15         if (!HTML_FlexyFramework::get()->cli) {
16             return false;
17         }
18         
19         return true;
20         
21     }
22
23     var $defaults = array();
24     
25     function get()
26     {   
27         
28         $this->transObj = DB_DataObject::Factory('core_enum');
29         
30         $this->transObj->query('BEGIN');
31         
32         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
33         
34         $this->modules = $this->modulesList();
35         
36         $this->defaults();
37         
38         $this->etype();
39         
40         
41         
42     }
43     
44     function etype()
45     {
46         $this->etype = DB_DataObject::factory('core_enum');
47         $this->etype->setFrom(array(
48             'etype' => '',
49             'name' => 'Core.NotifyType',
50             'display_name' => 'Core.NotifyType',
51             'active' => 1
52         ));
53         
54         if($this->etype->find(true)){
55             return;
56         }
57         
58         $this->etype->insert();
59     }
60     
61     function defaults()
62     {
63         foreach ($this->modules as $m){
64             $file = $this->rootDir. "/Pman/$m/Core.NotifyType.json";
65             
66             if(!file_exists($file)){
67                 continue;
68             }
69             
70             $this->defaults = array_merge($this->defaults, json_decode(file_get_contents($file), true)) ;
71         }
72         
73     }
74     
75     function log($str)
76     {
77         echo "$str \n";
78     }
79 }