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         print_r($this->defaults);exit;
39         
40         $this->etype();
41         
42         
43         
44     }
45     
46     function etype()
47     {
48         $this->etype = DB_DataObject::factory('core_enum');
49         $this->etype->setFrom(array(
50             'etype' => '',
51             'name' => 'Core.NotifyType',
52             'display_name' => 'Core.NotifyType',
53             'active' => 1
54         ));
55         
56         if($this->etype->find(true)){
57             return;
58         }
59         
60         $this->etype->insert();
61     }
62     
63     function defaults()
64     {
65         foreach ($this->modules as $m){
66             $file = $this->rootDir. "/Pman/$m/Core.NotifyType.json";
67             
68             if(!file_exists($file)){
69                 continue;
70             }
71             
72             $this->defaults = array_merge($this->defaults, json_decode(file_get_contents($file), true)) ;
73         }
74         
75     }
76     
77     function log($str)
78     {
79         echo "$str \n";
80     }
81 }