|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* commentModel class |
|
6
|
|
|
* model class of the comment module |
|
7
|
|
|
* |
|
8
|
|
|
* @author NAVER ([email protected]) |
|
9
|
|
|
* @package /modules/comment |
|
10
|
|
|
* @version 0.1 |
|
11
|
|
|
*/ |
|
12
|
|
|
class commentModel extends comment |
|
13
|
|
|
{ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Initialization |
|
17
|
|
|
* @return void |
|
18
|
|
|
*/ |
|
19
|
|
|
function init() |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* display the pop-up menu of the post |
|
26
|
|
|
* Print, scrap, vote-up(recommen), vote-down(non-recommend), report features added |
|
27
|
|
|
* @return void |
|
28
|
|
|
*/ |
|
29
|
|
|
function getCommentMenu() |
|
30
|
|
|
{ |
|
31
|
|
|
// get the post's id number and the current login information |
|
32
|
|
|
$comment_srl = Context::get('target_srl'); |
|
33
|
|
|
$mid = Context::get('cur_mid'); |
|
|
|
|
|
|
34
|
|
|
$logged_info = Context::get('logged_info'); |
|
35
|
|
|
$act = Context::get('cur_act'); |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
// array values for menu_list, "comment post, target, url" |
|
38
|
|
|
$menu_list = array(); |
|
39
|
|
|
|
|
40
|
|
|
// call a trigger |
|
41
|
|
|
ModuleHandler::triggerCall('comment.getCommentMenu', 'before', $menu_list); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
$oCommentController = getController('comment'); |
|
44
|
|
|
|
|
45
|
|
|
// feature that only member can do |
|
46
|
|
|
if($logged_info->member_srl) |
|
47
|
|
|
{ |
|
48
|
|
|
$oCommentModel = getModel('comment'); |
|
49
|
|
|
$columnList = array('comment_srl', 'module_srl', 'member_srl', 'ipaddress'); |
|
50
|
|
|
$oComment = $oCommentModel->getComment($comment_srl, FALSE, $columnList); |
|
51
|
|
|
$module_srl = $oComment->get('module_srl'); |
|
52
|
|
|
$member_srl = $oComment->get('member_srl'); |
|
53
|
|
|
|
|
54
|
|
|
$oModuleModel = getModel('module'); |
|
55
|
|
|
$comment_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
56
|
|
|
|
|
57
|
|
|
if($comment_config->use_vote_up != 'N' && $member_srl != $logged_info->member_srl) |
|
58
|
|
|
{ |
|
59
|
|
|
// Add a vote-up button for positive feedback |
|
60
|
|
|
$url = sprintf("doCallModuleAction('comment','procCommentVoteUp','%s')", $comment_srl); |
|
61
|
|
|
$oCommentController->addCommentPopupMenu($url, 'cmd_vote', '', 'javascript'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
View Code Duplication |
if($comment_config->use_vote_down != 'N' && $member_srl != $logged_info->member_srl) |
|
65
|
|
|
{ |
|
66
|
|
|
// Add a vote-down button for negative feedback |
|
67
|
|
|
$url = sprintf("doCallModuleAction('comment','procCommentVoteDown','%s')", $comment_srl); |
|
68
|
|
|
$oCommentController->addCommentPopupMenu($url, 'cmd_vote_down', '', 'javascript'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
// Add the report feature against abused posts |
|
72
|
|
|
$url = sprintf("doCallModuleAction('comment','procCommentDeclare','%s')", $comment_srl); |
|
73
|
|
|
$oCommentController->addCommentPopupMenu($url, 'cmd_declare', '', 'javascript'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
// call a trigger (after) |
|
77
|
|
|
ModuleHandler::triggerCall('comment.getCommentMenu', 'after', $menu_list); |
|
78
|
|
|
|
|
79
|
|
View Code Duplication |
if($this->grant->manager){ |
|
|
|
|
|
|
80
|
|
|
$str_confirm = Context::getLang('confirm_move'); |
|
81
|
|
|
$url = sprintf("if(!confirm('%s')) return; var params = new Array(); params['comment_srl']='%s'; params['mid']=current_mid;params['cur_url']=current_url; exec_xml('comment', 'procCommentAdminMoveToTrash', params)", $str_confirm, $comment_srl); |
|
82
|
|
|
$oCommentController->addCommentPopupMenu($url,'cmd_trash','','javascript'); |
|
83
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
// find a comment by IP matching if an administrator. |
|
87
|
|
View Code Duplication |
if($logged_info->is_admin == 'Y') |
|
88
|
|
|
{ |
|
89
|
|
|
$oCommentModel = getModel('comment'); |
|
90
|
|
|
$oComment = $oCommentModel->getComment($comment_srl); |
|
91
|
|
|
|
|
92
|
|
|
if($oComment->isExists()) |
|
93
|
|
|
{ |
|
94
|
|
|
// Find a post of the corresponding ip address |
|
95
|
|
|
$url = getUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'ipaddress', 'search_keyword', $oComment->getIpAddress()); |
|
96
|
|
|
$oCommentController->addCommentPopupMenu($url, 'cmd_search_by_ipaddress', $icon_path, 'TraceByIpaddress'); |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
$url = sprintf("var params = new Array(); params['ipaddress_list']='%s'; exec_xml('spamfilter', 'procSpamfilterAdminInsertDeniedIP', params, completeCallModuleAction)", $oComment->getIpAddress()); |
|
99
|
|
|
$oCommentController->addCommentPopupMenu($url, 'cmd_add_ip_to_spamfilter', '', 'javascript'); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
// Changing a language of pop-up menu |
|
104
|
|
|
$menus = Context::get('comment_popup_menu_list'); |
|
105
|
|
|
$menus_count = count($menus); |
|
106
|
|
|
|
|
107
|
|
View Code Duplication |
for($i = 0; $i < $menus_count; $i++) |
|
108
|
|
|
{ |
|
109
|
|
|
$menus[$i]->str = Context::getLang($menus[$i]->str); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
// get a list of final organized pop-up menus |
|
113
|
|
|
$this->add('menus', $menus); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Check if you have a permission to comment_srl |
|
118
|
|
|
* use only session information |
|
119
|
|
|
* @param int $comment_srl |
|
120
|
|
|
* @return bool |
|
121
|
|
|
*/ |
|
122
|
|
|
function isGranted($comment_srl) |
|
123
|
|
|
{ |
|
124
|
|
|
return $_SESSION['own_comment'][$comment_srl]; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Returns the number of child comments |
|
129
|
|
|
* @param int $comment_srl |
|
130
|
|
|
* @return int |
|
131
|
|
|
*/ |
|
132
|
|
|
function getChildCommentCount($comment_srl) |
|
133
|
|
|
{ |
|
134
|
|
|
$args = new stdClass(); |
|
135
|
|
|
$args->comment_srl = $comment_srl; |
|
136
|
|
|
$output = executeQuery('comment.getChildCommentCount', $args, NULL, 'master'); |
|
|
|
|
|
|
137
|
|
|
return (int) $output->data->count; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Returns the number of child comments |
|
142
|
|
|
* @param int $comment_srl |
|
143
|
|
|
* @return int |
|
144
|
|
|
*/ |
|
145
|
|
|
function getChildComments($comment_srl) |
|
146
|
|
|
{ |
|
147
|
|
|
$args = new stdClass(); |
|
148
|
|
|
$args->comment_srl = $comment_srl; |
|
149
|
|
|
$output = executeQueryArray('comment.getChildComments', $args, NULL, 'master'); |
|
|
|
|
|
|
150
|
|
|
return $output->data; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Get the comment |
|
155
|
|
|
* @param int $comment_srl |
|
156
|
|
|
* @param bool $is_admin |
|
157
|
|
|
* @param array $columnList |
|
158
|
|
|
* @return commentItem |
|
159
|
|
|
*/ |
|
160
|
|
|
function getComment($comment_srl = 0, $is_admin = FALSE, $columnList = array()) |
|
161
|
|
|
{ |
|
162
|
|
|
$oComment = new commentItem($comment_srl, $columnList); |
|
163
|
|
|
if($is_admin) |
|
164
|
|
|
{ |
|
165
|
|
|
$oComment->setGrant(); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
return $oComment; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* Get the comment list(not paginating) |
|
173
|
|
|
* @param string|array $comment_srl_list |
|
174
|
|
|
* @param array $columnList |
|
175
|
|
|
* @return array |
|
176
|
|
|
*/ |
|
177
|
|
|
function getComments($comment_srl_list, $columnList = array()) |
|
178
|
|
|
{ |
|
179
|
|
|
if(is_array($comment_srl_list)) |
|
180
|
|
|
{ |
|
181
|
|
|
$comment_srls = implode(',', $comment_srl_list); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
// fetch from a database |
|
185
|
|
|
$args = new stdClass(); |
|
186
|
|
|
$args->comment_srls = $comment_srls; |
|
|
|
|
|
|
187
|
|
|
$output = executeQuery('comment.getComments', $args, $columnList); |
|
188
|
|
|
if(!$output->toBool()) |
|
189
|
|
|
{ |
|
190
|
|
|
return; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
$comment_list = $output->data; |
|
194
|
|
|
if(!$comment_list) |
|
195
|
|
|
{ |
|
196
|
|
|
return; |
|
197
|
|
|
} |
|
198
|
|
|
if(!is_array($comment_list)) |
|
199
|
|
|
{ |
|
200
|
|
|
$comment_list = array($comment_list); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
$comment_count = count($comment_list); |
|
|
|
|
|
|
204
|
|
View Code Duplication |
foreach($comment_list as $key => $attribute) |
|
205
|
|
|
{ |
|
206
|
|
|
if(!$attribute->comment_srl) |
|
207
|
|
|
{ |
|
208
|
|
|
continue; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
$oComment = NULL; |
|
|
|
|
|
|
212
|
|
|
$oComment = new commentItem(); |
|
213
|
|
|
$oComment->setAttribute($attribute); |
|
214
|
|
|
if($is_admin) |
|
|
|
|
|
|
215
|
|
|
{ |
|
216
|
|
|
$oComment->setGrant(); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
$result[$attribute->comment_srl] = $oComment; |
|
|
|
|
|
|
220
|
|
|
} |
|
221
|
|
|
return $result; |
|
|
|
|
|
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Get the total number of comments in corresponding with document_srl. |
|
226
|
|
|
* @param int $document_srl |
|
227
|
|
|
* @return int |
|
228
|
|
|
*/ |
|
229
|
|
|
function getCommentCount($document_srl) |
|
230
|
|
|
{ |
|
231
|
|
|
$args = new stdClass(); |
|
232
|
|
|
$args->document_srl = $document_srl; |
|
233
|
|
|
|
|
234
|
|
|
// get the number of comments on the document module |
|
235
|
|
|
$oDocumentModel = getModel('document'); |
|
236
|
|
|
$columnList = array('document_srl', 'module_srl'); |
|
237
|
|
|
|
|
238
|
|
|
$oDocument = $oDocumentModel->getDocument($document_srl, FALSE, TRUE, $columnList); |
|
239
|
|
|
|
|
240
|
|
|
// return if no doc exists. |
|
241
|
|
|
if(!$oDocument->isExists()) |
|
242
|
|
|
{ |
|
243
|
|
|
return; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
// get a list of comments |
|
247
|
|
|
$module_srl = $oDocument->get('module_srl'); |
|
248
|
|
|
|
|
249
|
|
|
//check if module is using validation system |
|
250
|
|
|
$oCommentController = getController('comment'); |
|
251
|
|
|
|
|
252
|
|
|
$using_validation = $oCommentController->isModuleUsingPublishValidation($module_srl); |
|
253
|
|
|
if($using_validation) |
|
254
|
|
|
{ |
|
255
|
|
|
$args->status = 1; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
$output = executeQuery('comment.getCommentCount', $args, NULL, 'master'); |
|
|
|
|
|
|
259
|
|
|
$total_count = $output->data->count; |
|
260
|
|
|
|
|
261
|
|
|
return (int) $total_count; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Get the total number of comments in corresponding with document_srl. |
|
266
|
|
|
* @param string $date |
|
267
|
|
|
* @param array $moduleSrlList |
|
268
|
|
|
* @return int |
|
269
|
|
|
*/ |
|
270
|
|
|
function getCommentCountByDate($date = '', $moduleSrlList = array()) |
|
271
|
|
|
{ |
|
272
|
|
|
if($date) |
|
273
|
|
|
{ |
|
274
|
|
|
$args->regDate = date('Ymd', strtotime($date)); |
|
|
|
|
|
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
if(count($moduleSrlList) > 0) |
|
278
|
|
|
{ |
|
279
|
|
|
$args->module_srl = $moduleSrlList; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
$output = executeQuery('comment.getCommentCount', $args); |
|
283
|
|
|
if(!$output->toBool()) |
|
284
|
|
|
{ |
|
285
|
|
|
return 0; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
return $output->data->count; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* Get the total number of comments in corresponding with module_srl. |
|
293
|
|
|
* @param int $module_srl |
|
294
|
|
|
* @param bool $published |
|
295
|
|
|
* @return int |
|
296
|
|
|
*/ |
|
297
|
|
|
function getCommentAllCount($module_srl, $published = null) |
|
298
|
|
|
{ |
|
299
|
|
|
$args = new stdClass(); |
|
300
|
|
|
$args->module_srl = $module_srl; |
|
301
|
|
|
|
|
302
|
|
|
if(is_null($published)) |
|
303
|
|
|
{ |
|
304
|
|
|
// check if module is using comment validation system |
|
305
|
|
|
$oCommentController = getController("comment"); |
|
306
|
|
|
$is_using_validation = $oCommentController->isModuleUsingPublishValidation($module_srl); |
|
307
|
|
|
if($is_using_validation) |
|
308
|
|
|
{ |
|
309
|
|
|
$args->status = 1; |
|
310
|
|
|
} |
|
311
|
|
|
} |
|
312
|
|
|
else |
|
313
|
|
|
{ |
|
314
|
|
|
if($published) |
|
315
|
|
|
{ |
|
316
|
|
|
$args->status = 1; |
|
317
|
|
|
} |
|
318
|
|
|
else |
|
319
|
|
|
{ |
|
320
|
|
|
$args->status = 0; |
|
321
|
|
|
} |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
$output = executeQuery('comment.getCommentCount', $args); |
|
325
|
|
|
$total_count = $output->data->count; |
|
326
|
|
|
|
|
327
|
|
|
return (int) $total_count; |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* Get the module info without duplication |
|
332
|
|
|
* @return array |
|
333
|
|
|
*/ |
|
334
|
|
|
function getDistinctModules() |
|
335
|
|
|
{ |
|
336
|
|
|
return array(); |
|
337
|
|
|
|
|
338
|
|
|
/* |
|
339
|
|
|
$output = executeQueryArray('comment.getDistinctModules'); |
|
340
|
|
|
$module_srls = $output->data; |
|
341
|
|
|
$oModuleModel = getModel('module'); |
|
342
|
|
|
$result = array(); |
|
343
|
|
|
if($module_srls) |
|
344
|
|
|
{ |
|
345
|
|
|
foreach($module_srls as $module) |
|
346
|
|
|
{ |
|
347
|
|
|
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module->module_srl); |
|
348
|
|
|
$result[$module->module_srl] = $module_info->mid; |
|
349
|
|
|
} |
|
350
|
|
|
} |
|
351
|
|
|
return $result; |
|
352
|
|
|
*/ |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* Get the comment in corresponding with mid. |
|
357
|
|
|
* @todo add commentItems to cache too |
|
358
|
|
|
* @param object $obj |
|
359
|
|
|
* @param array $columnList |
|
360
|
|
|
* @return array |
|
361
|
|
|
*/ |
|
362
|
|
|
function getNewestCommentList($obj, $columnList = array()) |
|
363
|
|
|
{ |
|
364
|
|
|
$args = new stdClass(); |
|
365
|
|
|
|
|
366
|
|
|
if(!is_object($obj)) |
|
367
|
|
|
{ |
|
368
|
|
|
$obj = new stdClass(); |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
if($obj->mid) |
|
372
|
|
|
{ |
|
373
|
|
|
$oModuleModel = getModel('module'); |
|
374
|
|
|
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
|
375
|
|
|
unset($obj->mid); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
// check if module_srl is an arrary. |
|
379
|
|
|
if(is_array($obj->module_srl)) |
|
380
|
|
|
{ |
|
381
|
|
|
$args->module_srl = implode(',', $obj->module_srl); |
|
382
|
|
|
} |
|
383
|
|
|
else |
|
384
|
|
|
{ |
|
385
|
|
|
$args->module_srl = $obj->module_srl; |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
$args->document_srl = $obj->document_srl; |
|
389
|
|
|
$args->list_count = $obj->list_count; |
|
390
|
|
|
|
|
391
|
|
|
if(strpos($args->module_srl, ",") === false) |
|
392
|
|
|
{ |
|
393
|
|
|
if($args->module_srl) |
|
394
|
|
|
{ |
|
395
|
|
|
// check if module is using comment validation system |
|
396
|
|
|
$oCommentController = getController("comment"); |
|
397
|
|
|
$is_using_validation = $oCommentController->isModuleUsingPublishValidation($obj->module_srl); |
|
398
|
|
|
if($is_using_validation) |
|
399
|
|
|
{ |
|
400
|
|
|
$args->status = 1; |
|
401
|
|
|
} |
|
402
|
|
|
} |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
$output = executeQuery('comment.getNewestCommentList', $args, $columnList); |
|
406
|
|
|
|
|
407
|
|
|
if(!$output->toBool()) |
|
408
|
|
|
{ |
|
409
|
|
|
return $output; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
$comment_list = $output->data; |
|
413
|
|
|
if($comment_list) |
|
414
|
|
|
{ |
|
415
|
|
|
if(!is_array($comment_list)) |
|
416
|
|
|
{ |
|
417
|
|
|
$comment_list = array($comment_list); |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
$comment_count = count($comment_list); |
|
|
|
|
|
|
421
|
|
|
|
|
422
|
|
View Code Duplication |
foreach($comment_list as $key => $attribute) |
|
423
|
|
|
{ |
|
424
|
|
|
if(!$attribute->comment_srl) |
|
425
|
|
|
{ |
|
426
|
|
|
continue; |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
$oComment = NULL; |
|
|
|
|
|
|
430
|
|
|
$oComment = new commentItem(); |
|
431
|
|
|
$oComment->setAttribute($attribute); |
|
432
|
|
|
|
|
433
|
|
|
$result[$key] = $oComment; |
|
|
|
|
|
|
434
|
|
|
} |
|
435
|
|
|
$output->data = $result; |
|
|
|
|
|
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
return $result; |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
/** |
|
442
|
|
|
* Get a comment list of the doc in corresponding woth document_srl. |
|
443
|
|
|
* @param int $document_srl |
|
444
|
|
|
* @param int $page |
|
445
|
|
|
* @param bool $is_admin |
|
446
|
|
|
* @param int $count |
|
447
|
|
|
* @return object |
|
448
|
|
|
*/ |
|
449
|
|
|
function getCommentList($document_srl, $page = 0, $is_admin = FALSE, $count = 0) |
|
|
|
|
|
|
450
|
|
|
{ |
|
451
|
|
|
if(!isset($document_srl)) |
|
452
|
|
|
{ |
|
453
|
|
|
return; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
// get the number of comments on the document module |
|
457
|
|
|
$oDocumentModel = getModel('document'); |
|
458
|
|
|
$columnList = array('document_srl', 'module_srl', 'comment_count'); |
|
459
|
|
|
$oDocument = $oDocumentModel->getDocument($document_srl, FALSE, TRUE, $columnList); |
|
460
|
|
|
|
|
461
|
|
|
// return if no doc exists. |
|
462
|
|
|
if(!$oDocument->isExists()) |
|
463
|
|
|
{ |
|
464
|
|
|
return; |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
// return if no comment exists |
|
468
|
|
|
if($oDocument->getCommentCount() < 1) |
|
469
|
|
|
{ |
|
470
|
|
|
return; |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
// get a list of comments |
|
474
|
|
|
$module_srl = $oDocument->get('module_srl'); |
|
475
|
|
|
|
|
476
|
|
|
if(!$count) |
|
477
|
|
|
{ |
|
478
|
|
|
$comment_config = $this->getCommentConfig($module_srl); |
|
479
|
|
|
$comment_count = $comment_config->comment_count; |
|
480
|
|
|
if(!$comment_count) |
|
481
|
|
|
{ |
|
482
|
|
|
$comment_count = 50; |
|
483
|
|
|
} |
|
484
|
|
|
} |
|
485
|
|
|
else |
|
486
|
|
|
{ |
|
487
|
|
|
$comment_count = $count; |
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
// get a very last page if no page exists |
|
491
|
|
|
if(!$page) |
|
492
|
|
|
{ |
|
493
|
|
|
$page = (int) ( ($oDocument->getCommentCount() - 1) / $comment_count) + 1; |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
// get a list of comments |
|
497
|
|
|
$args = new stdClass(); |
|
498
|
|
|
$args->document_srl = $document_srl; |
|
499
|
|
|
$args->list_count = $comment_count; |
|
500
|
|
|
$args->page = $page; |
|
501
|
|
|
$args->page_count = 10; |
|
502
|
|
|
|
|
503
|
|
|
//check if module is using validation system |
|
504
|
|
|
$oCommentController = getController('comment'); |
|
505
|
|
|
$using_validation = $oCommentController->isModuleUsingPublishValidation($module_srl); |
|
506
|
|
|
if($using_validation) |
|
507
|
|
|
{ |
|
508
|
|
|
$args->status = 1; |
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
// call trigger (before) |
|
512
|
|
|
$trigger_output = ModuleHandler::triggerCall('comment.getCommentList', 'before', $args); |
|
513
|
|
|
if($trigger_output instanceof BaseObject && !$trigger_output->toBool()) |
|
514
|
|
|
{ |
|
515
|
|
|
return $output; |
|
|
|
|
|
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
$output = executeQueryArray('comment.getCommentPageList', $args); |
|
519
|
|
|
|
|
520
|
|
|
// return if an error occurs in the query results |
|
521
|
|
|
if(!$output->toBool()) |
|
522
|
|
|
{ |
|
523
|
|
|
return; |
|
524
|
|
|
} |
|
525
|
|
|
|
|
526
|
|
|
// insert data into CommentPageList table if the number of results is different from stored comments |
|
527
|
|
|
if(!$output->data) |
|
528
|
|
|
{ |
|
529
|
|
|
$this->fixCommentList($oDocument->get('module_srl'), $document_srl); |
|
530
|
|
|
$output = executeQueryArray('comment.getCommentPageList', $args); |
|
531
|
|
|
if(!$output->toBool()) |
|
532
|
|
|
{ |
|
533
|
|
|
return; |
|
534
|
|
|
} |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
// call trigger (after) |
|
538
|
|
|
$trigger_output = ModuleHandler::triggerCall('comment.getCommentList', 'after', $output); |
|
539
|
|
|
if($trigger_output instanceof BaseObject && !$trigger_output->toBool()) |
|
540
|
|
|
{ |
|
541
|
|
|
return $trigger_output; |
|
542
|
|
|
} |
|
543
|
|
|
|
|
544
|
|
|
return $output; |
|
545
|
|
|
} |
|
546
|
|
|
|
|
547
|
|
|
/** |
|
548
|
|
|
* Update a list of comments in corresponding with document_srl |
|
549
|
|
|
* Take care of previously used data than GA version |
|
550
|
|
|
* @param int $module_srl |
|
551
|
|
|
* @param int $document_srl |
|
552
|
|
|
* @return void |
|
553
|
|
|
*/ |
|
554
|
|
|
function fixCommentList($module_srl, $document_srl) |
|
555
|
|
|
{ |
|
556
|
|
|
// create a lock file to prevent repeated work when performing a batch job |
|
557
|
|
|
$lock_file = "./files/cache/tmp/lock." . $document_srl; |
|
558
|
|
|
|
|
559
|
|
|
if(file_exists($lock_file) && filemtime($lock_file) + 60 * 60 * 10 < $_SERVER['REQUEST_TIME']) |
|
560
|
|
|
{ |
|
561
|
|
|
return; |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
|
|
FileHandler::writeFile($lock_file, ''); |
|
565
|
|
|
|
|
566
|
|
|
// get a list |
|
567
|
|
|
$args = new stdClass(); |
|
568
|
|
|
$args->document_srl = $document_srl; |
|
569
|
|
|
$args->list_order = 'list_order'; |
|
570
|
|
|
$output = executeQuery('comment.getCommentList', $args); |
|
571
|
|
|
if(!$output->toBool()) |
|
572
|
|
|
{ |
|
573
|
|
|
return $output; |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
$source_list = $output->data; |
|
577
|
|
|
if(!is_array($source_list)) |
|
578
|
|
|
{ |
|
579
|
|
|
$source_list = array($source_list); |
|
580
|
|
|
} |
|
581
|
|
|
|
|
582
|
|
|
// Sort comments by the hierarchical structure |
|
583
|
|
|
$comment_count = count($source_list); |
|
584
|
|
|
|
|
585
|
|
|
$root = new stdClass; |
|
586
|
|
|
$list = array(); |
|
587
|
|
|
$comment_list = array(); |
|
588
|
|
|
|
|
589
|
|
|
// get the log-in information for logged-in users |
|
590
|
|
|
$logged_info = Context::get('logged_info'); |
|
|
|
|
|
|
591
|
|
|
|
|
592
|
|
|
// generate a hierarchical structure of comments for loop |
|
593
|
|
|
for($i = $comment_count - 1; $i >= 0; $i--) |
|
594
|
|
|
{ |
|
595
|
|
|
$comment_srl = $source_list[$i]->comment_srl; |
|
596
|
|
|
$parent_srl = $source_list[$i]->parent_srl; |
|
597
|
|
|
if(!$comment_srl) |
|
598
|
|
|
{ |
|
599
|
|
|
continue; |
|
600
|
|
|
} |
|
601
|
|
|
|
|
602
|
|
|
// generate a list |
|
603
|
|
|
$list[$comment_srl] = $source_list[$i]; |
|
604
|
|
|
|
|
605
|
|
|
if($parent_srl) |
|
606
|
|
|
{ |
|
607
|
|
|
$list[$parent_srl]->child[] = &$list[$comment_srl]; |
|
608
|
|
|
} |
|
609
|
|
|
else |
|
610
|
|
|
{ |
|
611
|
|
|
$root->child[] = &$list[$comment_srl]; |
|
612
|
|
|
} |
|
613
|
|
|
} |
|
614
|
|
|
$this->_arrangeComment($comment_list, $root->child, 0, NULL); |
|
615
|
|
|
|
|
616
|
|
|
// insert values to the database |
|
617
|
|
|
if(count($comment_list)) |
|
618
|
|
|
{ |
|
619
|
|
|
foreach($comment_list as $comment_srl => $item) |
|
620
|
|
|
{ |
|
621
|
|
|
$comment_args = new stdClass(); |
|
622
|
|
|
$comment_args->comment_srl = $comment_srl; |
|
623
|
|
|
$comment_args->document_srl = $document_srl; |
|
624
|
|
|
$comment_args->head = $item->head; |
|
625
|
|
|
$comment_args->arrange = $item->arrange; |
|
626
|
|
|
$comment_args->module_srl = $module_srl; |
|
627
|
|
|
$comment_args->regdate = $item->regdate; |
|
628
|
|
|
$comment_args->depth = $item->depth; |
|
629
|
|
|
|
|
630
|
|
|
executeQuery('comment.insertCommentList', $comment_args); |
|
631
|
|
|
} |
|
632
|
|
|
} |
|
633
|
|
|
|
|
634
|
|
|
// remove the lock file if successful. |
|
635
|
|
|
FileHandler::removeFile($lock_file); |
|
636
|
|
|
} |
|
637
|
|
|
|
|
638
|
|
|
/** |
|
639
|
|
|
* Relocate comments in the hierarchical structure |
|
640
|
|
|
* @param array $comment_list |
|
641
|
|
|
* @param array $list |
|
642
|
|
|
* @param int $depth |
|
643
|
|
|
* @param object $parent |
|
644
|
|
|
* @return void |
|
645
|
|
|
*/ |
|
646
|
|
|
function _arrangeComment(&$comment_list, $list, $depth, $parent = NULL) |
|
647
|
|
|
{ |
|
648
|
|
|
if(!count($list)) |
|
649
|
|
|
{ |
|
650
|
|
|
return; |
|
651
|
|
|
} |
|
652
|
|
|
|
|
653
|
|
|
foreach($list as $key => $val) |
|
654
|
|
|
{ |
|
655
|
|
|
if($parent) |
|
656
|
|
|
{ |
|
657
|
|
|
$val->head = $parent->head; |
|
658
|
|
|
} |
|
659
|
|
|
else |
|
660
|
|
|
{ |
|
661
|
|
|
$val->head = $val->comment_srl; |
|
662
|
|
|
} |
|
663
|
|
|
|
|
664
|
|
|
$val->arrange = count($comment_list) + 1; |
|
665
|
|
|
|
|
666
|
|
|
if($val->child) |
|
667
|
|
|
{ |
|
668
|
|
|
$val->depth = $depth; |
|
669
|
|
|
$comment_list[$val->comment_srl] = $val; |
|
670
|
|
|
$this->_arrangeComment($comment_list, $val->child, $depth + 1, $val); |
|
671
|
|
|
unset($val->child); |
|
672
|
|
|
} |
|
673
|
|
|
else |
|
674
|
|
|
{ |
|
675
|
|
|
$val->depth = $depth; |
|
676
|
|
|
$comment_list[$val->comment_srl] = $val; |
|
677
|
|
|
} |
|
678
|
|
|
} |
|
679
|
|
|
} |
|
680
|
|
|
|
|
681
|
|
|
/** |
|
682
|
|
|
* Get all the comments in time decending order(for administrators) |
|
683
|
|
|
* @param object $obj |
|
684
|
|
|
* @param array $columnList |
|
685
|
|
|
* @return object |
|
686
|
|
|
*/ |
|
687
|
|
|
function getTotalCommentList($obj, $columnList = array()) |
|
688
|
|
|
{ |
|
689
|
|
|
$query_id = 'comment.getTotalCommentList'; |
|
690
|
|
|
|
|
691
|
|
|
// Variables |
|
692
|
|
|
$args = new stdClass(); |
|
693
|
|
|
$args->sort_index = 'list_order'; |
|
694
|
|
|
$args->page = $obj->page ? $obj->page : 1; |
|
695
|
|
|
$args->list_count = $obj->list_count ? $obj->list_count : 20; |
|
696
|
|
|
$args->page_count = $obj->page_count ? $obj->page_count : 10; |
|
697
|
|
|
$args->s_module_srl = $obj->module_srl; |
|
698
|
|
|
$args->exclude_module_srl = $obj->exclude_module_srl; |
|
699
|
|
|
|
|
700
|
|
|
// check if module is using comment validation system |
|
701
|
|
|
$oCommentController = getController("comment"); |
|
702
|
|
|
$is_using_validation = $oCommentController->isModuleUsingPublishValidation($obj->module_srl); |
|
703
|
|
|
if($is_using_validation) |
|
704
|
|
|
{ |
|
705
|
|
|
$args->s_is_published = 1; |
|
706
|
|
|
} |
|
707
|
|
|
|
|
708
|
|
|
// Search options |
|
709
|
|
|
$search_target = $obj->search_target ? $obj->search_target : trim(Context::get('search_target')); |
|
710
|
|
|
$search_keyword = $obj->search_keyword ? $obj->search_keyword : trim(Context::get('search_keyword')); |
|
711
|
|
|
if($search_target && $search_keyword) |
|
712
|
|
|
{ |
|
713
|
|
|
switch($search_target) |
|
714
|
|
|
{ |
|
715
|
|
View Code Duplication |
case 'content' : |
|
716
|
|
|
if($search_keyword) |
|
717
|
|
|
{ |
|
718
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
719
|
|
|
} |
|
720
|
|
|
|
|
721
|
|
|
$args->s_content = $search_keyword; |
|
722
|
|
|
break; |
|
723
|
|
|
|
|
724
|
|
View Code Duplication |
case 'user_id' : |
|
725
|
|
|
if($search_keyword) |
|
726
|
|
|
{ |
|
727
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
728
|
|
|
} |
|
729
|
|
|
|
|
730
|
|
|
$args->s_user_id = $search_keyword; |
|
731
|
|
|
$query_id = 'comment.getTotalCommentListWithinMember'; |
|
732
|
|
|
$args->sort_index = 'comments.list_order'; |
|
733
|
|
|
break; |
|
734
|
|
|
|
|
735
|
|
View Code Duplication |
case 'user_name' : |
|
736
|
|
|
if($search_keyword) |
|
737
|
|
|
{ |
|
738
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
739
|
|
|
} |
|
740
|
|
|
|
|
741
|
|
|
$args->s_user_name = $search_keyword; |
|
742
|
|
|
break; |
|
743
|
|
|
|
|
744
|
|
View Code Duplication |
case 'nick_name' : |
|
745
|
|
|
if($search_keyword) |
|
746
|
|
|
{ |
|
747
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
748
|
|
|
} |
|
749
|
|
|
|
|
750
|
|
|
$args->s_nick_name = $search_keyword; |
|
751
|
|
|
break; |
|
752
|
|
|
|
|
753
|
|
View Code Duplication |
case 'email_address' : |
|
754
|
|
|
if($search_keyword) |
|
755
|
|
|
{ |
|
756
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
757
|
|
|
} |
|
758
|
|
|
|
|
759
|
|
|
$args->s_email_address = $search_keyword; |
|
760
|
|
|
break; |
|
761
|
|
|
|
|
762
|
|
View Code Duplication |
case 'homepage' : |
|
763
|
|
|
if($search_keyword) |
|
764
|
|
|
{ |
|
765
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
766
|
|
|
} |
|
767
|
|
|
|
|
768
|
|
|
$args->s_homepage = $search_keyword; |
|
769
|
|
|
break; |
|
770
|
|
|
|
|
771
|
|
|
case 'regdate' : |
|
772
|
|
|
$args->s_regdate = $search_keyword; |
|
773
|
|
|
break; |
|
774
|
|
|
|
|
775
|
|
|
case 'last_update' : |
|
776
|
|
|
$args->s_last_upate = $search_keyword; |
|
777
|
|
|
break; |
|
778
|
|
|
|
|
779
|
|
|
case 'ipaddress' : |
|
780
|
|
|
$args->s_ipaddress = $search_keyword; |
|
781
|
|
|
break; |
|
782
|
|
|
|
|
783
|
|
|
case 'is_secret' : |
|
784
|
|
|
$args->s_is_secret = $search_keyword; |
|
785
|
|
|
break; |
|
786
|
|
|
|
|
787
|
|
|
case 'is_published' : |
|
788
|
|
|
if($search_keyword == 'Y') |
|
789
|
|
|
{ |
|
790
|
|
|
$args->s_is_published = 1; |
|
791
|
|
|
} |
|
792
|
|
|
|
|
793
|
|
|
if($search_keyword == 'N') |
|
794
|
|
|
{ |
|
795
|
|
|
$args->s_is_published = 0; |
|
796
|
|
|
} |
|
797
|
|
|
|
|
798
|
|
|
break; |
|
799
|
|
|
|
|
800
|
|
|
case 'module': |
|
801
|
|
|
$args->s_module_srl = (int) $search_keyword; |
|
802
|
|
|
break; |
|
803
|
|
|
|
|
804
|
|
|
case 'member_srl' : |
|
805
|
|
|
$args->{"s_" . $search_target} = (int) $search_keyword; |
|
806
|
|
|
break; |
|
807
|
|
|
} |
|
808
|
|
|
} |
|
809
|
|
|
|
|
810
|
|
|
// comment.getTotalCommentList query execution |
|
811
|
|
|
$output = executeQueryArray($query_id, $args, $columnList); |
|
812
|
|
|
|
|
813
|
|
|
// return when no result or error occurance |
|
814
|
|
|
if(!$output->toBool() || !count($output->data)) |
|
815
|
|
|
{ |
|
816
|
|
|
return $output; |
|
817
|
|
|
} |
|
818
|
|
|
|
|
819
|
|
|
foreach($output->data as $key => $val) |
|
820
|
|
|
{ |
|
821
|
|
|
unset($_oComment); |
|
822
|
|
|
$_oComment = new CommentItem(0); |
|
823
|
|
|
$_oComment->setAttribute($val); |
|
824
|
|
|
$output->data[$key] = $_oComment; |
|
825
|
|
|
} |
|
826
|
|
|
|
|
827
|
|
|
return $output; |
|
828
|
|
|
} |
|
829
|
|
|
|
|
830
|
|
|
/** |
|
831
|
|
|
* Get all the comment count in time decending order(for administrators) |
|
832
|
|
|
* @param object $obj |
|
833
|
|
|
* @return int |
|
834
|
|
|
*/ |
|
835
|
|
|
function getTotalCommentCount($obj) |
|
836
|
|
|
{ |
|
837
|
|
|
$query_id = 'comment.getTotalCommentCountByGroupStatus'; |
|
838
|
|
|
|
|
839
|
|
|
// Variables |
|
840
|
|
|
$args = new stdClass(); |
|
841
|
|
|
$args->s_module_srl = $obj->module_srl; |
|
842
|
|
|
$args->exclude_module_srl = $obj->exclude_module_srl; |
|
843
|
|
|
|
|
844
|
|
|
// Search options |
|
845
|
|
|
$search_target = $obj->search_target ? $obj->search_target : trim(Context::get('search_target')); |
|
846
|
|
|
$search_keyword = $obj->search_keyword ? $obj->search_keyword : trim(Context::get('search_keyword')); |
|
847
|
|
|
|
|
848
|
|
|
if($search_target && $search_keyword) |
|
849
|
|
|
{ |
|
850
|
|
|
switch($search_target) |
|
851
|
|
|
{ |
|
852
|
|
View Code Duplication |
case 'content' : |
|
853
|
|
|
if($search_keyword) |
|
854
|
|
|
{ |
|
855
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
856
|
|
|
} |
|
857
|
|
|
|
|
858
|
|
|
$args->s_content = $search_keyword; |
|
859
|
|
|
break; |
|
860
|
|
|
|
|
861
|
|
View Code Duplication |
case 'user_id' : |
|
862
|
|
|
if($search_keyword) |
|
863
|
|
|
{ |
|
864
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
865
|
|
|
} |
|
866
|
|
|
|
|
867
|
|
|
$args->s_user_id = $search_keyword; |
|
868
|
|
|
$query_id = 'comment.getTotalCommentCountWithinMemberByGroupStatus'; |
|
869
|
|
|
break; |
|
870
|
|
|
|
|
871
|
|
View Code Duplication |
case 'user_name' : |
|
872
|
|
|
if($search_keyword) |
|
873
|
|
|
{ |
|
874
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
875
|
|
|
} |
|
876
|
|
|
$args->s_user_name = $search_keyword; |
|
877
|
|
|
|
|
878
|
|
|
break; |
|
879
|
|
|
|
|
880
|
|
View Code Duplication |
case 'nick_name' : |
|
881
|
|
|
if($search_keyword) |
|
882
|
|
|
{ |
|
883
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
884
|
|
|
} |
|
885
|
|
|
|
|
886
|
|
|
$args->s_nick_name = $search_keyword; |
|
887
|
|
|
break; |
|
888
|
|
|
|
|
889
|
|
View Code Duplication |
case 'email_address' : |
|
890
|
|
|
if($search_keyword) |
|
891
|
|
|
{ |
|
892
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
893
|
|
|
} |
|
894
|
|
|
|
|
895
|
|
|
$args->s_email_address = $search_keyword; |
|
896
|
|
|
break; |
|
897
|
|
|
|
|
898
|
|
View Code Duplication |
case 'homepage' : |
|
899
|
|
|
if($search_keyword) |
|
900
|
|
|
{ |
|
901
|
|
|
$search_keyword = str_replace(' ', '%', $search_keyword); |
|
902
|
|
|
} |
|
903
|
|
|
|
|
904
|
|
|
$args->s_homepage = $search_keyword; |
|
905
|
|
|
break; |
|
906
|
|
|
|
|
907
|
|
|
case 'regdate' : |
|
908
|
|
|
$args->s_regdate = $search_keyword; |
|
909
|
|
|
break; |
|
910
|
|
|
|
|
911
|
|
|
case 'last_update' : |
|
912
|
|
|
$args->s_last_upate = $search_keyword; |
|
913
|
|
|
break; |
|
914
|
|
|
|
|
915
|
|
|
case 'ipaddress' : |
|
916
|
|
|
$args->s_ipaddress = $search_keyword; |
|
917
|
|
|
break; |
|
918
|
|
|
|
|
919
|
|
|
case 'is_secret' : |
|
920
|
|
|
$args->s_is_secret = $search_keyword; |
|
921
|
|
|
break; |
|
922
|
|
|
|
|
923
|
|
|
case 'member_srl' : |
|
924
|
|
|
$args->{"s_" . $search_target} = (int) $search_keyword; |
|
925
|
|
|
break; |
|
926
|
|
|
} |
|
927
|
|
|
} |
|
928
|
|
|
|
|
929
|
|
|
$output = executeQueryArray($query_id, $args); |
|
930
|
|
|
|
|
931
|
|
|
// return when no result or error occurance |
|
932
|
|
|
if(!$output->toBool() || !count($output->data)) |
|
933
|
|
|
{ |
|
934
|
|
|
return $output; |
|
935
|
|
|
} |
|
936
|
|
|
|
|
937
|
|
|
return $output->data; |
|
938
|
|
|
} |
|
939
|
|
|
|
|
940
|
|
|
/** |
|
941
|
|
|
* Return a configuration of comments for each module |
|
942
|
|
|
* @param int $module_srl |
|
943
|
|
|
* @return object |
|
944
|
|
|
*/ |
|
945
|
|
|
function getCommentConfig($module_srl) |
|
946
|
|
|
{ |
|
947
|
|
|
$oModuleModel = getModel('module'); |
|
948
|
|
|
$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl); |
|
949
|
|
|
if(!is_object($comment_config)) |
|
950
|
|
|
{ |
|
951
|
|
|
$comment_config = new stdClass(); |
|
952
|
|
|
} |
|
953
|
|
|
|
|
954
|
|
|
if(!isset($comment_config->comment_count)) |
|
955
|
|
|
{ |
|
956
|
|
|
$comment_config->comment_count = 50; |
|
957
|
|
|
} |
|
958
|
|
|
|
|
959
|
|
|
return $comment_config; |
|
960
|
|
|
} |
|
961
|
|
|
|
|
962
|
|
|
/** |
|
963
|
|
|
* Return a list of voting member |
|
964
|
|
|
* @return void |
|
965
|
|
|
*/ |
|
966
|
|
|
function getCommentVotedMemberList() |
|
967
|
|
|
{ |
|
968
|
|
|
$comment_srl = Context::get('comment_srl'); |
|
969
|
|
|
if(!$comment_srl) |
|
970
|
|
|
{ |
|
971
|
|
|
return new BaseObject(-1, 'msg_invalid_request'); |
|
972
|
|
|
} |
|
973
|
|
|
|
|
974
|
|
|
$point = Context::get('point'); |
|
975
|
|
|
if($point != -1) |
|
976
|
|
|
{ |
|
977
|
|
|
$point = 1; |
|
978
|
|
|
} |
|
979
|
|
|
|
|
980
|
|
|
$oCommentModel = getModel('comment'); |
|
981
|
|
|
$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE); |
|
982
|
|
|
$module_srl = $oComment->get('module_srl'); |
|
983
|
|
|
if(!$module_srl) |
|
984
|
|
|
{ |
|
985
|
|
|
return new BaseObject(-1, 'msg_invalid_request'); |
|
986
|
|
|
} |
|
987
|
|
|
|
|
988
|
|
|
$oModuleModel = getModel('module'); |
|
989
|
|
|
$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl); |
|
990
|
|
|
|
|
991
|
|
|
$args = new stdClass(); |
|
992
|
|
|
|
|
993
|
|
View Code Duplication |
if($point == -1) |
|
994
|
|
|
{ |
|
995
|
|
|
if($comment_config->use_vote_down != 'S') |
|
996
|
|
|
{ |
|
997
|
|
|
return new BaseObject(-1, 'msg_invalid_request'); |
|
998
|
|
|
} |
|
999
|
|
|
|
|
1000
|
|
|
$args->below_point = 0; |
|
1001
|
|
|
} |
|
1002
|
|
|
else |
|
1003
|
|
|
{ |
|
1004
|
|
|
if($comment_config->use_vote_up != 'S') |
|
1005
|
|
|
{ |
|
1006
|
|
|
return new BaseObject(-1, 'msg_invalid_request'); |
|
1007
|
|
|
} |
|
1008
|
|
|
|
|
1009
|
|
|
$args->more_point = 0; |
|
1010
|
|
|
} |
|
1011
|
|
|
|
|
1012
|
|
|
$args->comment_srl = $comment_srl; |
|
1013
|
|
|
$output = executeQueryArray('comment.getVotedMemberList', $args); |
|
1014
|
|
|
if(!$output->toBool()) |
|
1015
|
|
|
{ |
|
1016
|
|
|
return $output; |
|
1017
|
|
|
} |
|
1018
|
|
|
|
|
1019
|
|
|
$oMemberModel = getModel('member'); |
|
1020
|
|
View Code Duplication |
if($output->data) |
|
1021
|
|
|
{ |
|
1022
|
|
|
foreach($output->data as $k => $d) |
|
1023
|
|
|
{ |
|
1024
|
|
|
$profile_image = $oMemberModel->getProfileImage($d->member_srl); |
|
1025
|
|
|
$output->data[$k]->src = $profile_image->src; |
|
1026
|
|
|
} |
|
1027
|
|
|
} |
|
1028
|
|
|
|
|
1029
|
|
|
$this->add('voted_member_list', $output->data); |
|
1030
|
|
|
} |
|
1031
|
|
|
|
|
1032
|
|
|
/** |
|
1033
|
|
|
* Return a secret status by secret field |
|
1034
|
|
|
* @return array |
|
1035
|
|
|
*/ |
|
1036
|
|
|
function getSecretNameList() |
|
1037
|
|
|
{ |
|
1038
|
|
|
global $lang; |
|
1039
|
|
|
|
|
1040
|
|
|
if(!isset($lang->secret_name_list)) |
|
1041
|
|
|
{ |
|
1042
|
|
|
return array('Y' => 'Secret', 'N' => 'Public'); |
|
1043
|
|
|
} |
|
1044
|
|
|
else |
|
1045
|
|
|
{ |
|
1046
|
|
|
return $lang->secret_name_list; |
|
1047
|
|
|
} |
|
1048
|
|
|
} |
|
1049
|
|
|
|
|
1050
|
|
|
/** |
|
1051
|
|
|
* Get the total number of comments in corresponding with member_srl. |
|
1052
|
|
|
* @param int $member_srl |
|
1053
|
|
|
* @return int |
|
1054
|
|
|
*/ |
|
1055
|
|
|
function getCommentCountByMemberSrl($member_srl) |
|
1056
|
|
|
{ |
|
1057
|
|
|
$args = new stdClass(); |
|
1058
|
|
|
$args->member_srl = $member_srl; |
|
1059
|
|
|
$output = executeQuery('comment.getCommentCountByMemberSrl', $args); |
|
1060
|
|
|
return (int) $output->data->count; |
|
1061
|
|
|
} |
|
1062
|
|
|
|
|
1063
|
|
|
|
|
1064
|
|
|
/** |
|
1065
|
|
|
* Get comment list of the doc in corresponding woth member_srl. |
|
1066
|
|
|
* @param int $member_srl |
|
1067
|
|
|
* @param array $columnList |
|
1068
|
|
|
* @param int $page |
|
1069
|
|
|
* @param bool $is_admin |
|
1070
|
|
|
* @param int $count |
|
1071
|
|
|
* @return object |
|
1072
|
|
|
*/ |
|
1073
|
|
View Code Duplication |
function getCommentListByMemberSrl($member_srl, $columnList = array(), $page = 0, $is_admin = FALSE, $count = 0) |
|
|
|
|
|
|
1074
|
|
|
{ |
|
1075
|
|
|
$args = new stdClass(); |
|
1076
|
|
|
$args->member_srl = $member_srl; |
|
1077
|
|
|
$args->list_count = $count; |
|
1078
|
|
|
$output = executeQuery('comment.getCommentListByMemberSrl', $args, $columnList); |
|
1079
|
|
|
$comment_list = $output->data; |
|
1080
|
|
|
|
|
1081
|
|
|
if(!$comment_list) return array(); |
|
1082
|
|
|
if(!is_array($comment_list)) $comment_list = array($comment_list); |
|
1083
|
|
|
|
|
1084
|
|
|
return $comment_list; |
|
1085
|
|
|
|
|
1086
|
|
|
} |
|
1087
|
|
|
|
|
1088
|
|
|
} |
|
1089
|
|
|
/* End of file comment.model.php */ |
|
1090
|
|
|
/* Location: ./modules/comment/comment.model.php */ |
|
1091
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.