473d648e4162643786aeb7fe5cb88f7bcdcd39bf
[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     function get()
24     {   
25         
26         $this->transObj = DB_DataObject::Factory('core_enum');
27         
28         $this->transObj->query('BEGIN');
29         
30         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
31         
32         $this->modules = $this->modulesList();
33         
34         $this->defaults();
35         
36         $this->etype();
37         
38         
39         
40     }
41     
42     function etype()
43     {
44         $this->etype = DB_DataObject::factory('core_enum');
45         $this->etype->setFrom(array(
46             'etype' => '',
47             'name' => 'Core.NotifyType',
48             'display_name' => 'Core.NotifyType',
49             'active' => 1
50         ));
51         
52         if($this->etype->find(true)){
53             return;
54         }
55         
56         $this->etype->insert();
57     }
58     
59     function defaults()
60     {
61         foreach ($this->modules as $m){
62             $file = $this->rootDir. "/Pman/$m/Core.NotifyType.json";
63             
64             if(!file_exists($file)){
65                 continue;
66             }
67             
68             $this->defaults[$m] = json_decode(file_get_contents($file), true);
69             
70         }
71         exit;
72     }
73     
74     function log($str)
75     {
76         echo "$str \n";
77     }
78 }