1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
|
4
|
|
|
require_once(_XE_PATH_ . 'modules/comment/comment.item.php'); |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* comment |
8
|
|
|
* comment module's high class |
9
|
|
|
* |
10
|
|
|
* @author NAVER ([email protected]) |
11
|
|
|
* @package /modules/comment |
12
|
|
|
* @version 0.1 |
13
|
|
|
*/ |
14
|
|
|
class comment extends ModuleObject |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Implemented if additional tasks are required when installing |
19
|
|
|
* @return Object |
20
|
|
|
*/ |
21
|
|
|
function moduleInstall() |
22
|
|
|
{ |
23
|
|
|
$oDB = DB::getInstance(); |
24
|
|
|
|
25
|
|
|
// register the action forward (for using on the admin mode) |
26
|
|
|
$oModuleController = getController('module'); |
27
|
|
|
|
28
|
|
|
$oDB->addIndex( |
29
|
|
|
"comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
// 2007. 10. 17 add a trigger to delete comments together with posting deleted |
33
|
|
|
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'); |
34
|
|
|
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted |
35
|
|
|
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'); |
36
|
|
|
// 2008. 02. 22 add comment setting when a new module added |
37
|
|
|
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'); |
38
|
|
|
|
39
|
|
|
if(!is_dir('./files/cache/tmp')) |
40
|
|
|
{ |
41
|
|
|
FileHandler::makeDir('./files/cache/tmp'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return new Object(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Method to check if installation is succeeded |
49
|
|
|
* @return bool |
50
|
|
|
*/ |
51
|
|
|
function checkUpdate() |
52
|
|
|
{ |
53
|
|
|
$oDB = DB::getInstance(); |
54
|
|
|
$oModuleModel = getModel('module'); |
55
|
|
|
// 2007. 10. 17 add a trigger to delete comments together with posting deleted |
56
|
|
|
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) |
57
|
|
|
{ |
58
|
|
|
return TRUE; |
59
|
|
|
} |
60
|
|
|
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted |
61
|
|
|
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) |
62
|
|
|
{ |
63
|
|
|
return TRUE; |
64
|
|
|
} |
65
|
|
|
// 2007. 10. 23 add a column for recommendation votes or notification of the comments |
66
|
|
|
if(!$oDB->isColumnExists("comments", "voted_count")) |
67
|
|
|
{ |
68
|
|
|
return TRUE; |
69
|
|
|
} |
70
|
|
|
if(!$oDB->isColumnExists("comments", "notify_message")) |
71
|
|
|
{ |
72
|
|
|
return TRUE; |
73
|
|
|
} |
74
|
|
|
// 2008. 02. 22 add comment setting when a new module added |
75
|
|
|
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) |
76
|
|
|
{ |
77
|
|
|
return TRUE; |
78
|
|
|
} |
79
|
|
|
// 2008. 05. 14 add a column for blamed count |
80
|
|
|
if(!$oDB->isColumnExists("comments", "blamed_count")) |
81
|
|
|
{ |
82
|
|
|
return TRUE; |
83
|
|
|
} |
84
|
|
|
if(!$oDB->isColumnExists("comment_voted_log", "point")) |
85
|
|
|
{ |
86
|
|
|
return TRUE; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if(!$oDB->isIndexExists("comments", "idx_module_list_order")) |
90
|
|
|
{ |
91
|
|
|
return TRUE; |
92
|
|
|
} |
93
|
|
|
//2012. 02. 24 add comment published status column and index |
94
|
|
|
if(!$oDB->isColumnExists("comments", "status")) |
95
|
|
|
{ |
96
|
|
|
return TRUE; |
97
|
|
|
} |
98
|
|
|
if(!$oDB->isIndexExists("comments", "idx_status")) |
99
|
|
|
{ |
100
|
|
|
return TRUE; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
104
|
|
|
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) |
105
|
|
|
{ |
106
|
|
|
return TRUE; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return FALSE; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Execute update |
114
|
|
|
* @return Object |
115
|
|
|
*/ |
116
|
|
|
function moduleUpdate() |
117
|
|
|
{ |
118
|
|
|
$oDB = DB::getInstance(); |
119
|
|
|
$oModuleModel = getModel('module'); |
120
|
|
|
$oModuleController = getController('module'); |
121
|
|
|
// 2007. 10. 17 add a trigger to delete comments together with posting deleted |
122
|
|
|
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) |
123
|
|
|
{ |
124
|
|
|
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'); |
125
|
|
|
} |
126
|
|
|
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted |
127
|
|
|
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) |
128
|
|
|
{ |
129
|
|
|
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'); |
130
|
|
|
} |
131
|
|
|
// 2007. 10. 23 add a column for recommendation votes or notification of the comments |
132
|
|
|
if(!$oDB->isColumnExists("comments", "voted_count")) |
133
|
|
|
{ |
134
|
|
|
$oDB->addColumn("comments", "voted_count", "number", "11"); |
135
|
|
|
$oDB->addIndex("comments", "idx_voted_count", array("voted_count")); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
if(!$oDB->isColumnExists("comments", "notify_message")) |
139
|
|
|
{ |
140
|
|
|
$oDB->addColumn("comments", "notify_message", "char", "1"); |
141
|
|
|
} |
142
|
|
|
// 2008. 02. 22 add comment setting when a new module added |
143
|
|
|
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) |
144
|
|
|
{ |
145
|
|
|
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'); |
146
|
|
|
} |
147
|
|
|
// 2008. 05. 14 add a column for blamed count |
148
|
|
View Code Duplication |
if(!$oDB->isColumnExists("comments", "blamed_count")) |
149
|
|
|
{ |
150
|
|
|
$oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, TRUE); |
151
|
|
|
$oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count')); |
152
|
|
|
} |
153
|
|
|
if(!$oDB->isColumnExists("comment_voted_log", "point")) |
154
|
|
|
{ |
155
|
|
|
$oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, TRUE); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
if(!$oDB->isIndexExists("comments", "idx_module_list_order")) |
159
|
|
|
{ |
160
|
|
|
$oDB->addIndex( |
161
|
|
|
"comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE |
162
|
|
|
); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
//2012. 02. 24 add comment published status column and index |
166
|
|
|
if(!$oDB->isColumnExists("comments", "status")) |
167
|
|
|
{ |
168
|
|
|
$oDB->addColumn("comments", "status", "number", 1, 1, TRUE); |
169
|
|
|
} |
170
|
|
|
if(!$oDB->isIndexExists("comments", "idx_status")) |
171
|
|
|
{ |
172
|
|
|
$oDB->addIndex( |
173
|
|
|
"comments", "idx_status", array("status", "comment_srl", "module_srl", "document_srl"), TRUE |
174
|
|
|
); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
178
|
|
|
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) |
179
|
|
|
{ |
180
|
|
|
$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
return new Object(0, 'success_updated'); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Regenerate cache file |
188
|
|
|
* @return void |
189
|
|
|
*/ |
190
|
|
|
function recompileCache() |
191
|
|
|
{ |
192
|
|
|
if(!is_dir('./files/cache/tmp')) |
193
|
|
|
{ |
194
|
|
|
FileHandler::makeDir('./files/cache/tmp'); |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
} |
199
|
|
|
/* End of file comment.class.php */ |
200
|
|
|
/* Location: ./modules/comment/comment.class.php */ |
201
|
|
|
|