1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
/** |
4
|
|
|
* @class moduleAdminController |
5
|
|
|
* @author NAVER ([email protected]) |
6
|
|
|
* @brief admin controller class of the module module |
7
|
|
|
*/ |
8
|
|
|
class moduleAdminController extends module |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @brief Initialization |
12
|
|
|
*/ |
13
|
|
|
function init() |
14
|
|
|
{ |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @brief Add the module category |
19
|
|
|
*/ |
20
|
|
View Code Duplication |
function procModuleAdminInsertCategory() |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
$args = new stdClass(); |
23
|
|
|
$args->title = Context::get('title'); |
24
|
|
|
$output = executeQuery('module.insertModuleCategory', $args); |
25
|
|
|
if(!$output->toBool()) return $output; |
26
|
|
|
|
27
|
|
|
$this->setMessage("success_registed"); |
28
|
|
|
|
29
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispModuleAdminCategory'); |
30
|
|
|
$this->setRedirectUrl($returnUrl); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @brief Update category |
35
|
|
|
*/ |
36
|
|
View Code Duplication |
function procModuleAdminUpdateCategory() |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$output = $this->doUpdateModuleCategory(); |
39
|
|
|
if(!$output->toBool()) return $output; |
40
|
|
|
|
41
|
|
|
$this->setMessage('success_updated'); |
42
|
|
|
|
43
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispModuleAdminCategory'); |
44
|
|
|
$this->setRedirectUrl($returnUrl); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @brief Delete category |
49
|
|
|
*/ |
50
|
|
View Code Duplication |
function procModuleAdminDeleteCategory() |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$output = $this->doDeleteModuleCategory(); |
53
|
|
|
if(!$output->toBool()) return $output; |
54
|
|
|
|
55
|
|
|
$this->setMessage('success_deleted'); |
56
|
|
|
|
57
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispModuleAdminCategory'); |
58
|
|
|
$this->setRedirectUrl($returnUrl); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @brief Change the title of the module category |
63
|
|
|
*/ |
64
|
|
|
function doUpdateModuleCategory() |
65
|
|
|
{ |
66
|
|
|
$args = new stdClass(); |
67
|
|
|
$args->title = Context::get('title'); |
68
|
|
|
$args->module_category_srl = Context::get('module_category_srl'); |
69
|
|
|
return executeQuery('module.updateModuleCategory', $args); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @brief Delete the module category |
74
|
|
|
*/ |
75
|
|
|
function doDeleteModuleCategory() |
76
|
|
|
{ |
77
|
|
|
$args = new stdClass; |
78
|
|
|
$args->module_category_srl = Context::get('module_category_srl'); |
79
|
|
|
return executeQuery('module.deleteModuleCategory', $args); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @brief Copy Module |
84
|
|
|
*/ |
85
|
|
|
function procModuleAdminCopyModule($args = NULL) |
86
|
|
|
{ |
87
|
|
|
$isProc = false; |
88
|
|
|
if(!$args) |
89
|
|
|
{ |
90
|
|
|
$isProc = true; |
91
|
|
|
// Get information of the target module to copy |
92
|
|
|
$module_srl = Context::get('module_srl'); |
93
|
|
|
$args = Context::getRequestVars(); |
94
|
|
|
} |
95
|
|
|
else |
96
|
|
|
{ |
97
|
|
|
$module_srl = $args->module_srl; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
if(!$module_srl) |
101
|
|
|
{ |
102
|
|
|
return $this->_returnByProc($isProc); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
// Get module name to create and browser title |
106
|
|
|
$clones = array(); |
107
|
|
|
for($i=1;$i<=10;$i++) |
108
|
|
|
{ |
109
|
|
|
$mid = trim($args->{"mid_".$i}); |
110
|
|
|
if(!$mid) continue; |
111
|
|
|
if(!preg_match("/^[a-zA-Z]([a-zA-Z0-9_]*)$/i", $mid)) return new BaseObject(-1, 'msg_limit_mid'); |
112
|
|
|
$browser_title = $args->{"browser_title_".$i}; |
113
|
|
|
if(!$mid) continue; |
114
|
|
|
if($mid && !$browser_title) $browser_title = $mid; |
115
|
|
|
$clones[$mid] = $browser_title; |
116
|
|
|
} |
117
|
|
|
if(count($clones) < 1) |
118
|
|
|
{ |
119
|
|
|
return $this->_returnByProc($isProc); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
$oModuleModel = getModel('module'); |
123
|
|
|
$oModuleController = getController('module'); |
124
|
|
|
// Get module information |
125
|
|
|
$columnList = array('module', 'module_category_srl', 'layout_srl', 'use_mobile', 'mlayout_srl', 'menu_srl', 'site_srl', 'skin', 'mskin', 'description', 'mcontent', 'open_rss', 'header_text', 'footer_text', 'regdate'); |
126
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
127
|
|
|
// Get permission information |
128
|
|
|
$module_args = new stdClass(); |
129
|
|
|
$module_args->module_srl = $module_srl; |
130
|
|
|
$output = executeQueryArray('module.getModuleGrants', $module_args); |
131
|
|
|
$grant = array(); |
132
|
|
|
if($output->data) |
133
|
|
|
{ |
134
|
|
|
foreach($output->data as $val) $grant[$val->name][] = $val->group_srl; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
// get Extra Vars |
138
|
|
|
$extra_args = new stdClass(); |
139
|
|
|
$extra_args->module_srl = $module_srl; |
140
|
|
|
$extra_output = executeQueryArray('module.getModuleExtraVars', $extra_args); |
141
|
|
|
$extra_vars = new stdClass(); |
142
|
|
|
if($extra_output->toBool() && is_array($extra_output->data)) |
143
|
|
|
{ |
144
|
|
|
foreach($extra_output->data as $info) |
145
|
|
|
{ |
146
|
|
|
$extra_vars->{$info->name} = $info->value; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
$tmpModuleSkinVars = $oModuleModel->getModuleSkinVars($module_srl); |
151
|
|
|
$tmpModuleMobileSkinVars = $oModuleModel->getModuleMobileSkinVars($module_srl); |
152
|
|
|
|
153
|
|
|
if($tmpModuleSkinVars) |
154
|
|
|
{ |
155
|
|
|
foreach($tmpModuleSkinVars as $key=>$value) |
156
|
|
|
{ |
157
|
|
|
$moduleSkinVars->{$key} = $value->value; |
|
|
|
|
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
if($tmpModuleMobileSkinVars) |
162
|
|
|
{ |
163
|
|
|
foreach($tmpModuleMobileSkinVars as $key=>$value) |
164
|
|
|
{ |
165
|
|
|
$moduleMobileSkinVars->{$key} = $value->value; |
|
|
|
|
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
$oDB = &DB::getInstance(); |
170
|
|
|
$oDB->begin(); |
171
|
|
|
// Copy a module |
172
|
|
|
$triggerObj = new stdClass(); |
173
|
|
|
$triggerObj->originModuleSrl = $module_srl; |
174
|
|
|
$triggerObj->moduleSrlList = array(); |
175
|
|
|
|
176
|
|
|
$errorLog = array(); |
177
|
|
|
foreach($clones as $mid => $browser_title) |
178
|
|
|
{ |
179
|
|
|
$clone_args = new stdClass; |
|
|
|
|
180
|
|
|
$clone_args = clone $module_info; |
181
|
|
|
$clone_args->module_srl = null; |
182
|
|
|
$clone_args->content = null; |
183
|
|
|
$clone_args->mid = $mid; |
184
|
|
|
$clone_args->browser_title = $browser_title; |
185
|
|
|
$clone_args->is_default = 'N'; |
186
|
|
|
$clone_args->isMenuCreate = $args->isMenuCreate; |
187
|
|
|
unset($clone_args->menu_srl); |
188
|
|
|
// Create a module |
189
|
|
|
$output = $oModuleController->insertModule($clone_args); |
190
|
|
|
|
191
|
|
|
if(!$output->toBool()) |
192
|
|
|
{ |
193
|
|
|
$errorLog[] = $mid . ' : '. $output->message; |
194
|
|
|
continue; |
195
|
|
|
} |
196
|
|
|
$module_srl = $output->get('module_srl'); |
197
|
|
|
|
198
|
|
|
if($module_info->module == 'page' && $extra_vars->page_type == 'ARTICLE') |
199
|
|
|
{ |
200
|
|
|
// copy document |
201
|
|
|
$oDocumentAdminController = getAdminController('document'); |
202
|
|
|
$copyOutput = $oDocumentAdminController->copyDocumentModule(array($extra_vars->document_srl), $module_srl, $module_info->category_srl); |
203
|
|
|
$document_srls = $copyOutput->get('copied_srls'); |
204
|
|
|
if($document_srls && count($document_srls) > 0) |
205
|
|
|
{ |
206
|
|
|
$extra_vars->document_srl = array_pop($document_srls); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
if($extra_vars->mdocument_srl) |
210
|
|
|
{ |
211
|
|
|
$copyOutput = $oDocumentAdminController->copyDocumentModule(array($extra_vars->mdocument_srl), $module_srl, $module_info->category_srl); |
212
|
|
|
$copiedSrls = $copyOutput->get('copied_srls'); |
213
|
|
|
if($copiedSrls && count($copiedSrls) > 0) |
214
|
|
|
{ |
215
|
|
|
$extra_vars->mdocument_srl = array_pop($copiedSrls); |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
// Grant module permissions |
221
|
|
|
if(count($grant) > 0) $oModuleController->insertModuleGrants($module_srl, $grant); |
222
|
|
|
if($extra_vars) $oModuleController->insertModuleExtraVars($module_srl, $extra_vars); |
223
|
|
|
|
224
|
|
|
if($moduleSkinVars) $oModuleController->insertModuleSkinVars($module_srl, $moduleSkinVars); |
|
|
|
|
225
|
|
|
if($moduleMobileSkinVars) $oModuleController->insertModuleMobileSkinVars($module_srl, $moduleMobileSkinVars); |
|
|
|
|
226
|
|
|
|
227
|
|
|
$triggerObj->moduleSrlList[] = $module_srl; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
$output = ModuleHandler::triggerCall('module.procModuleAdminCopyModule', 'after', $triggerObj); |
|
|
|
|
231
|
|
|
|
232
|
|
|
$oDB->commit(); |
233
|
|
|
|
234
|
|
|
if(count($errorLog) > 0) |
235
|
|
|
{ |
236
|
|
|
$message = implode('\n', $errorLog); |
237
|
|
|
$this->setMessage($message); |
238
|
|
|
} |
239
|
|
|
else |
240
|
|
|
{ |
241
|
|
|
$message = $lang->success_registed; |
|
|
|
|
242
|
|
|
$this->setMessage('success_registed'); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
View Code Duplication |
if($isProc) |
246
|
|
|
{ |
247
|
|
|
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
248
|
|
|
{ |
249
|
|
|
global $lang; |
250
|
|
|
htmlHeader(); |
251
|
|
|
alertScript($message); |
252
|
|
|
reload(true); |
253
|
|
|
closePopupScript(); |
254
|
|
|
htmlFooter(); |
255
|
|
|
Context::close(); |
256
|
|
|
exit; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
return $module_srl; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
private function _returnByProc($isProc, $msg='msg_invalid_request') |
264
|
|
|
{ |
265
|
|
|
if(!$isProc) |
266
|
|
|
return; |
267
|
|
|
else |
268
|
|
|
{ |
269
|
|
|
return new BaseObject(-1, $msg); |
270
|
|
|
} |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @brief Save the module permissions |
275
|
|
|
*/ |
276
|
|
|
function procModuleAdminInsertGrant() |
277
|
|
|
{ |
278
|
|
|
$oModuleController = getController('module'); |
279
|
|
|
$oModuleModel = getModel('module'); |
280
|
|
|
// Get module_srl |
281
|
|
|
$module_srl = Context::get('module_srl'); |
282
|
|
|
// Get information of the module |
283
|
|
|
$columnList = array('module_srl', 'module'); |
284
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
285
|
|
|
if(!$module_info) return new BaseObject(-1,'msg_invalid_request'); |
286
|
|
|
// Register Admin ID |
287
|
|
|
$oModuleController->deleteAdminId($module_srl); |
288
|
|
|
$admin_member = Context::get('admin_member'); |
289
|
|
View Code Duplication |
if($admin_member) |
290
|
|
|
{ |
291
|
|
|
$admin_members = explode(',',$admin_member); |
292
|
|
|
foreach($admin_members as $admin_id) |
293
|
|
|
{ |
294
|
|
|
$admin_id = trim($admin_id); |
295
|
|
|
if(!$admin_id) continue; |
296
|
|
|
$oModuleController->insertAdminId($module_srl, $admin_id); |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
// List permissions |
300
|
|
|
$xml_info = $oModuleModel->getModuleActionXML($module_info->module); |
301
|
|
|
|
302
|
|
|
$grant_list = $xml_info->grant; |
303
|
|
|
|
304
|
|
|
$grant_list->access = new stdClass(); |
305
|
|
|
$grant_list->access->default = 'guest'; |
306
|
|
|
$grant_list->manager = new stdClass(); |
307
|
|
|
$grant_list->manager->default = 'manager'; |
308
|
|
|
|
309
|
|
|
$grant = new stdClass(); |
310
|
|
View Code Duplication |
foreach($grant_list as $grant_name => $grant_info) |
311
|
|
|
{ |
312
|
|
|
// Get the default value |
313
|
|
|
$default = Context::get($grant_name.'_default'); |
314
|
|
|
// -1 = Log-in user only, -2 = site members only, -3 = manager only, 0 = all users |
315
|
|
|
$grant->{$grant_name} = array(); |
316
|
|
|
if(strlen($default)) |
317
|
|
|
{ |
318
|
|
|
$grant->{$grant_name}[] = $default; |
319
|
|
|
continue; |
320
|
|
|
// users in a particular group |
321
|
|
|
} |
322
|
|
|
else |
323
|
|
|
{ |
324
|
|
|
$group_srls = Context::get($grant_name); |
325
|
|
|
if($group_srls) |
326
|
|
|
{ |
327
|
|
|
if(strpos($group_srls,'|@|')!==false) $group_srls = explode('|@|',$group_srls); |
328
|
|
|
elseif(strpos($group_srls,',')!==false) $group_srls = explode(',',$group_srls); |
329
|
|
|
else $group_srls = array($group_srls); |
330
|
|
|
$grant->{$grant_name} = $group_srls; |
331
|
|
|
} |
332
|
|
|
continue; |
333
|
|
|
} |
334
|
|
|
$grant->{$group_srls} = array(); // dead code???? |
|
|
|
|
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
// Stored in the DB |
338
|
|
|
$args = new stdClass(); |
339
|
|
|
$args->module_srl = $module_srl; |
340
|
|
|
$output = executeQuery('module.deleteModuleGrants', $args); |
341
|
|
|
if(!$output->toBool()) return $output; |
342
|
|
|
// Permissions stored in the DB |
343
|
|
View Code Duplication |
foreach($grant as $grant_name => $group_srls) |
|
|
|
|
344
|
|
|
{ |
345
|
|
|
foreach($group_srls as $val) |
346
|
|
|
{ |
347
|
|
|
$args = new stdClass(); |
348
|
|
|
$args->module_srl = $module_srl; |
349
|
|
|
$args->name = $grant_name; |
350
|
|
|
$args->group_srl = $val; |
351
|
|
|
$output = executeQuery('module.insertModuleGrant', $args); |
352
|
|
|
if(!$output->toBool()) return $output; |
353
|
|
|
} |
354
|
|
|
} |
355
|
|
|
$this->setMessage('success_registed'); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* @brief Updating Skins |
360
|
|
|
*/ |
361
|
|
|
function procModuleAdminUpdateSkinInfo() |
362
|
|
|
{ |
363
|
|
|
// Get information of the module_srl |
364
|
|
|
$module_srl = Context::get('module_srl'); |
365
|
|
|
$mode = Context::get('_mode'); |
366
|
|
|
$mode = $mode === 'P' ? 'P' : 'M'; |
367
|
|
|
|
368
|
|
|
$oModuleModel = getModel('module'); |
369
|
|
|
$columnList = array('module_srl', 'module', 'skin', 'mskin', 'is_skin_fix', 'is_mskin_fix'); |
370
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
371
|
|
|
if($module_info->module_srl) |
372
|
|
|
{ |
373
|
|
View Code Duplication |
if($mode === 'M') |
374
|
|
|
{ |
375
|
|
|
if($module_info->is_mskin_fix == 'Y') |
376
|
|
|
{ |
377
|
|
|
$skin = $module_info->mskin; |
378
|
|
|
} |
379
|
|
|
else |
380
|
|
|
{ |
381
|
|
|
$skin = $oModuleModel->getModuleDefaultSkin($module_info->module, 'M'); |
382
|
|
|
} |
383
|
|
|
} |
384
|
|
|
else |
385
|
|
|
{ |
386
|
|
|
if($module_info->is_skin_fix == 'Y') |
387
|
|
|
{ |
388
|
|
|
$skin = $module_info->skin; |
389
|
|
|
} |
390
|
|
|
else |
391
|
|
|
{ |
392
|
|
|
$skin = $oModuleModel->getModuleDefaultSkin($module_info->module, 'P'); |
393
|
|
|
} |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
// Get skin information (to check extra_vars) |
397
|
|
|
$module_path = _XE_PATH_ . 'modules/'.$module_info->module; |
398
|
|
|
|
399
|
|
View Code Duplication |
if($mode === 'M') |
400
|
|
|
{ |
401
|
|
|
$skin_info = $oModuleModel->loadSkinInfo($module_path, $skin, 'm.skins'); |
402
|
|
|
$skin_vars = $oModuleModel->getModuleMobileSkinVars($module_srl); |
403
|
|
|
} |
404
|
|
|
else |
405
|
|
|
{ |
406
|
|
|
$skin_info = $oModuleModel->loadSkinInfo($module_path, $skin); |
407
|
|
|
$skin_vars = $oModuleModel->getModuleSkinVars($module_srl); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
// Check received variables (unset such variables as act, module_srl, page, mid, module) |
411
|
|
|
$obj = Context::getRequestVars(); |
412
|
|
|
unset($obj->act); |
413
|
|
|
unset($obj->error_return_url); |
414
|
|
|
unset($obj->module_srl); |
415
|
|
|
unset($obj->page); |
416
|
|
|
unset($obj->mid); |
417
|
|
|
unset($obj->module); |
418
|
|
|
unset($obj->_mode); |
419
|
|
|
// Separately handle if a type of extra_vars is an image in the original skin_info |
420
|
|
|
if($skin_info->extra_vars) |
421
|
|
|
{ |
422
|
|
|
foreach($skin_info->extra_vars as $vars) |
423
|
|
|
{ |
424
|
|
|
if($vars->type!='image') continue; |
425
|
|
|
|
426
|
|
|
$image_obj = $obj->{$vars->name}; |
427
|
|
|
// Get a variable to delete |
428
|
|
|
$del_var = $obj->{"del_".$vars->name}; |
429
|
|
|
unset($obj->{"del_".$vars->name}); |
430
|
|
|
if($del_var == 'Y') |
431
|
|
|
{ |
432
|
|
|
FileHandler::removeFile($skin_vars[$vars->name]->value); |
433
|
|
|
continue; |
434
|
|
|
} |
435
|
|
|
// Use the previous data if not uploaded |
436
|
|
|
if(!$image_obj['tmp_name']) |
437
|
|
|
{ |
438
|
|
|
$obj->{$vars->name} = $skin_vars[$vars->name]->value; |
439
|
|
|
continue; |
440
|
|
|
} |
441
|
|
|
// Ignore if the file is not successfully uploaded |
442
|
|
View Code Duplication |
if(!is_uploaded_file($image_obj['tmp_name']) || !checkUploadedFile($image_obj['tmp_name'])) |
443
|
|
|
{ |
444
|
|
|
unset($obj->{$vars->name}); |
445
|
|
|
continue; |
446
|
|
|
} |
447
|
|
|
// Ignore if the file is not an image |
448
|
|
|
if(!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name'])) |
449
|
|
|
{ |
450
|
|
|
unset($obj->{$vars->name}); |
451
|
|
|
continue; |
452
|
|
|
} |
453
|
|
|
// Upload the file to a path |
454
|
|
|
$path = sprintf("./files/attach/images/%s/", $module_srl); |
455
|
|
|
// Create a directory |
456
|
|
|
if(!FileHandler::makeDir($path)) return false; |
|
|
|
|
457
|
|
|
|
458
|
|
|
$filename = $path.$image_obj['name']; |
459
|
|
|
// Move the file |
460
|
|
|
if(!move_uploaded_file($image_obj['tmp_name'], $filename)) |
461
|
|
|
{ |
462
|
|
|
unset($obj->{$vars->name}); |
463
|
|
|
continue; |
464
|
|
|
} |
465
|
|
|
// Upload the file |
466
|
|
|
FileHandler::removeFile($skin_vars[$vars->name]->value); |
467
|
|
|
// Change a variable |
468
|
|
|
unset($obj->{$vars->name}); |
469
|
|
|
$obj->{$vars->name} = $filename; |
470
|
|
|
} |
471
|
|
|
} |
472
|
|
|
// Load the entire skin of the module and then remove the image |
473
|
|
|
/* |
474
|
|
|
if($skin_info->extra_vars) { |
475
|
|
|
foreach($skin_info->extra_vars as $vars) { |
476
|
|
|
if($vars->type!='image') continue; |
477
|
|
|
$value = $skin_vars[$vars->name]; |
478
|
|
|
if(file_exists($value)) @unlink($value); |
479
|
|
|
} |
480
|
|
|
} |
481
|
|
|
*/ |
482
|
|
|
$oModuleController = getController('module'); |
483
|
|
|
|
484
|
|
|
if($mode === 'M') |
485
|
|
|
{ |
486
|
|
|
$output = $oModuleController->insertModuleMobileSkinVars($module_srl, $obj); |
487
|
|
|
} |
488
|
|
|
else |
489
|
|
|
{ |
490
|
|
|
$output = $oModuleController->insertModuleSkinVars($module_srl, $obj); |
491
|
|
|
} |
492
|
|
|
if(!$output->toBool()) |
493
|
|
|
{ |
494
|
|
|
return $output; |
495
|
|
|
} |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
$this->setMessage('success_saved'); |
499
|
|
|
$this->setRedirectUrl(Context::get('error_return_url')); |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* @brief List module information |
504
|
|
|
*/ |
505
|
|
|
function procModuleAdminModuleSetup() |
506
|
|
|
{ |
507
|
|
|
$vars = Context::getRequestVars(); |
508
|
|
|
|
509
|
|
|
if(!$vars->module_srls) return new BaseObject(-1,'msg_invalid_request'); |
|
|
|
|
510
|
|
|
|
511
|
|
|
$module_srls = explode(',',$vars->module_srls); |
512
|
|
|
if(count($module_srls) < 1) return new BaseObject(-1,'msg_invalid_request'); |
513
|
|
|
|
514
|
|
|
$oModuleModel = getModel('module'); |
515
|
|
|
$oModuleController= getController('module'); |
516
|
|
|
$columnList = array('module_srl', 'module', 'menu_srl', 'site_srl', 'mid', 'browser_title', 'is_default', 'content', 'mcontent', 'open_rss', 'regdate'); |
517
|
|
|
$updateList = array('module_category_srl','layout_srl','skin','mlayout_srl','mskin','description','header_text','footer_text', 'use_mobile'); |
518
|
|
|
foreach($updateList as $key=>$val) |
519
|
|
|
{ |
520
|
|
|
if(!strlen($vars->{$val})) |
521
|
|
|
{ |
522
|
|
|
unset($updateList[$key]); |
523
|
|
|
$columnList[] = $val; |
524
|
|
|
} |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
foreach($module_srls as $module_srl) |
528
|
|
|
{ |
529
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
530
|
|
|
|
531
|
|
|
foreach($updateList as $val) |
532
|
|
|
{ |
533
|
|
|
$module_info->{$val} = $vars->{$val}; |
534
|
|
|
} |
535
|
|
|
$output = $oModuleController->updateModule($module_info); |
|
|
|
|
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
$this->setMessage('success_registed'); |
539
|
|
View Code Duplication |
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
540
|
|
|
{ |
541
|
|
|
if(Context::get('success_return_url')) |
542
|
|
|
{ |
543
|
|
|
$this->setRedirectUrl(Context::get('success_return_url')); |
544
|
|
|
} |
545
|
|
|
else |
546
|
|
|
{ |
547
|
|
|
global $lang; |
548
|
|
|
htmlHeader(); |
549
|
|
|
alertScript($lang->success_registed); |
550
|
|
|
closePopupScript(); |
551
|
|
|
htmlFooter(); |
552
|
|
|
Context::close(); |
553
|
|
|
exit; |
554
|
|
|
} |
555
|
|
|
} |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* @brief List permissions of the module |
560
|
|
|
*/ |
561
|
|
|
function procModuleAdminModuleGrantSetup() |
562
|
|
|
{ |
563
|
|
|
$module_srls = Context::get('module_srls'); |
564
|
|
|
if(!$module_srls) return new BaseObject(-1,'msg_invalid_request'); |
565
|
|
|
|
566
|
|
|
$modules = explode(',',$module_srls); |
567
|
|
|
if(count($modules) < 1) return new BaseObject(-1,'msg_invalid_request'); |
568
|
|
|
|
569
|
|
|
$oModuleController = getController('module'); |
|
|
|
|
570
|
|
|
$oModuleModel = getModel('module'); |
571
|
|
|
|
572
|
|
|
$columnList = array('module_srl', 'module'); |
573
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($modules[0], $columnList); |
574
|
|
|
$xml_info = $oModuleModel->getModuleActionXml($module_info->module); |
575
|
|
|
$grant_list = $xml_info->grant; |
576
|
|
|
|
577
|
|
|
$grant_list->access = new stdClass(); |
578
|
|
|
$grant_list->access->default = 'guest'; |
579
|
|
|
$grant_list->manager = new stdClass(); |
580
|
|
|
$grant_list->manager->default = 'manager'; |
581
|
|
|
|
582
|
|
|
$grant = new stdClass; |
583
|
|
|
|
584
|
|
View Code Duplication |
foreach($grant_list as $grant_name => $grant_info) |
585
|
|
|
{ |
586
|
|
|
// Get the default value |
587
|
|
|
$default = Context::get($grant_name.'_default'); |
588
|
|
|
// -1 = Sign only, 0 = all users |
589
|
|
|
$grant->{$grant_name} = array(); |
590
|
|
|
if(strlen($default)) |
591
|
|
|
{ |
592
|
|
|
$grant->{$grant_name}[] = $default; |
593
|
|
|
continue; |
594
|
|
|
// Users in a particular group |
595
|
|
|
} |
596
|
|
|
else |
597
|
|
|
{ |
598
|
|
|
$group_srls = Context::get($grant_name); |
599
|
|
|
if($group_srls) |
600
|
|
|
{ |
601
|
|
|
if(!is_array($group_srls)) |
602
|
|
|
{ |
603
|
|
|
if(strpos($group_srls,'|@|')!==false) $group_srls = explode('|@|',$group_srls); |
604
|
|
|
elseif(strpos($group_srls,',')!==false) $group_srls = explode(',',$group_srls); |
605
|
|
|
else $group_srls = array($group_srls); |
606
|
|
|
} |
607
|
|
|
$grant->{$grant_name} = $group_srls; |
608
|
|
|
} |
609
|
|
|
continue; |
610
|
|
|
} |
611
|
|
|
$grant->{$group_srls} = array(); // dead code, too?? |
|
|
|
|
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
// Stored in the DB |
615
|
|
|
foreach($modules as $module_srl) |
616
|
|
|
{ |
617
|
|
|
$args = new stdClass(); |
618
|
|
|
$args->module_srl = $module_srl; |
619
|
|
|
$output = executeQuery('module.deleteModuleGrants', $args); |
620
|
|
|
if(!$output->toBool()) continue; |
621
|
|
|
// Permissions stored in the DB |
622
|
|
View Code Duplication |
foreach($grant as $grant_name => $group_srls) |
|
|
|
|
623
|
|
|
{ |
624
|
|
|
foreach($group_srls as $val) |
625
|
|
|
{ |
626
|
|
|
$args = new stdClass(); |
627
|
|
|
$args->module_srl = $module_srl; |
628
|
|
|
$args->name = $grant_name; |
629
|
|
|
$args->group_srl = $val; |
630
|
|
|
$output = executeQuery('module.insertModuleGrant', $args); |
631
|
|
|
if(!$output->toBool()) return $output; |
632
|
|
|
} |
633
|
|
|
} |
634
|
|
|
} |
635
|
|
|
$this->setMessage('success_registed'); |
636
|
|
View Code Duplication |
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) |
637
|
|
|
{ |
638
|
|
|
if(Context::get('success_return_url')) |
639
|
|
|
{ |
640
|
|
|
$this->setRedirectUrl(Context::get('success_return_url')); |
641
|
|
|
} |
642
|
|
|
else |
643
|
|
|
{ |
644
|
|
|
global $lang; |
645
|
|
|
htmlHeader(); |
646
|
|
|
alertScript($lang->success_registed); |
647
|
|
|
closePopupScript(); |
648
|
|
|
htmlFooter(); |
649
|
|
|
Context::close(); |
650
|
|
|
exit; |
651
|
|
|
} |
652
|
|
|
} |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
/** |
656
|
|
|
* @brief Add/Update language |
657
|
|
|
*/ |
658
|
|
|
function procModuleAdminInsertLang() |
659
|
|
|
{ |
660
|
|
|
// Get language code |
661
|
|
|
$site_module_info = Context::get('site_module_info'); |
662
|
|
|
$target = Context::get('target'); |
663
|
|
|
$module = Context::get('module'); |
664
|
|
|
$args = new stdClass(); |
665
|
|
|
$args->site_srl = (int)$site_module_info->site_srl; |
666
|
|
|
$args->name = str_replace(' ','_',Context::get('lang_code')); |
667
|
|
|
$args->lang_name = str_replace(' ','_',Context::get('lang_name')); |
668
|
|
|
if(!empty($args->lang_name)) $args->name = $args->lang_name; |
669
|
|
|
|
670
|
|
|
// if args->name is empty, random generate for user define language |
671
|
|
|
if(empty($args->name)) $args->name = 'userLang'.date('YmdHis').''.sprintf('%03d', mt_rand(0, 100)); |
672
|
|
|
|
673
|
|
|
if(!$args->name) return new BaseObject(-1,'msg_invalid_request'); |
674
|
|
|
// Check whether a language code exists |
675
|
|
|
$output = executeQueryArray('module.getLang', $args); |
676
|
|
|
if(!$output->toBool()) return $output; |
677
|
|
|
// If exists, clear the old values for updating |
678
|
|
|
if($output->data) $output = executeQuery('module.deleteLang', $args); |
679
|
|
|
if(!$output->toBool()) return $output; |
680
|
|
|
// Enter |
681
|
|
|
$lang_supported = Context::get('lang_supported'); |
682
|
|
|
foreach($lang_supported as $key => $val) |
|
|
|
|
683
|
|
|
{ |
684
|
|
|
$args->lang_code = $key; |
685
|
|
|
$args->value = trim(Context::get($key)); |
686
|
|
|
|
687
|
|
|
// if request method is json, strip slashes |
688
|
|
|
if(Context::getRequestMethod() == 'JSON' && version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
689
|
|
|
{ |
690
|
|
|
$args->value = stripslashes($args->value); |
691
|
|
|
} |
692
|
|
|
|
693
|
|
|
if($args->value) |
694
|
|
|
{ |
695
|
|
|
$output = executeQuery('module.insertLang', $args); |
696
|
|
|
if(!$output->toBool()) return $output; |
697
|
|
|
} |
698
|
|
|
} |
699
|
|
|
$this->makeCacheDefinedLangCode($args->site_srl); |
700
|
|
|
|
701
|
|
|
$this->add('name', $args->name); |
702
|
|
|
$this->setMessage("success_saved", 'info'); |
703
|
|
|
|
704
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', $module, 'target', $target, 'act', 'dispModuleAdminLangcode'); |
705
|
|
|
$this->setRedirectUrl($returnUrl); |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
/** |
709
|
|
|
* @brief Remove language |
710
|
|
|
*/ |
711
|
|
|
function procModuleAdminDeleteLang() |
712
|
|
|
{ |
713
|
|
|
// Get language code |
714
|
|
|
$site_module_info = Context::get('site_module_info'); |
715
|
|
|
$args = new stdClass(); |
716
|
|
|
$args->site_srl = (int)$site_module_info->site_srl; |
717
|
|
|
$args->name = str_replace(' ','_',Context::get('name')); |
718
|
|
|
$args->lang_name = str_replace(' ','_',Context::get('lang_name')); |
719
|
|
|
if(!empty($args->lang_name)) $args->name = $args->lang_name; |
720
|
|
|
if(!$args->name) return new BaseObject(-1,'msg_invalid_request'); |
721
|
|
|
|
722
|
|
|
$output = executeQuery('module.deleteLang', $args); |
723
|
|
|
if(!$output->toBool()) return $output; |
724
|
|
|
$this->makeCacheDefinedLangCode($args->site_srl); |
725
|
|
|
|
726
|
|
|
$this->setMessage("success_deleted", 'info'); |
727
|
|
|
|
728
|
|
|
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispModuleAdminLangcode'); |
729
|
|
|
$this->setRedirectUrl($returnUrl); |
730
|
|
|
} |
731
|
|
|
|
732
|
|
|
function procModuleAdminGetList() |
733
|
|
|
{ |
734
|
|
|
if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
735
|
|
|
|
736
|
|
|
$oModuleController = getController('module'); |
737
|
|
|
$oModuleModel = getModel('module'); |
738
|
|
|
// Variable setting for site keyword |
739
|
|
|
$site_keyword = Context::get('site_keyword'); |
740
|
|
|
$site_srl = Context::get('site_srl'); |
741
|
|
|
$vid = Context::get('vid'); |
742
|
|
|
|
743
|
|
|
// If there is no site keyword, use as information of the current virtual site |
744
|
|
|
$args = new stdClass; |
745
|
|
|
$logged_info = Context::get('logged_info'); |
746
|
|
|
$site_module_info = Context::get('site_module_info'); |
747
|
|
|
if($site_keyword) $args->site_keyword = $site_keyword; |
748
|
|
|
|
749
|
|
|
if(!$site_srl) |
750
|
|
|
{ |
751
|
|
View Code Duplication |
if($logged_info->is_admin == 'Y' && !$site_keyword && !$vid) $args->site_srl = 0; |
752
|
|
|
else $args->site_srl = (int)$site_module_info->site_srl; |
753
|
|
|
} |
754
|
|
|
else $args->site_srl = $site_srl; |
755
|
|
|
|
756
|
|
|
$args->sort_index1 = 'sites.domain'; |
757
|
|
|
|
758
|
|
|
$moduleCategorySrl = array(); |
759
|
|
|
// Get a list of modules at the site |
760
|
|
|
$output = executeQueryArray('module.getSiteModules', $args); |
761
|
|
|
$mid_list = array(); |
762
|
|
|
if(count($output->data) > 0) |
763
|
|
|
{ |
764
|
|
|
foreach($output->data as $val) |
765
|
|
|
{ |
766
|
|
|
$module = trim($val->module); |
767
|
|
|
if(!$module) continue; |
768
|
|
|
|
769
|
|
|
// replace user defined lang. |
770
|
|
|
$oModuleController->replaceDefinedLangCode($val->browser_title); |
771
|
|
|
|
772
|
|
|
$obj = new stdClass(); |
773
|
|
|
$obj->module_srl = $val->module_srl; |
774
|
|
|
$obj->layout_srl = $val->layout_srl; |
775
|
|
|
$obj->browser_title = $val->browser_title; |
776
|
|
|
$obj->mid = $val->mid; |
777
|
|
|
$obj->module_category_srl = $val->module_category_srl; |
778
|
|
|
if($val->module_category_srl > 0) |
779
|
|
|
{ |
780
|
|
|
$moduleCategorySrl[] = $val->module_category_srl; |
781
|
|
|
} |
782
|
|
|
$mid_list[$module]->list[$val->mid] = $obj; |
783
|
|
|
} |
784
|
|
|
} |
785
|
|
|
|
786
|
|
|
// Get module category name |
787
|
|
|
$moduleCategorySrl = array_unique($moduleCategorySrl); |
788
|
|
|
$output = $oModuleModel->getModuleCategories($moduleCategorySrl); |
789
|
|
|
$categoryNameList = array(); |
790
|
|
|
if(is_array($output)) |
791
|
|
|
{ |
792
|
|
|
foreach($output as $value) |
793
|
|
|
{ |
794
|
|
|
$categoryNameList[$value->module_category_srl] = $value->title; |
795
|
|
|
} |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
$selected_module = Context::get('selected_module'); |
799
|
|
|
if(count($mid_list) > 0) |
800
|
|
|
{ |
801
|
|
|
foreach($mid_list as $module => $val) |
802
|
|
|
{ |
803
|
|
|
if(!$selected_module) $selected_module = $module; |
804
|
|
|
$xml_info = $oModuleModel->getModuleInfoXml($module); |
805
|
|
|
|
806
|
|
|
if(!$xml_info) |
807
|
|
|
{ |
808
|
|
|
unset($mid_list[$module]); |
809
|
|
|
continue; |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
$mid_list[$module]->title = $xml_info->title; |
813
|
|
|
|
814
|
|
|
// change module category srl to title |
815
|
|
|
if(is_array($val->list)) |
816
|
|
|
{ |
817
|
|
|
foreach($val->list as $key=>$value) |
818
|
|
|
{ |
819
|
|
|
if($value->module_category_srl > 0) |
820
|
|
|
{ |
821
|
|
|
$categorySrl = $mid_list[$module]->list[$key]->module_category_srl; |
822
|
|
|
if(isset($categoryNameList[$categorySrl])) |
823
|
|
|
{ |
824
|
|
|
$mid_list[$module]->list[$key]->module_category_srl = $categoryNameList[$categorySrl]; |
825
|
|
|
} |
826
|
|
|
} |
827
|
|
|
else |
828
|
|
|
{ |
829
|
|
|
$mid_list[$module]->list[$key]->module_category_srl = Context::getLang('none_category'); |
830
|
|
|
} |
831
|
|
|
} |
832
|
|
|
} |
833
|
|
|
} |
834
|
|
|
} |
835
|
|
|
|
836
|
|
|
$security = new Security($mid_list); |
837
|
|
|
$security->encodeHTML('....browser_title'); |
838
|
|
|
|
839
|
|
|
$this->add('module_list', $mid_list); |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
/** |
843
|
|
|
* @brief Save the file of user-defined language code |
844
|
|
|
*/ |
845
|
|
|
function makeCacheDefinedLangCode($site_srl = 0) |
846
|
|
|
{ |
847
|
|
|
$args = new stdClass(); |
848
|
|
|
|
849
|
|
|
// Get the language file of the current site |
850
|
|
View Code Duplication |
if(!$site_srl) |
851
|
|
|
{ |
852
|
|
|
$site_module_info = Context::get('site_module_info'); |
853
|
|
|
$args->site_srl = (int)$site_module_info->site_srl; |
854
|
|
|
} |
855
|
|
|
else |
856
|
|
|
{ |
857
|
|
|
$args->site_srl = $site_srl; |
858
|
|
|
} |
859
|
|
|
$output = executeQueryArray('module.getLang', $args); |
860
|
|
|
if(!$output->toBool() || !$output->data) return; |
861
|
|
|
|
862
|
|
|
$langMap = array(); |
863
|
|
|
foreach($output->data as $lang) |
864
|
|
|
{ |
865
|
|
|
$langMap[$lang->lang_code][$lang->name] = $lang->value; |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
$lang_supported = Context::get('lang_supported'); |
869
|
|
|
$dbInfo = Context::getDBInfo(); |
870
|
|
|
$defaultLang = $dbInfo->lang_type; |
871
|
|
|
|
872
|
|
|
if(!is_array($langMap[$defaultLang])) |
873
|
|
|
{ |
874
|
|
|
$langMap[$defaultLang] = array(); |
875
|
|
|
} |
876
|
|
|
|
877
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
878
|
|
|
|
879
|
|
|
foreach($lang_supported as $langCode => $langName) |
|
|
|
|
880
|
|
|
{ |
881
|
|
|
if(!is_array($langMap[$langCode])) |
882
|
|
|
{ |
883
|
|
|
$langMap[$langCode] = array(); |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
$langMap[$langCode] += $langMap[$defaultLang]; |
887
|
|
|
foreach($lang_supported as $targetLangCode => $targetLangName) |
|
|
|
|
888
|
|
|
{ |
889
|
|
|
if($langCode == $targetLangCode || $langCode == $defaultLang) |
890
|
|
|
{ |
891
|
|
|
continue; |
892
|
|
|
} |
893
|
|
|
|
894
|
|
|
if(!is_array($langMap[$targetLangCode])) |
895
|
|
|
{ |
896
|
|
|
$langMap[$targetLangCode] = array(); |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
$langMap[$langCode] += $langMap[$targetLangCode]; |
900
|
|
|
} |
901
|
|
|
|
902
|
|
|
if($oCacheHandler->isSupport()) |
903
|
|
|
{ |
904
|
|
|
$object_key = 'user_defined_langs:' . $args->site_srl . ':' . $langCode; |
905
|
|
|
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
906
|
|
|
$oCacheHandler->put($cache_key, $langMap[$langCode]); |
907
|
|
|
} |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
return $langMap[Context::getLangType()]; |
911
|
|
|
} |
912
|
|
|
|
913
|
|
|
public function procModuleAdminSetDesignInfo() |
914
|
|
|
{ |
915
|
|
|
$moduleSrl = Context::get('target_module_srl'); |
916
|
|
|
$mid = Context::get('target_mid'); |
917
|
|
|
|
918
|
|
|
$skinType = Context::get('skin_type'); |
919
|
|
|
$skinType = ($skinType == 'M') ? 'M' : 'P'; |
920
|
|
|
|
921
|
|
|
$layoutSrl = Context::get('layout_srl'); |
922
|
|
|
|
923
|
|
|
$isSkinFix = Context::get('is_skin_fix'); |
924
|
|
|
|
925
|
|
|
if($isSkinFix) |
926
|
|
|
{ |
927
|
|
|
$isSkinFix = ($isSkinFix == 'N') ? 'N' : 'Y'; |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
$skinName = Context::get('skin_name'); |
931
|
|
|
$skinVars = Context::get('skin_vars'); |
932
|
|
|
|
933
|
|
|
$output = $this->setDesignInfo($moduleSrl, $mid, $skinType, $layoutSrl, $isSkinFix, $skinName, $skinVars); |
934
|
|
|
|
935
|
|
|
return $output; |
936
|
|
|
|
937
|
|
|
} |
938
|
|
|
|
939
|
|
|
public function setDesignInfo($moduleSrl = 0, $mid = '', $skinType = 'P', $layoutSrl = 0, $isSkinFix = 'Y', $skinName = '', $skinVars = NULL) |
940
|
|
|
{ |
941
|
|
|
if(!$moduleSrl && !$mid) |
942
|
|
|
{ |
943
|
|
|
return $this->stop(-1, 'msg_invalid_request'); |
|
|
|
|
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
$oModuleModel = getModel('module'); |
947
|
|
|
|
948
|
|
|
if($mid) |
949
|
|
|
{ |
950
|
|
|
$moduleInfo = $oModuleModel->getModuleInfoByMid($mid); |
951
|
|
|
} |
952
|
|
|
else |
953
|
|
|
{ |
954
|
|
|
$moduleInfo = $oModuleModel->getModuleInfoByModuleSrl($moduleSrl); |
955
|
|
|
} |
956
|
|
|
|
957
|
|
|
if(!$moduleInfo) |
958
|
|
|
{ |
959
|
|
|
return $this->stop(-1, 'msg_module_not_exists'); |
|
|
|
|
960
|
|
|
} |
961
|
|
|
|
962
|
|
|
$skinTargetValue = ($skinType == 'M') ? 'mskin' : 'skin'; |
963
|
|
|
$layoutTargetValue = ($skinType == 'M') ? 'mlayout_srl' : 'layout_srl'; |
964
|
|
|
$skinFixTargetValue = ($skinType == 'M') ? 'is_mskin_fix' : 'is_skin_fix'; |
965
|
|
|
|
966
|
|
|
if(strlen($layoutSrl)) |
967
|
|
|
{ |
968
|
|
|
$moduleInfo->{$layoutTargetValue} = $layoutSrl; |
969
|
|
|
} |
970
|
|
|
|
971
|
|
|
if(strlen($isSkinFix)) |
972
|
|
|
{ |
973
|
|
|
$moduleInfo->{$skinFixTargetValue} = $isSkinFix; |
974
|
|
|
} |
975
|
|
|
|
976
|
|
|
if($isSkinFix == 'Y') |
977
|
|
|
{ |
978
|
|
|
$moduleInfo->{$skinTargetValue} = $skinName; |
979
|
|
|
$skinVars = json_decode($skinVars); |
980
|
|
|
|
981
|
|
|
if(is_array($skinVars)) |
982
|
|
|
{ |
983
|
|
|
foreach($skinVars as $key => $val) |
984
|
|
|
{ |
985
|
|
|
if(empty($val)) |
986
|
|
|
{ |
987
|
|
|
continue; |
988
|
|
|
} |
989
|
|
|
|
990
|
|
|
$moduleInfo->{$key} = $val; |
991
|
|
|
} |
992
|
|
|
} |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
$oModuleController = getController('module'); |
996
|
|
|
$output = $oModuleController->updateModule($moduleInfo); |
997
|
|
|
|
998
|
|
|
return $output; |
999
|
|
|
} |
1000
|
|
|
|
1001
|
|
|
public function procModuleAdminUpdateUseMobile() |
1002
|
|
|
{ |
1003
|
|
|
$menuItemSrl = Context::get('menu_item_srl'); |
1004
|
|
|
$useMobile = Context::get('use_mobile'); |
1005
|
|
|
|
1006
|
|
|
if(!$menuItemSrl) |
1007
|
|
|
{ |
1008
|
|
|
return $this->stop(-1, 'msg_invalid_request'); |
|
|
|
|
1009
|
|
|
} |
1010
|
|
|
|
1011
|
|
|
$oModuleModel = getModel('module'); |
1012
|
|
|
$moduleInfo = $oModuleModel->getModuleInfoByMenuItemSrl($menuItemSrl); |
1013
|
|
|
|
1014
|
|
|
// designSettings is not original module info, so unset |
1015
|
|
|
unset($moduleInfo->designSettings); |
1016
|
|
|
|
1017
|
|
|
$useMobile = $useMobile != 'Y' ? 'N' : 'Y'; |
1018
|
|
|
|
1019
|
|
|
$moduleInfo->use_mobile = $useMobile; |
1020
|
|
|
|
1021
|
|
|
$oModuleController = getController('module'); |
1022
|
|
|
$output = $oModuleController->updateModule($moduleInfo); |
1023
|
|
|
|
1024
|
|
|
return $output; |
1025
|
|
|
} |
1026
|
|
|
} |
1027
|
|
|
/* End of file module.admin.controller.php */ |
1028
|
|
|
/* Location: ./modules/module/module.admin.controller.php */ |
1029
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.