1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* High class of addon modules |
6
|
|
|
* @author NAVER ([email protected]) |
7
|
|
|
*/ |
8
|
|
|
class addon extends ModuleObject |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Implement if additional tasks are necessary when installing |
13
|
|
|
* |
14
|
|
|
* @return Object |
15
|
|
|
*/ |
16
|
|
|
function moduleInstall() |
17
|
|
|
{ |
18
|
|
|
// Register to add a few |
19
|
|
|
$oAddonController = getAdminController('addon'); |
20
|
|
|
$oAddonController->doInsert('autolink', 0, 'site', 'Y'); |
21
|
|
|
$oAddonController->doInsert('blogapi'); |
22
|
|
|
$oAddonController->doInsert('member_communication', 0, 'site', 'Y'); |
23
|
|
|
$oAddonController->doInsert('member_extra_info', 0, 'site', 'Y'); |
24
|
|
|
$oAddonController->doInsert('mobile', 0, 'site', 'Y'); |
25
|
|
|
$oAddonController->doInsert('resize_image', 0, 'site', 'Y'); |
26
|
|
|
$oAddonController->doInsert('openid_delegation_id'); |
27
|
|
|
$oAddonController->doInsert('point_level_icon'); |
28
|
|
|
|
29
|
|
|
$oAddonController->makeCacheFile(0); |
30
|
|
|
return new Object(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* A method to check if successfully installed |
35
|
|
|
* |
36
|
|
|
* @return bool |
37
|
|
|
*/ |
38
|
|
View Code Duplication |
function checkUpdate() |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
$oDB = DB::getInstance(); |
41
|
|
|
$oModuleModel = getModel('module'); |
|
|
|
|
42
|
|
|
$oModuleController = getController('module'); |
43
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
44
|
|
|
{ |
45
|
|
|
if(!$oDB->isColumnExists("addons", "is_used_m")) |
46
|
|
|
{ |
47
|
|
|
return TRUE; |
48
|
|
|
} |
49
|
|
|
if(!$oDB->isColumnExists("addons_site", "is_used_m")) |
50
|
|
|
{ |
51
|
|
|
return TRUE; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// 2011. 7. 29. add is_fixed column |
55
|
|
|
if(!$oDB->isColumnExists('addons', 'is_fixed')) |
56
|
|
|
{ |
57
|
|
|
return TRUE; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return FALSE; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Execute update |
68
|
|
|
* |
69
|
|
|
* @return Object |
70
|
|
|
*/ |
71
|
|
|
function moduleUpdate() |
72
|
|
|
{ |
73
|
|
|
$oDB = DB::getInstance(); |
74
|
|
|
|
75
|
|
|
$oModuleModel = getModel('module'); |
76
|
|
|
$oModuleController = getController('module'); |
77
|
|
|
$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated')); |
78
|
|
|
if($oModuleModel->needUpdate($version_update_id)) |
79
|
|
|
{ |
80
|
|
|
if(!$oDB->isColumnExists("addons", "is_used_m")) |
81
|
|
|
{ |
82
|
|
|
$oDB->addColumn("addons", "is_used_m", "char", 1, "N", TRUE); |
83
|
|
|
} |
84
|
|
|
if(!$oDB->isColumnExists("addons_site", "is_used_m")) |
85
|
|
|
{ |
86
|
|
|
$oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", TRUE); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
// 2011. 7. 29. add is_fixed column |
90
|
|
|
if(!$oDB->isColumnExists('addons', 'is_fixed')) |
91
|
|
|
{ |
92
|
|
|
$oDB->addColumn('addons', 'is_fixed', 'char', 1, 'N', TRUE); |
93
|
|
|
|
94
|
|
|
// move addon info to addon_site table |
95
|
|
|
$output = executeQueryArray('addon.getAddons'); |
96
|
|
|
if($output->data) |
97
|
|
|
{ |
98
|
|
|
foreach($output->data as $row) |
99
|
|
|
{ |
100
|
|
|
$args = new stdClass(); |
101
|
|
|
$args->site_srl = 0; |
102
|
|
|
$args->addon = $row->addon; |
103
|
|
|
$args->is_used = $row->is_used; |
104
|
|
|
$args->is_used_m = $row->is_used_m; |
105
|
|
|
$args->extra_vars = $row->extra_vars; |
106
|
|
|
executeQuery('addon.insertSiteAddon', $args); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
$oModuleController->insertUpdatedLog($version_update_id); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return new Object(0, 'success_updated'); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Re-generate the cache file |
118
|
|
|
* |
119
|
|
|
* @return Object |
120
|
|
|
*/ |
121
|
|
|
function recompileCache() |
122
|
|
|
{ |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
} |
127
|
|
|
/* End of file addon.class.php */ |
128
|
|
|
/* Location: ./modules/addon/addon.class.php */ |
129
|
|
|
|
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.