1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* XML Generater |
6
|
|
|
* @author NAVER ([email protected]) |
7
|
|
|
*/ |
8
|
|
|
class XmlGenerater |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Generate XML using given data |
13
|
|
|
* |
14
|
|
|
* @param array $params The data |
15
|
|
|
* @return string Returns xml string |
16
|
|
|
*/ |
17
|
|
|
function generate(&$params) |
18
|
|
|
{ |
19
|
|
|
$xmlDoc = '<?xml version="1.0" encoding="utf-8" ?><methodCall><params>'; |
20
|
|
|
if(!is_array($params)) |
21
|
|
|
{ |
22
|
|
|
return NULL; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$params["module"] = "resourceapi"; |
26
|
|
|
foreach($params as $key => $val) |
27
|
|
|
{ |
28
|
|
|
$xmlDoc .= sprintf("<%s><![CDATA[%s]]></%s>", $key, $val, $key); |
29
|
|
|
} |
30
|
|
|
$xmlDoc .= "</params></methodCall>"; |
31
|
|
|
return $xmlDoc; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Request data to server and returns result |
36
|
|
|
* |
37
|
|
|
* @param array $params Request data |
38
|
|
|
* @return object |
39
|
|
|
*/ |
40
|
|
|
function getXmlDoc(&$params) |
41
|
|
|
{ |
42
|
|
|
$body = XmlGenerater::generate($params); |
43
|
|
|
$buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml"); |
44
|
|
|
if(!$buff) |
45
|
|
|
{ |
46
|
|
|
return; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$xml = new XmlParser(); |
50
|
|
|
$xmlDoc = $xml->parse($buff); |
51
|
|
|
return $xmlDoc; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* High class of the autoinstall module |
58
|
|
|
* @author NAVER ([email protected]) |
59
|
|
|
*/ |
60
|
|
|
class autoinstall extends ModuleObject |
61
|
|
|
{ |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Temporary directory path |
65
|
|
|
*/ |
66
|
|
|
var $tmp_dir = './files/cache/autoinstall/'; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Constructor |
70
|
|
|
* |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
|
|
function autoinstall() |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
$oModuleModel = getModel('module'); |
76
|
|
|
$config = $oModuleModel->getModuleConfig('autoinstall'); |
77
|
|
|
if($config->downloadServer != _XE_DOWNLOAD_SERVER_) |
78
|
|
|
{ |
79
|
|
|
$this->stop('msg_not_match_server'); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* For additional tasks required when installing |
85
|
|
|
* |
86
|
|
|
* @return Object |
87
|
|
|
*/ |
88
|
|
|
function moduleInstall() |
89
|
|
|
{ |
90
|
|
|
$oModuleController = getController('module'); |
91
|
|
|
|
92
|
|
|
$config = new stdClass; |
93
|
|
|
$config->downloadServer = _XE_DOWNLOAD_SERVER_; |
94
|
|
|
$oModuleController->insertModuleConfig('autoinstall', $config); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Method to check if installation is succeeded |
99
|
|
|
* |
100
|
|
|
* @return bool |
101
|
|
|
*/ |
102
|
|
|
function checkUpdate() |
103
|
|
|
{ |
104
|
|
|
$oDB = DB::getInstance(); |
105
|
|
|
$oModuleModel = getModel('module'); |
106
|
|
|
$oModuleController = getController('module'); |
107
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
108
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
109
|
|
|
{ |
110
|
|
|
if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_installed_packages.xml') |
|
|
|
|
111
|
|
|
&& $oDB->isTableExists("autoinstall_installed_packages")) |
112
|
|
|
{ |
113
|
|
|
return TRUE; |
114
|
|
|
} |
115
|
|
|
if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_remote_categories.xml') |
|
|
|
|
116
|
|
|
&& $oDB->isTableExists("autoinstall_remote_categories")) |
117
|
|
|
{ |
118
|
|
|
return TRUE; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
// 2011.08.08 add column 'list_order' in ai_remote_categories |
122
|
|
|
if(!$oDB->isColumnExists('ai_remote_categories', 'list_order')) |
123
|
|
|
{ |
124
|
|
|
return TRUE; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
// 2011.08.08 set _XE_DOWNLOAD_SERVER_ at module config |
128
|
|
|
$config = $oModuleModel->getModuleConfig('autoinstall'); |
129
|
|
|
if(!isset($config->downloadServer)) |
130
|
|
|
{ |
131
|
|
|
return TRUE; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
// 2012.11.12 add column 'have_instance' in autoinstall_packages |
135
|
|
|
if(!$oDB->isColumnExists('autoinstall_packages', 'have_instance')) |
136
|
|
|
{ |
137
|
|
|
return TRUE; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
return FALSE; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Execute update |
148
|
|
|
* |
149
|
|
|
* @return Object |
150
|
|
|
*/ |
151
|
|
|
function moduleUpdate() |
152
|
|
|
{ |
153
|
|
|
$oDB = DB::getInstance(); |
154
|
|
|
$oModuleModel = getModel('module'); |
155
|
|
|
$oModuleController = getController('module'); |
156
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
157
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
158
|
|
|
{ |
159
|
|
|
if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_installed_packages.xml') |
|
|
|
|
160
|
|
|
&& $oDB->isTableExists("autoinstall_installed_packages")) |
161
|
|
|
{ |
162
|
|
|
$oDB->dropTable("autoinstall_installed_packages"); |
163
|
|
|
} |
164
|
|
|
if(!FileHandler::exists('./modules/autoinstall/schemas/autoinstall_remote_categories.xml') |
|
|
|
|
165
|
|
|
&& $oDB->isTableExists("autoinstall_remote_categories")) |
166
|
|
|
{ |
167
|
|
|
$oDB->dropTable("autoinstall_remote_categories"); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
// 2011.08.08 add column 'list_order' in 'ai_remote_categories |
171
|
|
|
if(!$oDB->isColumnExists('ai_remote_categories', 'list_order')) |
172
|
|
|
{ |
173
|
|
|
$oDB->addColumn('ai_remote_categories', 'list_order', 'number', 11, NULL, TRUE); |
174
|
|
|
$oDB->addIndex('ai_remote_categories', 'idx_list_order', array('list_order')); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
// 2011. 08. 08 set _XE_DOWNLOAD_SERVER_ at module config |
178
|
|
|
$config = $oModuleModel->getModuleConfig('autoinstall'); |
179
|
|
|
if(!isset($config->downloadServer)) |
180
|
|
|
{ |
181
|
|
|
$config->downloadServer = _XE_DOWNLOAD_SERVER_; |
182
|
|
|
$oModuleController->insertModuleConfig('autoinstall', $config); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
// 2012.11.12 add column 'have_instance' in autoinstall_packages |
186
|
|
|
if(!$oDB->isColumnExists('autoinstall_packages', 'have_instance')) |
187
|
|
|
{ |
188
|
|
|
$oDB->addColumn('autoinstall_packages', 'have_instance', 'char', '1', 'N', TRUE); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
return new Object(0, 'success_updated'); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Re-generate the cache file |
199
|
|
|
* @return Object |
200
|
|
|
*/ |
201
|
|
|
function recompileCache() |
202
|
|
|
{ |
203
|
|
|
|
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
} |
207
|
|
|
/* End of file autoinstall.class.php */ |
208
|
|
|
/* Location: ./modules/autoinstall/autoinstall.class.php */ |
209
|
|
|
|