@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function procDocumentVoteUp() |
26 | 26 | { |
27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
27 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
28 | 28 | |
29 | 29 | $document_srl = Context::get('target_srl'); |
30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
30 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
31 | 31 | |
32 | 32 | $oDocumentModel = getModel('document'); |
33 | 33 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
34 | 34 | $module_srl = $oDocument->get('module_srl'); |
35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
35 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
36 | 36 | |
37 | 37 | $oModuleModel = getModel('module'); |
38 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
38 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
39 | + if ($document_config->use_vote_up == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
40 | 40 | |
41 | 41 | $point = 1; |
42 | 42 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function procDocumentVoteDown() |
71 | 71 | { |
72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
72 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
73 | 73 | |
74 | 74 | $document_srl = Context::get('target_srl'); |
75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
75 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
76 | 76 | |
77 | 77 | $oDocumentModel = getModel('document'); |
78 | 78 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
79 | 79 | $module_srl = $oDocument->get('module_srl'); |
80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
80 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
81 | 81 | |
82 | 82 | $oModuleModel = getModel('module'); |
83 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
83 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
84 | + if ($document_config->use_vote_down == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
85 | 85 | |
86 | 86 | $point = -1; |
87 | 87 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function procDocumentDeclare() |
97 | 97 | { |
98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
98 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
99 | 99 | |
100 | 100 | $document_srl = Context::get('target_srl'); |
101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
101 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
102 | 102 | |
103 | 103 | return $this->declaredDocument($document_srl); |
104 | 104 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $args->history_srl = $history_srl; |
141 | 141 | $args->module_srl = $module_srl; |
142 | 142 | $args->document_srl = $document_srl; |
143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
143 | + if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
144 | 144 | executeQuery("document.deleteHistory", $args); |
145 | 145 | } |
146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | function triggerDeleteModuleDocuments(&$obj) |
153 | 153 | { |
154 | 154 | $module_srl = $obj->module_srl; |
155 | - if(!$module_srl) return new BaseObject(); |
|
155 | + if (!$module_srl) return new BaseObject(); |
|
156 | 156 | // Delete the document |
157 | 157 | $oDocumentAdminController = getAdminController('document'); |
158 | 158 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
159 | - if(!$output->toBool()) return $output; |
|
159 | + if (!$output->toBool()) return $output; |
|
160 | 160 | // Delete the category |
161 | 161 | $oDocumentController = getController('document'); |
162 | 162 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
163 | - if(!$output->toBool()) return $output; |
|
163 | + if (!$output->toBool()) return $output; |
|
164 | 164 | // Delete extra key and variable, because module deleted |
165 | 165 | $this->deleteDocumentExtraKeys($module_srl); |
166 | 166 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true) |
195 | 195 | { |
196 | - if(!$manual_inserted && !checkCSRF()) |
|
196 | + if (!$manual_inserted && !checkCSRF()) |
|
197 | 197 | { |
198 | 198 | return new BaseObject(-1, 'msg_invalid_request'); |
199 | 199 | } |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | $oDB = &DB::getInstance(); |
203 | 203 | $oDB->begin(); |
204 | 204 | // List variables |
205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
209 | - if($obj->homepage) |
|
205 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
209 | + if ($obj->homepage) |
|
210 | 210 | { |
211 | 211 | $obj->homepage = removeHackTag($obj->homepage); |
212 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
212 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
213 | 213 | { |
214 | 214 | $obj->homepage = 'http://'.$obj->homepage; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
218 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | + if (!$obj->email_address) $obj->email_address = ''; |
|
220 | + if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
221 | 221 | |
222 | 222 | // can modify regdate only manager |
223 | 223 | $grant = Context::get('grant'); |
224 | - if(!$grant->manager) |
|
224 | + if (!$grant->manager) |
|
225 | 225 | { |
226 | 226 | unset($obj->regdate); |
227 | 227 | } |
228 | 228 | |
229 | 229 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
230 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
231 | 231 | // Remove the columns for automatic saving |
232 | 232 | unset($obj->_saved_doc_srl); |
233 | 233 | unset($obj->_saved_doc_title); |
@@ -235,34 +235,34 @@ discard block |
||
235 | 235 | unset($obj->_saved_doc_message); |
236 | 236 | // Call a trigger (before) |
237 | 237 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
238 | - if(!$output->toBool()) return $output; |
|
238 | + if (!$output->toBool()) return $output; |
|
239 | 239 | // Register it if no given document_srl exists |
240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
240 | + if (!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | + elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
242 | 242 | |
243 | 243 | $oDocumentModel = getModel('document'); |
244 | 244 | // Set to 0 if the category_srl doesn't exist |
245 | - if($obj->category_srl) |
|
245 | + if ($obj->category_srl) |
|
246 | 246 | { |
247 | 247 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
248 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
248 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
249 | 249 | { |
250 | 250 | return new BaseObject(-1, 'msg_not_permitted'); |
251 | 251 | } |
252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
252 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
253 | 253 | } |
254 | 254 | // Set the read counts and update order. |
255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
255 | + if (!$obj->readed_count) $obj->readed_count = 0; |
|
256 | + if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
257 | 257 | else $obj->update_order = $obj->list_order; |
258 | 258 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
259 | - if($obj->password && !$obj->password_is_hashed) |
|
259 | + if ($obj->password && !$obj->password_is_hashed) |
|
260 | 260 | { |
261 | 261 | $obj->password = getModel('member')->hashPassword($obj->password); |
262 | 262 | } |
263 | 263 | // Insert member's information only if the member is logged-in and not manually registered. |
264 | 264 | $logged_info = Context::get('logged_info'); |
265 | - if(Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
265 | + if (Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
266 | 266 | { |
267 | 267 | $obj->member_srl = $logged_info->member_srl; |
268 | 268 | |
@@ -276,61 +276,61 @@ discard block |
||
276 | 276 | // If the tile is empty, extract string from the contents. |
277 | 277 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
278 | 278 | settype($obj->title, "string"); |
279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
279 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
280 | 280 | // If no tile extracted from the contents, leave it untitled. |
281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
281 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
282 | 282 | // Remove XE's own tags from the contents. |
283 | 283 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
284 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
284 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
285 | 285 | { |
286 | - if($obj->use_html != 'Y') |
|
286 | + if ($obj->use_html != 'Y') |
|
287 | 287 | { |
288 | 288 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
289 | 289 | } |
290 | 290 | $obj->content = nl2br($obj->content); |
291 | 291 | } |
292 | 292 | // Remove iframe and script if not a top adminisrator in the session. |
293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
293 | + if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
294 | 294 | // An error appears if both log-in info and user name don't exist. |
295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
295 | + if (!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1, 'msg_invalid_request'); |
|
296 | 296 | |
297 | 297 | $obj->lang_code = Context::getLangType(); |
298 | 298 | // Insert data into the DB |
299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
299 | + if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
300 | 300 | $output = executeQuery('document.insertDocument', $obj); |
301 | - if(!$output->toBool()) |
|
301 | + if (!$output->toBool()) |
|
302 | 302 | { |
303 | 303 | $oDB->rollback(); |
304 | 304 | return $output; |
305 | 305 | } |
306 | 306 | // Insert extra variables if the document successfully inserted. |
307 | 307 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
308 | - if(count($extra_keys)) |
|
308 | + if (count($extra_keys)) |
|
309 | 309 | { |
310 | - foreach($extra_keys as $idx => $extra_item) |
|
310 | + foreach ($extra_keys as $idx => $extra_item) |
|
311 | 311 | { |
312 | 312 | $value = NULL; |
313 | - if(isset($obj->{'extra_vars'.$idx})) |
|
313 | + if (isset($obj->{'extra_vars'.$idx})) |
|
314 | 314 | { |
315 | 315 | $tmp = $obj->{'extra_vars'.$idx}; |
316 | - if(is_array($tmp)) |
|
316 | + if (is_array($tmp)) |
|
317 | 317 | $value = implode('|@|', $tmp); |
318 | 318 | else |
319 | 319 | $value = trim($tmp); |
320 | 320 | } |
321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | - if($value == NULL) continue; |
|
321 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | + if ($value == NULL) continue; |
|
323 | 323 | |
324 | 324 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
325 | 325 | } |
326 | 326 | } |
327 | 327 | // Update the category if the category_srl exists. |
328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
328 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
329 | 329 | // Call a trigger (after) |
330 | - if($output->toBool()) |
|
330 | + if ($output->toBool()) |
|
331 | 331 | { |
332 | 332 | $trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj); |
333 | - if(!$trigger_output->toBool()) |
|
333 | + if (!$trigger_output->toBool()) |
|
334 | 334 | { |
335 | 335 | $oDB->rollback(); |
336 | 336 | return $trigger_output; |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | $oDB->commit(); |
342 | 342 | |
343 | 343 | // return |
344 | - if(!$manual_inserted) |
|
344 | + if (!$manual_inserted) |
|
345 | 345 | { |
346 | 346 | $this->addGrant($obj->document_srl); |
347 | 347 | } |
348 | - $output->add('document_srl',$obj->document_srl); |
|
349 | - $output->add('category_srl',$obj->category_srl); |
|
348 | + $output->add('document_srl', $obj->document_srl); |
|
349 | + $output->add('category_srl', $obj->category_srl); |
|
350 | 350 | |
351 | 351 | return $output; |
352 | 352 | } |
@@ -362,41 +362,41 @@ discard block |
||
362 | 362 | { |
363 | 363 | $logged_info = Context::get('logged_info'); |
364 | 364 | |
365 | - if(!$manual_updated && !checkCSRF()) |
|
365 | + if (!$manual_updated && !checkCSRF()) |
|
366 | 366 | { |
367 | 367 | return new BaseObject(-1, 'msg_invalid_request'); |
368 | 368 | } |
369 | 369 | |
370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
370 | + if (!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1, 'msg_invalied_request'); |
|
371 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | + if (!$obj->status) $obj->status = 'PUBLIC'; |
|
373 | 373 | |
374 | 374 | // Call a trigger (before) |
375 | 375 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
376 | - if(!$output->toBool()) return $output; |
|
376 | + if (!$output->toBool()) return $output; |
|
377 | 377 | |
378 | 378 | // begin transaction |
379 | 379 | $oDB = &DB::getInstance(); |
380 | 380 | $oDB->begin(); |
381 | 381 | |
382 | 382 | $oModuleModel = getModel('module'); |
383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
383 | + if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
384 | 384 | $module_srl = $obj->module_srl; |
385 | 385 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
386 | - if(!$document_config) |
|
386 | + if (!$document_config) |
|
387 | 387 | { |
388 | 388 | $document_config = new stdClass(); |
389 | 389 | } |
390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
390 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
391 | 391 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
392 | 392 | |
393 | - if($bUseHistory) |
|
393 | + if ($bUseHistory) |
|
394 | 394 | { |
395 | 395 | $args = new stdClass; |
396 | 396 | $args->history_srl = getNextSequence(); |
397 | 397 | $args->document_srl = $obj->document_srl; |
398 | 398 | $args->module_srl = $module_srl; |
399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
399 | + if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
400 | 400 | $args->nick_name = $logged_info->nick_name; |
401 | 401 | $args->member_srl = $logged_info->member_srl; |
402 | 402 | $args->regdate = $source_obj->get('last_update'); |
@@ -408,30 +408,30 @@ discard block |
||
408 | 408 | $obj->ipaddress = $source_obj->get('ipaddress'); |
409 | 409 | } |
410 | 410 | // List variables |
411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
415 | - if($obj->homepage) |
|
411 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
415 | + if ($obj->homepage) |
|
416 | 416 | { |
417 | 417 | $obj->homepage = removeHackTag($obj->homepage); |
418 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
418 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
419 | 419 | { |
420 | 420 | $obj->homepage = 'http://'.$obj->homepage; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
424 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
425 | 425 | |
426 | 426 | // can modify regdate only manager |
427 | 427 | $grant = Context::get('grant'); |
428 | - if(!$grant->manager) |
|
428 | + if (!$grant->manager) |
|
429 | 429 | { |
430 | 430 | unset($obj->regdate); |
431 | 431 | } |
432 | 432 | |
433 | 433 | // Serialize the $extra_vars |
434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
434 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
435 | 435 | // Remove the columns for automatic saving |
436 | 436 | unset($obj->_saved_doc_srl); |
437 | 437 | unset($obj->_saved_doc_title); |
@@ -440,23 +440,23 @@ discard block |
||
440 | 440 | |
441 | 441 | $oDocumentModel = getModel('document'); |
442 | 442 | // Set the category_srl to 0 if the changed category is not exsiting. |
443 | - if($source_obj->get('category_srl')!=$obj->category_srl) |
|
443 | + if ($source_obj->get('category_srl') != $obj->category_srl) |
|
444 | 444 | { |
445 | 445 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
446 | + if (!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
447 | 447 | } |
448 | 448 | // Change the update order |
449 | 449 | $obj->update_order = getNextSequence() * -1; |
450 | 450 | // Hash the password if it exists |
451 | - if($obj->password) |
|
451 | + if ($obj->password) |
|
452 | 452 | { |
453 | 453 | $obj->password = getModel('member')->hashPassword($obj->password); |
454 | 454 | } |
455 | 455 | |
456 | 456 | // If an author is identical to the modifier or history is used, use the logged-in user's information. |
457 | - if(Context::get('is_logged') && !$manual_updated) |
|
457 | + if (Context::get('is_logged') && !$manual_updated) |
|
458 | 458 | { |
459 | - if($source_obj->get('member_srl')==$logged_info->member_srl) |
|
459 | + if ($source_obj->get('member_srl') == $logged_info->member_srl) |
|
460 | 460 | { |
461 | 461 | $obj->member_srl = $logged_info->member_srl; |
462 | 462 | $obj->user_name = htmlspecialchars_decode($logged_info->user_name); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | // For the document written by logged-in user however no nick_name exists |
470 | - if($source_obj->get('member_srl')&& !$obj->nick_name) |
|
470 | + if ($source_obj->get('member_srl') && !$obj->nick_name) |
|
471 | 471 | { |
472 | 472 | $obj->member_srl = $source_obj->get('member_srl'); |
473 | 473 | $obj->user_name = $source_obj->get('user_name'); |
@@ -478,24 +478,24 @@ discard block |
||
478 | 478 | // If the tile is empty, extract string from the contents. |
479 | 479 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
480 | 480 | settype($obj->title, "string"); |
481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
481 | + if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
482 | 482 | // If no tile extracted from the contents, leave it untitled. |
483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
483 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
484 | 484 | // Remove XE's own tags from the contents. |
485 | 485 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
486 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
486 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
487 | 487 | { |
488 | - if($obj->use_html != 'Y') |
|
488 | + if ($obj->use_html != 'Y') |
|
489 | 489 | { |
490 | 490 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
491 | 491 | } |
492 | 492 | $obj->content = nl2br($obj->content); |
493 | 493 | } |
494 | 494 | // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. |
495 | - if($source_obj->get('lang_code') != Context::getLangType()) |
|
495 | + if ($source_obj->get('lang_code') != Context::getLangType()) |
|
496 | 496 | { |
497 | 497 | // Change not extra vars but language code of the original document if document's lang_code doesn't exist. |
498 | - if(!$source_obj->get('lang_code')) |
|
498 | + if (!$source_obj->get('lang_code')) |
|
499 | 499 | { |
500 | 500 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
501 | 501 | $lang_code_args->lang_code = Context::getLangType(); |
@@ -515,59 +515,59 @@ discard block |
||
515 | 515 | } |
516 | 516 | } |
517 | 517 | // Remove iframe and script if not a top adminisrator in the session. |
518 | - if($logged_info->is_admin != 'Y') |
|
518 | + if ($logged_info->is_admin != 'Y') |
|
519 | 519 | { |
520 | 520 | $obj->content = removeHackTag($obj->content); |
521 | 521 | } |
522 | 522 | // if temporary document, regdate is now setting |
523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
523 | + if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
524 | 524 | |
525 | 525 | // Insert data into the DB |
526 | 526 | $output = executeQuery('document.updateDocument', $obj); |
527 | - if(!$output->toBool()) |
|
527 | + if (!$output->toBool()) |
|
528 | 528 | { |
529 | 529 | $oDB->rollback(); |
530 | 530 | return $output; |
531 | 531 | } |
532 | 532 | // Remove all extra variables |
533 | - if(Context::get('act')!='procFileDelete') |
|
533 | + if (Context::get('act') != 'procFileDelete') |
|
534 | 534 | { |
535 | 535 | $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType()); |
536 | 536 | // Insert extra variables if the document successfully inserted. |
537 | 537 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
538 | - if(count($extra_keys)) |
|
538 | + if (count($extra_keys)) |
|
539 | 539 | { |
540 | - foreach($extra_keys as $idx => $extra_item) |
|
540 | + foreach ($extra_keys as $idx => $extra_item) |
|
541 | 541 | { |
542 | 542 | $value = NULL; |
543 | - if(isset($obj->{'extra_vars'.$idx})) |
|
543 | + if (isset($obj->{'extra_vars'.$idx})) |
|
544 | 544 | { |
545 | 545 | $tmp = $obj->{'extra_vars'.$idx}; |
546 | - if(is_array($tmp)) |
|
546 | + if (is_array($tmp)) |
|
547 | 547 | $value = implode('|@|', $tmp); |
548 | 548 | else |
549 | 549 | $value = trim($tmp); |
550 | 550 | } |
551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | - if($value == NULL) continue; |
|
551 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | + if ($value == NULL) continue; |
|
553 | 553 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
554 | 554 | } |
555 | 555 | } |
556 | 556 | // Inert extra vars for multi-language support of title and contents. |
557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
557 | + if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | + if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
559 | 559 | } |
560 | 560 | // Update the category if the category_srl exists. |
561 | - if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
561 | + if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
562 | 562 | { |
563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
563 | + if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
565 | 565 | } |
566 | 566 | // Call a trigger (after) |
567 | - if($output->toBool()) |
|
567 | + if ($output->toBool()) |
|
568 | 568 | { |
569 | 569 | $trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); |
570 | - if(!$trigger_output->toBool()) |
|
570 | + if (!$trigger_output->toBool()) |
|
571 | 571 | { |
572 | 572 | $oDB->rollback(); |
573 | 573 | return $trigger_output; |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | // commit |
578 | 578 | $oDB->commit(); |
579 | 579 | // Remove the thumbnail file |
580 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
580 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
581 | 581 | |
582 | - $output->add('document_srl',$obj->document_srl); |
|
582 | + $output->add('document_srl', $obj->document_srl); |
|
583 | 583 | //remove from cache |
584 | 584 | $oCacheHandler = CacheHandler::getInstance('object'); |
585 | - if($oCacheHandler->isSupport()) |
|
585 | + if ($oCacheHandler->isSupport()) |
|
586 | 586 | { |
587 | 587 | //remove document item from cache |
588 | - $cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
588 | + $cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl; |
|
589 | 589 | $oCacheHandler->delete($cache_key); |
590 | 590 | } |
591 | 591 | |
@@ -606,33 +606,33 @@ discard block |
||
606 | 606 | $trigger_obj = new stdClass(); |
607 | 607 | $trigger_obj->document_srl = $document_srl; |
608 | 608 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
609 | - if(!$output->toBool()) return $output; |
|
609 | + if (!$output->toBool()) return $output; |
|
610 | 610 | |
611 | 611 | // begin transaction |
612 | 612 | $oDB = &DB::getInstance(); |
613 | 613 | $oDB->begin(); |
614 | 614 | |
615 | - if(!$isEmptyTrash) |
|
615 | + if (!$isEmptyTrash) |
|
616 | 616 | { |
617 | 617 | // get model object of the document |
618 | 618 | $oDocumentModel = getModel('document'); |
619 | 619 | // Check if the documnet exists |
620 | 620 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
621 | 621 | } |
622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
622 | + else if ($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
623 | 623 | |
624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
624 | + if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
625 | 625 | // Check if a permossion is granted |
626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
626 | + if (!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
627 | 627 | |
628 | 628 | //if empty trash, document already deleted, therefore document not delete |
629 | 629 | $args = new stdClass(); |
630 | 630 | $args->document_srl = $document_srl; |
631 | - if(!$isEmptyTrash) |
|
631 | + if (!$isEmptyTrash) |
|
632 | 632 | { |
633 | 633 | // Delete the document |
634 | 634 | $output = executeQuery('document.deleteDocument', $args); |
635 | - if(!$output->toBool()) |
|
635 | + if (!$output->toBool()) |
|
636 | 636 | { |
637 | 637 | $oDB->rollback(); |
638 | 638 | return $output; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | |
644 | 644 | $this->deleteDocumentHistory(null, $document_srl, null); |
645 | 645 | // Update category information if the category_srl exists. |
646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
646 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
647 | 647 | // Delete a declared list |
648 | 648 | executeQuery('document.deleteDeclared', $args); |
649 | 649 | // Delete extra variable |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | |
652 | 652 | //this |
653 | 653 | // Call a trigger (after) |
654 | - if($output->toBool()) |
|
654 | + if ($output->toBool()) |
|
655 | 655 | { |
656 | 656 | $trigger_obj = $oDocument->getObjectVars(); |
657 | 657 | $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); |
658 | - if(!$trigger_output->toBool()) |
|
658 | + if (!$trigger_output->toBool()) |
|
659 | 659 | { |
660 | 660 | $oDB->rollback(); |
661 | 661 | return $trigger_output; |
@@ -667,16 +667,16 @@ discard block |
||
667 | 667 | $this->_deleteDocumentVotedLog($args); |
668 | 668 | |
669 | 669 | // Remove the thumbnail file |
670 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3))); |
|
670 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3))); |
|
671 | 671 | |
672 | 672 | // commit |
673 | 673 | $oDB->commit(); |
674 | 674 | |
675 | 675 | //remove from cache |
676 | 676 | $oCacheHandler = CacheHandler::getInstance('object'); |
677 | - if($oCacheHandler->isSupport()) |
|
677 | + if ($oCacheHandler->isSupport()) |
|
678 | 678 | { |
679 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
679 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
680 | 680 | $oCacheHandler->delete($cache_key); |
681 | 681 | } |
682 | 682 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | { |
724 | 724 | $trash_args = new stdClass(); |
725 | 725 | // Get trash_srl if a given trash_srl doesn't exist |
726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
726 | + if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
727 | 727 | else $trash_args->trash_srl = $obj->trash_srl; |
728 | 728 | // Get its module_srl which the document belongs to |
729 | 729 | $oDocumentModel = getModel('document'); |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | $trash_args->module_srl = $oDocument->get('module_srl'); |
733 | 733 | $obj->module_srl = $oDocument->get('module_srl'); |
734 | 734 | // Cannot throw data from the trash to the trash |
735 | - if($trash_args->module_srl == 0) return false; |
|
735 | + if ($trash_args->module_srl == 0) return false; |
|
736 | 736 | // Data setting |
737 | 737 | $trash_args->document_srl = $obj->document_srl; |
738 | 738 | $trash_args->description = $obj->description; |
739 | 739 | // Insert member's information only if the member is logged-in and not manually registered. |
740 | - if(Context::get('is_logged')&&!$manual_inserted) |
|
740 | + if (Context::get('is_logged') && !$manual_inserted) |
|
741 | 741 | { |
742 | 742 | $logged_info = Context::get('logged_info'); |
743 | 743 | $trash_args->member_srl = $logged_info->member_srl; |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | |
774 | 774 | $oTrashAdminController = getAdminController('trash'); |
775 | 775 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
776 | - if(!$output->toBool()) |
|
776 | + if (!$output->toBool()) |
|
777 | 777 | { |
778 | 778 | $oDB->rollback(); |
779 | 779 | return $output; |
780 | 780 | } |
781 | 781 | |
782 | 782 | $output = executeQuery('document.deleteDocument', $trash_args); |
783 | - if(!$output->toBool()) |
|
783 | + if (!$output->toBool()) |
|
784 | 784 | { |
785 | 785 | $oDB->rollback(); |
786 | 786 | return $output; |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | }*/ |
794 | 794 | |
795 | 795 | // update category |
796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
796 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
797 | 797 | |
798 | 798 | // remove thumbnails |
799 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
799 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
800 | 800 | // Set the attachment to be invalid state |
801 | - if($oDocument->hasUploadedFiles()) |
|
801 | + if ($oDocument->hasUploadedFiles()) |
|
802 | 802 | { |
803 | 803 | $args = new stdClass(); |
804 | 804 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -806,10 +806,10 @@ discard block |
||
806 | 806 | executeQuery('file.updateFileValid', $args); |
807 | 807 | } |
808 | 808 | // Call a trigger (after) |
809 | - if($output->toBool()) |
|
809 | + if ($output->toBool()) |
|
810 | 810 | { |
811 | 811 | $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj); |
812 | - if(!$trigger_output->toBool()) |
|
812 | + if (!$trigger_output->toBool()) |
|
813 | 813 | { |
814 | 814 | $oDB->rollback(); |
815 | 815 | return $trigger_output; |
@@ -821,9 +821,9 @@ discard block |
||
821 | 821 | |
822 | 822 | // Clear cache |
823 | 823 | $oCacheHandler = CacheHandler::getInstance('object'); |
824 | - if($oCacheHandler->isSupport()) |
|
824 | + if ($oCacheHandler->isSupport()) |
|
825 | 825 | { |
826 | - $cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
826 | + $cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl; |
|
827 | 827 | $oCacheHandler->delete($cache_key); |
828 | 828 | } |
829 | 829 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | function updateReadedCount(&$oDocument) |
839 | 839 | { |
840 | 840 | // Pass if Crawler access |
841 | - if(isCrawler()) return false; |
|
841 | + if (isCrawler()) return false; |
|
842 | 842 | |
843 | 843 | $document_srl = $oDocument->document_srl; |
844 | 844 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,19 +846,19 @@ discard block |
||
846 | 846 | |
847 | 847 | // Call a trigger when the read count is updated (before) |
848 | 848 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
849 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
850 | 850 | |
851 | 851 | // Pass if read count is increaded on the session information |
852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
852 | + if ($_SESSION['readed_document'][$document_srl]) return false; |
|
853 | 853 | |
854 | 854 | // Pass if the author's IP address is as same as visitor's. |
855 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
855 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
856 | 856 | { |
857 | 857 | $_SESSION['readed_document'][$document_srl] = true; |
858 | 858 | return false; |
859 | 859 | } |
860 | 860 | // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. |
861 | - if($member_srl && $logged_info->member_srl == $member_srl) |
|
861 | + if ($member_srl && $logged_info->member_srl == $member_srl) |
|
862 | 862 | { |
863 | 863 | $_SESSION['readed_document'][$document_srl] = true; |
864 | 864 | return false; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | |
875 | 875 | // Call a trigger when the read count is updated (after) |
876 | 876 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); |
877 | - if(!$trigger_output->toBool()) |
|
877 | + if (!$trigger_output->toBool()) |
|
878 | 878 | { |
879 | 879 | $oDB->rollback(); |
880 | 880 | return $trigger_output; |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | $oDB->commit(); |
884 | 884 | |
885 | 885 | $oCacheHandler = CacheHandler::getInstance('object'); |
886 | - if($oCacheHandler->isSupport()) |
|
886 | + if ($oCacheHandler->isSupport()) |
|
887 | 887 | { |
888 | 888 | //remove document item from cache |
889 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
889 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
890 | 890 | $oCacheHandler->delete($cache_key); |
891 | 891 | } |
892 | 892 | |
893 | 893 | // Register session |
894 | - if(!$_SESSION['banned_document'][$document_srl]) |
|
894 | + if (!$_SESSION['banned_document'][$document_srl]) |
|
895 | 895 | { |
896 | 896 | $_SESSION['readed_document'][$document_srl] = true; |
897 | 897 | } |
@@ -914,21 +914,21 @@ discard block |
||
914 | 914 | */ |
915 | 915 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
916 | 916 | { |
917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
917 | + if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1, 'msg_invalid_request'); |
|
918 | 918 | |
919 | 919 | $obj = new stdClass(); |
920 | 920 | $obj->module_srl = $module_srl; |
921 | 921 | $obj->var_idx = $var_idx; |
922 | 922 | $obj->var_name = $var_name; |
923 | 923 | $obj->var_type = $var_type; |
924 | - $obj->var_is_required = $var_is_required=='Y'?'Y':'N'; |
|
925 | - $obj->var_search = $var_search=='Y'?'Y':'N'; |
|
924 | + $obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N'; |
|
925 | + $obj->var_search = $var_search == 'Y' ? 'Y' : 'N'; |
|
926 | 926 | $obj->var_default = $var_default; |
927 | 927 | $obj->var_desc = $var_desc; |
928 | 928 | $obj->eid = $eid; |
929 | 929 | |
930 | 930 | $output = executeQuery('document.getDocumentExtraKeys', $obj); |
931 | - if(!$output->data) |
|
931 | + if (!$output->data) |
|
932 | 932 | { |
933 | 933 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
934 | 934 | } |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
943 | - if($oCacheHandler->isSupport()) |
|
943 | + if ($oCacheHandler->isSupport()) |
|
944 | 944 | { |
945 | 945 | $object_key = 'module_document_extra_keys:'.$module_srl; |
946 | 946 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -958,42 +958,42 @@ discard block |
||
958 | 958 | */ |
959 | 959 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
960 | 960 | { |
961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
961 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
962 | 962 | $obj = new stdClass(); |
963 | 963 | $obj->module_srl = $module_srl; |
964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
964 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
965 | 965 | |
966 | 966 | $oDB = DB::getInstance(); |
967 | 967 | $oDB->begin(); |
968 | 968 | |
969 | 969 | $output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj); |
970 | - if(!$output->toBool()) |
|
970 | + if (!$output->toBool()) |
|
971 | 971 | { |
972 | 972 | $oDB->rollback(); |
973 | 973 | return $output; |
974 | 974 | } |
975 | 975 | |
976 | - if($var_idx != NULL) |
|
976 | + if ($var_idx != NULL) |
|
977 | 977 | { |
978 | 978 | $output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj); |
979 | - if(!$output->toBool()) |
|
979 | + if (!$output->toBool()) |
|
980 | 980 | { |
981 | 981 | $oDB->rollback(); |
982 | 982 | return $output; |
983 | 983 | } |
984 | 984 | } |
985 | 985 | |
986 | - $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
987 | - if(!$output->toBool()) |
|
986 | + $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
987 | + if (!$output->toBool()) |
|
988 | 988 | { |
989 | 989 | $oDB->rollback(); |
990 | 990 | return $output; |
991 | 991 | } |
992 | 992 | |
993 | - if($var_idx != NULL) |
|
993 | + if ($var_idx != NULL) |
|
994 | 994 | { |
995 | 995 | $output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj); |
996 | - if(!$output->toBool()) |
|
996 | + if (!$output->toBool()) |
|
997 | 997 | { |
998 | 998 | $oDB->rollback(); |
999 | 999 | return $output; |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | $oDB->commit(); |
1004 | 1004 | |
1005 | 1005 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
1006 | - if($oCacheHandler->isSupport()) |
|
1006 | + if ($oCacheHandler->isSupport()) |
|
1007 | 1007 | { |
1008 | 1008 | $object_key = 'module_document_extra_keys:'.$module_srl; |
1009 | 1009 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | */ |
1026 | 1026 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
1027 | 1027 | { |
1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
1028 | + if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1, 'msg_invalid_request'); |
|
1029 | + if (!$lang_code) $lang_code = Context::getLangType(); |
|
1030 | 1030 | |
1031 | 1031 | $obj = new stdClass; |
1032 | 1032 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1052,10 @@ discard block |
||
1052 | 1052 | { |
1053 | 1053 | $obj = new stdClass(); |
1054 | 1054 | $obj->module_srl = $module_srl; |
1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
1055 | + if (!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | + if (!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | + if (!is_null($eid)) $obj->eid = $eid; |
|
1059 | 1059 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
1060 | 1060 | return $output; |
1061 | 1061 | } |
@@ -1069,10 +1069,10 @@ discard block |
||
1069 | 1069 | */ |
1070 | 1070 | function updateVotedCount($document_srl, $point = 1) |
1071 | 1071 | { |
1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
1072 | + if ($point > 0) $failed_voted = 'failed_voted'; |
|
1073 | 1073 | else $failed_voted = 'failed_blamed'; |
1074 | 1074 | // Return fail if session already has information about votes |
1075 | - if($_SESSION['voted_document'][$document_srl]) |
|
1075 | + if ($_SESSION['voted_document'][$document_srl]) |
|
1076 | 1076 | { |
1077 | 1077 | return new BaseObject(-1, $failed_voted); |
1078 | 1078 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | $oDocumentModel = getModel('document'); |
1081 | 1081 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
1082 | 1082 | // Pass if the author's IP address is as same as visitor's. |
1083 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
1083 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
1084 | 1084 | { |
1085 | 1085 | $_SESSION['voted_document'][$document_srl] = true; |
1086 | 1086 | return new BaseObject(-1, $failed_voted); |
@@ -1091,10 +1091,10 @@ discard block |
||
1091 | 1091 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
1092 | 1092 | |
1093 | 1093 | // Check if document's author is a member. |
1094 | - if($oDocument->get('member_srl')) |
|
1094 | + if ($oDocument->get('member_srl')) |
|
1095 | 1095 | { |
1096 | 1096 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
1097 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1097 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1098 | 1098 | { |
1099 | 1099 | $_SESSION['voted_document'][$document_srl] = true; |
1100 | 1100 | return new BaseObject(-1, $failed_voted); |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | // Use member_srl for logged-in members and IP address for non-members. |
1105 | 1105 | $args = new stdClass; |
1106 | - if($member_srl) |
|
1106 | + if ($member_srl) |
|
1107 | 1107 | { |
1108 | 1108 | $args->member_srl = $member_srl; |
1109 | 1109 | } |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | $args->document_srl = $document_srl; |
1115 | 1115 | $output = executeQuery('document.getDocumentVotedLogInfo', $args); |
1116 | 1116 | // Pass after registering a session if log information has vote-up logs |
1117 | - if($output->data->count) |
|
1117 | + if ($output->data->count) |
|
1118 | 1118 | { |
1119 | 1119 | $_SESSION['voted_document'][$document_srl] = true; |
1120 | 1120 | return new BaseObject(-1, $failed_voted); |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | $oDB->begin(); |
1126 | 1126 | |
1127 | 1127 | // Update the voted count |
1128 | - if($point < 0) |
|
1128 | + if ($point < 0) |
|
1129 | 1129 | { |
1130 | 1130 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
1131 | 1131 | $output = executeQuery('document.updateBlamedCount', $args); |
@@ -1135,11 +1135,11 @@ discard block |
||
1135 | 1135 | $args->voted_count = $oDocument->get('voted_count') + $point; |
1136 | 1136 | $output = executeQuery('document.updateVotedCount', $args); |
1137 | 1137 | } |
1138 | - if(!$output->toBool()) return $output; |
|
1138 | + if (!$output->toBool()) return $output; |
|
1139 | 1139 | // Leave logs |
1140 | 1140 | $args->point = $point; |
1141 | 1141 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
1142 | - if(!$output->toBool()) return $output; |
|
1142 | + if (!$output->toBool()) return $output; |
|
1143 | 1143 | |
1144 | 1144 | $obj = new stdClass; |
1145 | 1145 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | $obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); |
1151 | 1151 | $obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count; |
1152 | 1152 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj); |
1153 | - if(!$trigger_output->toBool()) |
|
1153 | + if (!$trigger_output->toBool()) |
|
1154 | 1154 | { |
1155 | 1155 | $oDB->rollback(); |
1156 | 1156 | return $trigger_output; |
@@ -1159,10 +1159,10 @@ discard block |
||
1159 | 1159 | $oDB->commit(); |
1160 | 1160 | |
1161 | 1161 | $oCacheHandler = CacheHandler::getInstance('object'); |
1162 | - if($oCacheHandler->isSupport()) |
|
1162 | + if ($oCacheHandler->isSupport()) |
|
1163 | 1163 | { |
1164 | 1164 | //remove document item from cache |
1165 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1165 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1166 | 1166 | $oCacheHandler->delete($cache_key); |
1167 | 1167 | } |
1168 | 1168 | |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | |
1172 | 1172 | // Return result |
1173 | 1173 | $output = new BaseObject(); |
1174 | - if($point > 0) |
|
1174 | + if ($point > 0) |
|
1175 | 1175 | { |
1176 | 1176 | $output->setMessage('success_voted'); |
1177 | 1177 | $output->add('voted_count', $obj->after_point); |
@@ -1193,13 +1193,13 @@ discard block |
||
1193 | 1193 | function declaredDocument($document_srl) |
1194 | 1194 | { |
1195 | 1195 | // Fail if session information already has a reported document |
1196 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1196 | + if ($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1197 | 1197 | |
1198 | 1198 | // Check if previously reported |
1199 | 1199 | $args = new stdClass(); |
1200 | 1200 | $args->document_srl = $document_srl; |
1201 | 1201 | $output = executeQuery('document.getDeclaredDocument', $args); |
1202 | - if(!$output->toBool()) return $output; |
|
1202 | + if (!$output->toBool()) return $output; |
|
1203 | 1203 | |
1204 | 1204 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
1205 | 1205 | |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | // Call a trigger (before) |
1211 | 1211 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); |
1212 | - if(!$trigger_output->toBool()) |
|
1212 | + if (!$trigger_output->toBool()) |
|
1213 | 1213 | { |
1214 | 1214 | return $trigger_output; |
1215 | 1215 | } |
@@ -1219,19 +1219,19 @@ discard block |
||
1219 | 1219 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
1220 | 1220 | |
1221 | 1221 | // Pass if the author's IP address is as same as visitor's. |
1222 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
1222 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
1223 | 1223 | $_SESSION['declared_document'][$document_srl] = true; |
1224 | 1224 | return new BaseObject(-1, 'failed_declared'); |
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | // Check if document's author is a member. |
1228 | - if($oDocument->get('member_srl')) |
|
1228 | + if ($oDocument->get('member_srl')) |
|
1229 | 1229 | { |
1230 | 1230 | // Create a member model object |
1231 | 1231 | $oMemberModel = getModel('member'); |
1232 | 1232 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
1233 | 1233 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
1234 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1234 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1235 | 1235 | { |
1236 | 1236 | $_SESSION['declared_document'][$document_srl] = true; |
1237 | 1237 | return new BaseObject(-1, 'failed_declared'); |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | |
1241 | 1241 | // Use member_srl for logged-in members and IP address for non-members. |
1242 | 1242 | $args = new stdClass; |
1243 | - if($member_srl) |
|
1243 | + if ($member_srl) |
|
1244 | 1244 | { |
1245 | 1245 | $args->member_srl = $member_srl; |
1246 | 1246 | } |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); |
1254 | 1254 | |
1255 | 1255 | // Pass after registering a sesson if reported/declared documents are in the logs. |
1256 | - if($output->data->count) |
|
1256 | + if ($output->data->count) |
|
1257 | 1257 | { |
1258 | 1258 | $_SESSION['declared_document'][$document_srl] = true; |
1259 | 1259 | return new BaseObject(-1, 'failed_declared'); |
@@ -1264,23 +1264,23 @@ discard block |
||
1264 | 1264 | $oDB->begin(); |
1265 | 1265 | |
1266 | 1266 | // Add the declared document |
1267 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1267 | + if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1268 | 1268 | else $output = executeQuery('document.insertDeclaredDocument', $args); |
1269 | - if(!$output->toBool()) return $output; |
|
1269 | + if (!$output->toBool()) return $output; |
|
1270 | 1270 | // Leave logs |
1271 | 1271 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
1272 | - if(!$output->toBool()) |
|
1272 | + if (!$output->toBool()) |
|
1273 | 1273 | { |
1274 | 1274 | $oDB->rollback(); |
1275 | 1275 | return $output; |
1276 | 1276 | } |
1277 | 1277 | |
1278 | - $this->add('declared_count', $declared_count+1); |
|
1278 | + $this->add('declared_count', $declared_count + 1); |
|
1279 | 1279 | |
1280 | 1280 | // Call a trigger (after) |
1281 | 1281 | $trigger_obj->declared_count = $declared_count + 1; |
1282 | 1282 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); |
1283 | - if(!$trigger_output->toBool()) |
|
1283 | + if (!$trigger_output->toBool()) |
|
1284 | 1284 | { |
1285 | 1285 | $oDB->rollback(); |
1286 | 1286 | return $trigger_output; |
@@ -1310,16 +1310,16 @@ discard block |
||
1310 | 1310 | $args->document_srl = $document_srl; |
1311 | 1311 | $args->comment_count = $comment_count; |
1312 | 1312 | |
1313 | - if($comment_inserted) |
|
1313 | + if ($comment_inserted) |
|
1314 | 1314 | { |
1315 | - $args->update_order = -1*getNextSequence(); |
|
1315 | + $args->update_order = -1 * getNextSequence(); |
|
1316 | 1316 | $args->last_updater = $last_updater; |
1317 | 1317 | |
1318 | 1318 | $oCacheHandler = CacheHandler::getInstance('object'); |
1319 | - if($oCacheHandler->isSupport()) |
|
1319 | + if ($oCacheHandler->isSupport()) |
|
1320 | 1320 | { |
1321 | 1321 | //remove document item from cache |
1322 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1322 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1323 | 1323 | $oCacheHandler->delete($cache_key); |
1324 | 1324 | } |
1325 | 1325 | } |
@@ -1340,10 +1340,10 @@ discard block |
||
1340 | 1340 | $args->trackback_count = $trackback_count; |
1341 | 1341 | |
1342 | 1342 | $oCacheHandler = CacheHandler::getInstance('object'); |
1343 | - if($oCacheHandler->isSupport()) |
|
1343 | + if ($oCacheHandler->isSupport()) |
|
1344 | 1344 | { |
1345 | 1345 | //remove document item from cache |
1346 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1346 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1347 | 1347 | $oCacheHandler->delete($cache_key); |
1348 | 1348 | } |
1349 | 1349 | |
@@ -1358,14 +1358,14 @@ discard block |
||
1358 | 1358 | function insertCategory($obj) |
1359 | 1359 | { |
1360 | 1360 | // Sort the order to display if a child category is added |
1361 | - if($obj->parent_srl) |
|
1361 | + if ($obj->parent_srl) |
|
1362 | 1362 | { |
1363 | 1363 | // Get its parent category |
1364 | 1364 | $oDocumentModel = getModel('document'); |
1365 | 1365 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
1366 | 1366 | $obj->list_order = $parent_category->list_order; |
1367 | - $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
|
1368 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1367 | + $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1); |
|
1368 | + if (!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1369 | 1369 | } |
1370 | 1370 | else |
1371 | 1371 | { |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | $output = executeQuery('document.insertCategory', $obj); |
1376 | - if($output->toBool()) |
|
1376 | + if ($output->toBool()) |
|
1377 | 1377 | { |
1378 | 1378 | $output->add('category_srl', $obj->category_srl); |
1379 | 1379 | $this->makeCategoryFile($obj->module_srl); |
@@ -1407,13 +1407,13 @@ discard block |
||
1407 | 1407 | { |
1408 | 1408 | // Create a document model object |
1409 | 1409 | $oDocumentModel = getModel('document'); |
1410 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1410 | + if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl); |
|
1411 | 1411 | |
1412 | 1412 | $args = new stdClass; |
1413 | 1413 | $args->category_srl = $category_srl; |
1414 | 1414 | $args->document_count = $document_count; |
1415 | 1415 | $output = executeQuery('document.updateCategoryCount', $args); |
1416 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1416 | + if ($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1417 | 1417 | |
1418 | 1418 | return $output; |
1419 | 1419 | } |
@@ -1426,7 +1426,7 @@ discard block |
||
1426 | 1426 | function updateCategory($obj) |
1427 | 1427 | { |
1428 | 1428 | $output = executeQuery('document.updateCategory', $obj); |
1429 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1429 | + if ($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1430 | 1430 | return $output; |
1431 | 1431 | } |
1432 | 1432 | |
@@ -1443,32 +1443,32 @@ discard block |
||
1443 | 1443 | $category_info = $oDocumentModel->getCategory($category_srl); |
1444 | 1444 | // Display an error that the category cannot be deleted if it has a child |
1445 | 1445 | $output = executeQuery('document.getChildCategoryCount', $args); |
1446 | - if(!$output->toBool()) return $output; |
|
1447 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1446 | + if (!$output->toBool()) return $output; |
|
1447 | + if ($output->data->count > 0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1448 | 1448 | // Delete a category information |
1449 | 1449 | $output = executeQuery('document.deleteCategory', $args); |
1450 | - if(!$output->toBool()) return $output; |
|
1450 | + if (!$output->toBool()) return $output; |
|
1451 | 1451 | |
1452 | 1452 | $this->makeCategoryFile($category_info->module_srl); |
1453 | 1453 | // remvove cache |
1454 | 1454 | $oCacheHandler = CacheHandler::getInstance('object'); |
1455 | - if($oCacheHandler->isSupport()) |
|
1455 | + if ($oCacheHandler->isSupport()) |
|
1456 | 1456 | { |
1457 | 1457 | $page = 0; |
1458 | - while(true) { |
|
1458 | + while (true) { |
|
1459 | 1459 | $args = new stdClass(); |
1460 | 1460 | $args->category_srl = $category_srl; |
1461 | 1461 | $args->list_count = 100; |
1462 | 1462 | $args->page = ++$page; |
1463 | 1463 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
1464 | 1464 | |
1465 | - if($output->data == array()) |
|
1465 | + if ($output->data == array()) |
|
1466 | 1466 | break; |
1467 | 1467 | |
1468 | - foreach($output->data as $val) |
|
1468 | + foreach ($output->data as $val) |
|
1469 | 1469 | { |
1470 | 1470 | //remove document item from cache |
1471 | - $cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl; |
|
1471 | + $cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl; |
|
1472 | 1472 | $oCacheHandler->delete($cache_key); |
1473 | 1473 | } |
1474 | 1474 | } |
@@ -1515,18 +1515,18 @@ discard block |
||
1515 | 1515 | // Seek a full list of categories |
1516 | 1516 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1517 | 1517 | $category_srl_list = array_keys($category_list); |
1518 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1518 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
1519 | 1519 | |
1520 | 1520 | $prev_category = NULL; |
1521 | - foreach($category_list as $key => $val) |
|
1521 | + foreach ($category_list as $key => $val) |
|
1522 | 1522 | { |
1523 | - if($key==$category_srl) break; |
|
1523 | + if ($key == $category_srl) break; |
|
1524 | 1524 | $prev_category = $val; |
1525 | 1525 | } |
1526 | 1526 | // Return if the previous category doesn't exist |
1527 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1527 | + if (!$prev_category) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1528 | 1528 | // Return if the selected category is the top level |
1529 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1529 | + if ($category_srl_list[0] == $category_srl) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1530 | 1530 | // Information of the selected category |
1531 | 1531 | $cur_args = new stdClass; |
1532 | 1532 | $cur_args->category_srl = $category_srl; |
@@ -1562,15 +1562,15 @@ discard block |
||
1562 | 1562 | // Seek a full list of categories |
1563 | 1563 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1564 | 1564 | $category_srl_list = array_keys($category_list); |
1565 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1565 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
1566 | 1566 | |
1567 | - for($i=0;$i<count($category_srl_list);$i++) |
|
1567 | + for ($i = 0; $i < count($category_srl_list); $i++) |
|
1568 | 1568 | { |
1569 | - if($category_srl_list[$i]==$category_srl) break; |
|
1569 | + if ($category_srl_list[$i] == $category_srl) break; |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | - $next_category_srl = $category_srl_list[$i+1]; |
|
1573 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1572 | + $next_category_srl = $category_srl_list[$i + 1]; |
|
1573 | + if (!$category_list[$next_category_srl]) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1574 | 1574 | $next_category = $category_list[$next_category_srl]; |
1575 | 1575 | // Information of the selected category |
1576 | 1576 | $cur_args = new stdClass; |
@@ -1597,7 +1597,7 @@ discard block |
||
1597 | 1597 | { |
1598 | 1598 | $oDocumentModel = getModel('document'); |
1599 | 1599 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
1600 | - if(!count($extra_keys)) return; |
|
1600 | + if (!count($extra_keys)) return; |
|
1601 | 1601 | |
1602 | 1602 | $js_code = array(); |
1603 | 1603 | $js_code[] = '<script>//<![CDATA['; |
@@ -1607,16 +1607,16 @@ discard block |
||
1607 | 1607 | |
1608 | 1608 | $logged_info = Context::get('logged_info'); |
1609 | 1609 | |
1610 | - foreach($extra_keys as $idx => $val) |
|
1610 | + foreach ($extra_keys as $idx => $val) |
|
1611 | 1611 | { |
1612 | 1612 | $idx = $val->idx; |
1613 | - if($val->type == 'kr_zip') |
|
1613 | + if ($val->type == 'kr_zip') |
|
1614 | 1614 | { |
1615 | 1615 | $idx .= '[]'; |
1616 | 1616 | } |
1617 | 1617 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
1618 | 1618 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
1619 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1619 | + if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | 1622 | $js_code[] = '})(jQuery);'; |
@@ -1634,12 +1634,12 @@ discard block |
||
1634 | 1634 | function procDocumentInsertCategory($args = null) |
1635 | 1635 | { |
1636 | 1636 | // List variables |
1637 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1637 | + if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid'); |
|
1638 | 1638 | $args->title = $args->category_title; |
1639 | 1639 | $args->description = $args->category_description; |
1640 | 1640 | $args->color = $args->category_color; |
1641 | 1641 | |
1642 | - if(!$args->module_srl && $args->mid) |
|
1642 | + if (!$args->module_srl && $args->mid) |
|
1643 | 1643 | { |
1644 | 1644 | $mid = $args->mid; |
1645 | 1645 | unset($args->mid); |
@@ -1650,28 +1650,28 @@ discard block |
||
1650 | 1650 | $columnList = array('module_srl', 'module'); |
1651 | 1651 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1652 | 1652 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1653 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1653 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1654 | 1654 | |
1655 | - if($args->expand !="Y") $args->expand = "N"; |
|
1656 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1655 | + if ($args->expand != "Y") $args->expand = "N"; |
|
1656 | + if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls); |
|
1657 | 1657 | else $args->group_srls = implode(',', $args->group_srls); |
1658 | - $args->parent_srl = (int)$args->parent_srl; |
|
1658 | + $args->parent_srl = (int) $args->parent_srl; |
|
1659 | 1659 | |
1660 | 1660 | $oDocumentModel = getModel('document'); |
1661 | 1661 | |
1662 | 1662 | $oDB = &DB::getInstance(); |
1663 | 1663 | $oDB->begin(); |
1664 | 1664 | // Check if already exists |
1665 | - if($args->category_srl) |
|
1665 | + if ($args->category_srl) |
|
1666 | 1666 | { |
1667 | 1667 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1668 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1668 | + if ($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1669 | 1669 | } |
1670 | 1670 | // Update if exists |
1671 | - if($args->category_srl) |
|
1671 | + if ($args->category_srl) |
|
1672 | 1672 | { |
1673 | 1673 | $output = $this->updateCategory($args); |
1674 | - if(!$output->toBool()) |
|
1674 | + if (!$output->toBool()) |
|
1675 | 1675 | { |
1676 | 1676 | $oDB->rollback(); |
1677 | 1677 | return $output; |
@@ -1681,7 +1681,7 @@ discard block |
||
1681 | 1681 | else |
1682 | 1682 | { |
1683 | 1683 | $output = $this->insertCategory($args); |
1684 | - if(!$output->toBool()) |
|
1684 | + if (!$output->toBool()) |
|
1685 | 1685 | { |
1686 | 1686 | $oDB->rollback(); |
1687 | 1687 | return $output; |
@@ -1720,11 +1720,11 @@ discard block |
||
1720 | 1720 | $columnList = array('module_srl', 'module'); |
1721 | 1721 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
1722 | 1722 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1723 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1723 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1724 | 1724 | |
1725 | 1725 | // First child of the parent_category_srl |
1726 | 1726 | $source_args = new stdClass; |
1727 | - if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
1727 | + if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
1728 | 1728 | { |
1729 | 1729 | $parent_category = $oDocumentModel->getCategory($parent_category_srl); |
1730 | 1730 | |
@@ -1733,30 +1733,30 @@ discard block |
||
1733 | 1733 | $args->parent_srl = $parent_category_srl; |
1734 | 1734 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
1735 | 1735 | |
1736 | - if(!$output->toBool()) return $output; |
|
1737 | - $args->list_order = (int)$output->data->list_order; |
|
1738 | - if(!$args->list_order) $args->list_order = 0; |
|
1736 | + if (!$output->toBool()) return $output; |
|
1737 | + $args->list_order = (int) $output->data->list_order; |
|
1738 | + if (!$args->list_order) $args->list_order = 0; |
|
1739 | 1739 | $args->list_order--; |
1740 | 1740 | |
1741 | 1741 | $source_args->category_srl = $source_category_srl; |
1742 | 1742 | $source_args->parent_srl = $parent_category_srl; |
1743 | 1743 | $source_args->list_order = $args->list_order; |
1744 | 1744 | $output = $this->updateCategory($source_args); |
1745 | - if(!$output->toBool()) return $output; |
|
1745 | + if (!$output->toBool()) return $output; |
|
1746 | 1746 | // Sibling of the $target_category_srl |
1747 | 1747 | } |
1748 | - else if($target_category_srl > 0) |
|
1748 | + else if ($target_category_srl > 0) |
|
1749 | 1749 | { |
1750 | 1750 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
1751 | 1751 | // Move all siblings of the $target_category down |
1752 | - $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
|
1753 | - if(!$output->toBool()) return $output; |
|
1752 | + $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1); |
|
1753 | + if (!$output->toBool()) return $output; |
|
1754 | 1754 | |
1755 | 1755 | $source_args->category_srl = $source_category_srl; |
1756 | 1756 | $source_args->parent_srl = $target_category->parent_srl; |
1757 | - $source_args->list_order = $target_category->list_order+1; |
|
1757 | + $source_args->list_order = $target_category->list_order + 1; |
|
1758 | 1758 | $output = $this->updateCategory($source_args); |
1759 | - if(!$output->toBool()) return $output; |
|
1759 | + if (!$output->toBool()) return $output; |
|
1760 | 1760 | } |
1761 | 1761 | // Re-generate the xml file |
1762 | 1762 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | function procDocumentDeleteCategory() |
1773 | 1773 | { |
1774 | 1774 | // List variables |
1775 | - $args = Context::gets('module_srl','category_srl'); |
|
1775 | + $args = Context::gets('module_srl', 'category_srl'); |
|
1776 | 1776 | |
1777 | 1777 | $oDB = &DB::getInstance(); |
1778 | 1778 | $oDB->begin(); |
@@ -1781,17 +1781,17 @@ discard block |
||
1781 | 1781 | $columnList = array('module_srl', 'module'); |
1782 | 1782 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1783 | 1783 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1784 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1784 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1785 | 1785 | |
1786 | 1786 | $oDocumentModel = getModel('document'); |
1787 | 1787 | // Get original information |
1788 | 1788 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1789 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
1789 | + if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
1790 | 1790 | // Display an error that the category cannot be deleted if it has a child node |
1791 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1791 | + if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1792 | 1792 | // Remove from the DB |
1793 | 1793 | $output = $this->deleteCategory($args->category_srl); |
1794 | - if(!$output->toBool()) |
|
1794 | + if (!$output->toBool()) |
|
1795 | 1795 | { |
1796 | 1796 | $oDB->rollback(); |
1797 | 1797 | return $output; |
@@ -1822,11 +1822,11 @@ discard block |
||
1822 | 1822 | $columnList = array('module_srl', 'module'); |
1823 | 1823 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1824 | 1824 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1825 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1825 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1826 | 1826 | |
1827 | 1827 | $xml_file = $this->makeCategoryFile($module_srl); |
1828 | 1828 | // Set return value |
1829 | - $this->add('xml_file',$xml_file); |
|
1829 | + $this->add('xml_file', $xml_file); |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | /** |
@@ -1837,14 +1837,14 @@ discard block |
||
1837 | 1837 | function makeCategoryFile($module_srl) |
1838 | 1838 | { |
1839 | 1839 | // Return if there is no information you need for creating a cache file |
1840 | - if(!$module_srl) return false; |
|
1840 | + if (!$module_srl) return false; |
|
1841 | 1841 | // Get module information (to obtain mid) |
1842 | 1842 | $oModuleModel = getModel('module'); |
1843 | 1843 | $columnList = array('module_srl', 'mid', 'site_srl'); |
1844 | 1844 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1845 | 1845 | $mid = $module_info->mid; |
1846 | 1846 | |
1847 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
1847 | + if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
1848 | 1848 | // Cache file's name |
1849 | 1849 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
1850 | 1850 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1856,17 +1856,17 @@ discard block |
||
1856 | 1856 | |
1857 | 1857 | $category_list = $output->data; |
1858 | 1858 | |
1859 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
1859 | + if (!is_array($category_list)) $category_list = array($category_list); |
|
1860 | 1860 | |
1861 | 1861 | $category_count = count($category_list); |
1862 | - for($i=0;$i<$category_count;$i++) |
|
1862 | + for ($i = 0; $i < $category_count; $i++) |
|
1863 | 1863 | { |
1864 | 1864 | $category_srl = $category_list[$i]->category_srl; |
1865 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
1865 | + if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
1866 | 1866 | $list[$category_srl] = $category_list[$i]; |
1867 | 1867 | } |
1868 | 1868 | // Create the xml file without node data if no data is obtained |
1869 | - if(!$list) |
|
1869 | + if (!$list) |
|
1870 | 1870 | { |
1871 | 1871 | $xml_buff = "<root />"; |
1872 | 1872 | FileHandler::writeFile($xml_file, $xml_buff); |
@@ -1874,12 +1874,12 @@ discard block |
||
1874 | 1874 | return $xml_file; |
1875 | 1875 | } |
1876 | 1876 | // Change to an array if only a single data is obtained |
1877 | - if(!is_array($list)) $list = array($list); |
|
1877 | + if (!is_array($list)) $list = array($list); |
|
1878 | 1878 | // Create a tree for loop |
1879 | - foreach($list as $category_srl => $node) |
|
1879 | + foreach ($list as $category_srl => $node) |
|
1880 | 1880 | { |
1881 | 1881 | $node->mid = $mid; |
1882 | - $parent_srl = (int)$node->parent_srl; |
|
1882 | + $parent_srl = (int) $node->parent_srl; |
|
1883 | 1883 | $tree[$parent_srl][$category_srl] = $node; |
1884 | 1884 | } |
1885 | 1885 | // A common header to set permissions and groups of the cache file |
@@ -1953,13 +1953,13 @@ discard block |
||
1953 | 1953 | */ |
1954 | 1954 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
1955 | 1955 | { |
1956 | - if(!$source_node) return; |
|
1956 | + if (!$source_node) return; |
|
1957 | 1957 | |
1958 | - foreach($source_node as $category_srl => $node) |
|
1958 | + foreach ($source_node as $category_srl => $node) |
|
1959 | 1959 | { |
1960 | 1960 | $child_buff = ""; |
1961 | 1961 | // Get data of the child nodes |
1962 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
1962 | + if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
1963 | 1963 | // List variables |
1964 | 1964 | $expand = ($node->expand) ? $node->expand : 'N'; |
1965 | 1965 | $group_srls = ($node->group_srls) ? $node->group_srls : ''; |
@@ -1969,27 +1969,27 @@ discard block |
||
1969 | 1969 | $color = ($node->color) ? $node->color : ''; |
1970 | 1970 | $description = ($node->description) ? $node->description : ''; |
1971 | 1971 | // If node->group_srls value exists |
1972 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
1972 | + if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls); |
|
1973 | 1973 | else $group_check_code = "true"; |
1974 | 1974 | |
1975 | 1975 | $title = $node->title; |
1976 | 1976 | $oModuleAdminModel = getAdminModel('module'); |
1977 | 1977 | |
1978 | 1978 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
1979 | - if(count($langs)) |
|
1979 | + if (count($langs)) |
|
1980 | 1980 | { |
1981 | - foreach($langs as $key => $val) |
|
1981 | + foreach ($langs as $key => $val) |
|
1982 | 1982 | { |
1983 | - $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1983 | + $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1984 | 1984 | } |
1985 | 1985 | } |
1986 | 1986 | |
1987 | 1987 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
1988 | - if(count($langx)) |
|
1988 | + if (count($langx)) |
|
1989 | 1989 | { |
1990 | - foreach($langx as $key => $val) |
|
1990 | + foreach ($langx as $key => $val) |
|
1991 | 1991 | { |
1992 | - $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1992 | + $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1993 | 1993 | } |
1994 | 1994 | } |
1995 | 1995 | |
@@ -2002,7 +2002,7 @@ discard block |
||
2002 | 2002 | $category_srl, |
2003 | 2003 | $group_check_code, |
2004 | 2004 | $category_srl, |
2005 | - var_export(getUrl('','mid',$node->mid,'category',$category_srl), true), |
|
2005 | + var_export(getUrl('', 'mid', $node->mid, 'category', $category_srl), true), |
|
2006 | 2006 | var_export($expand, true), |
2007 | 2007 | var_export($color, true), |
2008 | 2008 | $group_check_code, |
@@ -2010,8 +2010,8 @@ discard block |
||
2010 | 2010 | $node->document_count |
2011 | 2011 | ); |
2012 | 2012 | |
2013 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2014 | - else $buff .= sprintf('<node %s />', $attribute); |
|
2013 | + if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2014 | + else $buff .= sprintf('<node %s />', $attribute); |
|
2015 | 2015 | } |
2016 | 2016 | return $buff; |
2017 | 2017 | } |
@@ -2030,13 +2030,13 @@ discard block |
||
2030 | 2030 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
2031 | 2031 | { |
2032 | 2032 | $output = array("buff"=>"", "category_srl_list"=>array()); |
2033 | - if(!$source_node) return $output; |
|
2033 | + if (!$source_node) return $output; |
|
2034 | 2034 | |
2035 | 2035 | // Set to an arraty for looping and then generate php script codes to be included |
2036 | - foreach($source_node as $category_srl => $node) |
|
2036 | + foreach ($source_node as $category_srl => $node) |
|
2037 | 2037 | { |
2038 | 2038 | // Get data from child nodes first if exist. |
2039 | - if($category_srl && $tree[$category_srl]){ |
|
2039 | + if ($category_srl && $tree[$category_srl]) { |
|
2040 | 2040 | $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff); |
2041 | 2041 | } else { |
2042 | 2042 | $child_output = array("buff"=>"", "category_srl_list"=>array()); |
@@ -2047,14 +2047,14 @@ discard block |
||
2047 | 2047 | $output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']); |
2048 | 2048 | |
2049 | 2049 | // If node->group_srls value exists |
2050 | - if($node->group_srls) { |
|
2051 | - $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls); |
|
2050 | + if ($node->group_srls) { |
|
2051 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls); |
|
2052 | 2052 | } else { |
2053 | 2053 | $group_check_code = "true"; |
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | // List variables |
2057 | - $selected = '"' . implode('","', $child_output['category_srl_list']) . '"'; |
|
2057 | + $selected = '"'.implode('","', $child_output['category_srl_list']).'"'; |
|
2058 | 2058 | $child_buff = $child_output['buff']; |
2059 | 2059 | $expand = $node->expand; |
2060 | 2060 | |
@@ -2063,32 +2063,32 @@ discard block |
||
2063 | 2063 | $oModuleAdminModel = getAdminModel('module'); |
2064 | 2064 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
2065 | 2065 | |
2066 | - if(count($langs)) |
|
2066 | + if (count($langs)) |
|
2067 | 2067 | { |
2068 | - foreach($langs as $key => $val) |
|
2068 | + foreach ($langs as $key => $val) |
|
2069 | 2069 | { |
2070 | 2070 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
2071 | 2071 | $php_header_buff .= sprintf( |
2072 | 2072 | '$_titles[%d]["%s"] = %s; ', |
2073 | 2073 | $category_srl, |
2074 | 2074 | $key, |
2075 | - var_export(str_replace('"','\\"', $val), true) |
|
2075 | + var_export(str_replace('"', '\\"', $val), true) |
|
2076 | 2076 | ); |
2077 | 2077 | } |
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
2081 | 2081 | |
2082 | - if(count($langx)) |
|
2082 | + if (count($langx)) |
|
2083 | 2083 | { |
2084 | - foreach($langx as $key => $val) |
|
2084 | + foreach ($langx as $key => $val) |
|
2085 | 2085 | { |
2086 | 2086 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
2087 | 2087 | $php_header_buff .= sprintf( |
2088 | 2088 | '$_descriptions[%d]["%s"] = %s; ', |
2089 | 2089 | $category_srl, |
2090 | 2090 | $key, |
2091 | - var_export(str_replace('"','\\"', $val), true) |
|
2091 | + var_export(str_replace('"', '\\"', $val), true) |
|
2092 | 2092 | ); |
2093 | 2093 | } |
2094 | 2094 | } |
@@ -2112,7 +2112,7 @@ discard block |
||
2112 | 2112 | ); |
2113 | 2113 | |
2114 | 2114 | // Generate buff data |
2115 | - $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
2115 | + $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
2116 | 2116 | } |
2117 | 2117 | |
2118 | 2118 | return $output; |
@@ -2129,7 +2129,7 @@ discard block |
||
2129 | 2129 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
2130 | 2130 | { |
2131 | 2131 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
2132 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2132 | + if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2133 | 2133 | |
2134 | 2134 | $obj = new stdClass(); |
2135 | 2135 | $obj->url = $url; |
@@ -2147,68 +2147,68 @@ discard block |
||
2147 | 2147 | */ |
2148 | 2148 | function procDocumentAddCart() |
2149 | 2149 | { |
2150 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2150 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2151 | 2151 | |
2152 | 2152 | // Get document_srl |
2153 | - $srls = explode(',',Context::get('srls')); |
|
2154 | - for($i = 0; $i < count($srls); $i++) |
|
2153 | + $srls = explode(',', Context::get('srls')); |
|
2154 | + for ($i = 0; $i < count($srls); $i++) |
|
2155 | 2155 | { |
2156 | 2156 | $srl = trim($srls[$i]); |
2157 | 2157 | |
2158 | - if(!$srl) continue; |
|
2158 | + if (!$srl) continue; |
|
2159 | 2159 | |
2160 | 2160 | $document_srls[] = $srl; |
2161 | 2161 | } |
2162 | - if(!count($document_srls)) return; |
|
2162 | + if (!count($document_srls)) return; |
|
2163 | 2163 | |
2164 | 2164 | // Get module_srl of the documents |
2165 | 2165 | $args = new stdClass; |
2166 | 2166 | $args->list_count = count($document_srls); |
2167 | - $args->document_srls = implode(',',$document_srls); |
|
2167 | + $args->document_srls = implode(',', $document_srls); |
|
2168 | 2168 | $args->order_type = 'asc'; |
2169 | 2169 | $output = executeQueryArray('document.getDocuments', $args); |
2170 | - if(!$output->data) return new BaseObject(); |
|
2170 | + if (!$output->data) return new BaseObject(); |
|
2171 | 2171 | |
2172 | 2172 | unset($document_srls); |
2173 | - foreach($output->data as $key => $val) |
|
2173 | + foreach ($output->data as $key => $val) |
|
2174 | 2174 | { |
2175 | 2175 | $document_srls[$val->module_srl][] = $val->document_srl; |
2176 | 2176 | } |
2177 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2177 | + if (!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2178 | 2178 | |
2179 | 2179 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
2180 | 2180 | $oModuleModel = getModel('module'); |
2181 | 2181 | $module_srls = array_keys($document_srls); |
2182 | - for($i=0;$i<count($module_srls);$i++) |
|
2182 | + for ($i = 0; $i < count($module_srls); $i++) |
|
2183 | 2183 | { |
2184 | 2184 | $module_srl = $module_srls[$i]; |
2185 | 2185 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
2186 | 2186 | $logged_info = Context::get('logged_info'); |
2187 | - if($logged_info->is_admin != 'Y') |
|
2187 | + if ($logged_info->is_admin != 'Y') |
|
2188 | 2188 | { |
2189 | - if(!$module_info) |
|
2189 | + if (!$module_info) |
|
2190 | 2190 | { |
2191 | 2191 | unset($document_srls[$module_srl]); |
2192 | 2192 | continue; |
2193 | 2193 | } |
2194 | 2194 | $grant = $oModuleModel->getGrant($module_info, $logged_info); |
2195 | - if(!$grant->manager) |
|
2195 | + if (!$grant->manager) |
|
2196 | 2196 | { |
2197 | 2197 | unset($document_srls[$module_srl]); |
2198 | 2198 | continue; |
2199 | 2199 | } |
2200 | 2200 | } |
2201 | 2201 | } |
2202 | - if(!count($document_srls)) return new BaseObject(); |
|
2202 | + if (!count($document_srls)) return new BaseObject(); |
|
2203 | 2203 | |
2204 | - foreach($document_srls as $module_srl => $documents) |
|
2204 | + foreach ($document_srls as $module_srl => $documents) |
|
2205 | 2205 | { |
2206 | 2206 | $cnt = count($documents); |
2207 | - for($i=0;$i<$cnt;$i++) |
|
2207 | + for ($i = 0; $i < $cnt; $i++) |
|
2208 | 2208 | { |
2209 | - $document_srl = (int)trim($documents[$i]); |
|
2210 | - if(!$document_srls) continue; |
|
2211 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2209 | + $document_srl = (int) trim($documents[$i]); |
|
2210 | + if (!$document_srls) continue; |
|
2211 | + if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2212 | 2212 | else $_SESSION['document_management'][$document_srl] = true; |
2213 | 2213 | } |
2214 | 2214 | } |
@@ -2221,9 +2221,9 @@ discard block |
||
2221 | 2221 | function procDocumentManageCheckedDocument() |
2222 | 2222 | { |
2223 | 2223 | @set_time_limit(0); |
2224 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2224 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2225 | 2225 | |
2226 | - if(!checkCSRF()) |
|
2226 | + if (!checkCSRF()) |
|
2227 | 2227 | { |
2228 | 2228 | return new BaseObject(-1, 'msg_invalid_request'); |
2229 | 2229 | } |
@@ -2231,44 +2231,44 @@ discard block |
||
2231 | 2231 | $type = Context::get('type'); |
2232 | 2232 | $target_module = Context::get('target_module'); |
2233 | 2233 | $module_srl = Context::get('module_srl'); |
2234 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
2234 | + if ($target_module && !$module_srl) $module_srl = $target_module; |
|
2235 | 2235 | $category_srl = Context::get('target_category'); |
2236 | 2236 | $message_content = Context::get('message_content'); |
2237 | - if($message_content) $message_content = nl2br($message_content); |
|
2237 | + if ($message_content) $message_content = nl2br($message_content); |
|
2238 | 2238 | |
2239 | 2239 | $cart = Context::get('cart'); |
2240 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
2240 | + if (!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
2241 | 2241 | else $document_srl_list = $cart; |
2242 | 2242 | |
2243 | 2243 | $document_srl_count = count($document_srl_list); |
2244 | 2244 | |
2245 | 2245 | $oDocumentModel = getModel('document'); |
2246 | 2246 | $document_items = array(); |
2247 | - foreach($document_srl_list as $document_srl) |
|
2247 | + foreach ($document_srl_list as $document_srl) |
|
2248 | 2248 | { |
2249 | 2249 | $oDocument = $oDocumentModel->getDocument($document_srl); |
2250 | 2250 | $document_items[] = $oDocument; |
2251 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2251 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2252 | 2252 | } |
2253 | 2253 | |
2254 | 2254 | // Send a message |
2255 | - if($message_content) |
|
2255 | + if ($message_content) |
|
2256 | 2256 | { |
2257 | 2257 | |
2258 | 2258 | $oCommunicationController = getController('communication'); |
2259 | 2259 | |
2260 | 2260 | $logged_info = Context::get('logged_info'); |
2261 | 2261 | |
2262 | - $title = cut_str($message_content,10,'...'); |
|
2262 | + $title = cut_str($message_content, 10, '...'); |
|
2263 | 2263 | $sender_member_srl = $logged_info->member_srl; |
2264 | 2264 | |
2265 | - foreach($document_items as $oDocument) |
|
2265 | + foreach ($document_items as $oDocument) |
|
2266 | 2266 | { |
2267 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
2267 | + if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue; |
|
2268 | 2268 | |
2269 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2269 | + if ($type == 'move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2270 | 2270 | else $purl = ""; |
2271 | - $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
2271 | + $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
2272 | 2272 | |
2273 | 2273 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
2274 | 2274 | } |
@@ -2278,54 +2278,54 @@ discard block |
||
2278 | 2278 | $oSpamController->setAvoidLog(); |
2279 | 2279 | |
2280 | 2280 | $oDocumentAdminController = getAdminController('document'); |
2281 | - if($type == 'move') |
|
2281 | + if ($type == 'move') |
|
2282 | 2282 | { |
2283 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2283 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2284 | 2284 | |
2285 | 2285 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
2286 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2286 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2287 | 2287 | |
2288 | 2288 | $msg_code = 'success_moved'; |
2289 | 2289 | |
2290 | 2290 | } |
2291 | - else if($type == 'copy') |
|
2291 | + else if ($type == 'copy') |
|
2292 | 2292 | { |
2293 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2293 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2294 | 2294 | |
2295 | 2295 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
2296 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2296 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2297 | 2297 | |
2298 | 2298 | $msg_code = 'success_copied'; |
2299 | 2299 | } |
2300 | - else if($type =='delete') |
|
2300 | + else if ($type == 'delete') |
|
2301 | 2301 | { |
2302 | 2302 | $oDB = &DB::getInstance(); |
2303 | 2303 | $oDB->begin(); |
2304 | - for($i=0;$i<$document_srl_count;$i++) |
|
2304 | + for ($i = 0; $i < $document_srl_count; $i++) |
|
2305 | 2305 | { |
2306 | 2306 | $document_srl = $document_srl_list[$i]; |
2307 | 2307 | $output = $this->deleteDocument($document_srl, true); |
2308 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2308 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2309 | 2309 | } |
2310 | 2310 | $oDB->commit(); |
2311 | 2311 | $msg_code = 'success_deleted'; |
2312 | 2312 | } |
2313 | - else if($type == 'trash') |
|
2313 | + else if ($type == 'trash') |
|
2314 | 2314 | { |
2315 | 2315 | $args = new stdClass(); |
2316 | 2316 | $args->description = $message_content; |
2317 | 2317 | |
2318 | 2318 | $oDB = &DB::getInstance(); |
2319 | 2319 | $oDB->begin(); |
2320 | - for($i=0;$i<$document_srl_count;$i++) { |
|
2320 | + for ($i = 0; $i < $document_srl_count; $i++) { |
|
2321 | 2321 | $args->document_srl = $document_srl_list[$i]; |
2322 | 2322 | $output = $this->moveDocumentToTrash($args); |
2323 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2323 | + if (!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2324 | 2324 | } |
2325 | 2325 | $oDB->commit(); |
2326 | 2326 | $msg_code = 'success_trashed'; |
2327 | 2327 | } |
2328 | - else if($type == 'cancelDeclare') |
|
2328 | + else if ($type == 'cancelDeclare') |
|
2329 | 2329 | { |
2330 | 2330 | $args->document_srl = $document_srl_list; |
2331 | 2331 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2347,27 +2347,27 @@ discard block |
||
2347 | 2347 | function procDocumentInsertModuleConfig() |
2348 | 2348 | { |
2349 | 2349 | $module_srl = Context::get('target_module_srl'); |
2350 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
2350 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
2351 | 2351 | else $module_srl = array($module_srl); |
2352 | 2352 | |
2353 | 2353 | $document_config = new stdClass(); |
2354 | 2354 | $document_config->use_history = Context::get('use_history'); |
2355 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
2355 | + if (!$document_config->use_history) $document_config->use_history = 'N'; |
|
2356 | 2356 | |
2357 | 2357 | $document_config->use_vote_up = Context::get('use_vote_up'); |
2358 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2358 | + if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2359 | 2359 | |
2360 | 2360 | $document_config->use_vote_down = Context::get('use_vote_down'); |
2361 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2361 | + if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2362 | 2362 | |
2363 | 2363 | $document_config->use_status = Context::get('use_status'); |
2364 | 2364 | |
2365 | 2365 | $oModuleController = getController('module'); |
2366 | - for($i=0;$i<count($module_srl);$i++) |
|
2366 | + for ($i = 0; $i < count($module_srl); $i++) |
|
2367 | 2367 | { |
2368 | 2368 | $srl = trim($module_srl[$i]); |
2369 | - if(!$srl) continue; |
|
2370 | - $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
|
2369 | + if (!$srl) continue; |
|
2370 | + $output = $oModuleController->insertModulePartConfig('document', $srl, $document_config); |
|
2371 | 2371 | } |
2372 | 2372 | $this->setError(-1); |
2373 | 2373 | $this->setMessage('success_updated', 'info'); |
@@ -2383,7 +2383,7 @@ discard block |
||
2383 | 2383 | function procDocumentTempSave() |
2384 | 2384 | { |
2385 | 2385 | // Check login information |
2386 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2386 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2387 | 2387 | $module_info = Context::get('module_info'); |
2388 | 2388 | $logged_info = Context::get('logged_info'); |
2389 | 2389 | |
@@ -2395,7 +2395,7 @@ discard block |
||
2395 | 2395 | unset($obj->is_notice); |
2396 | 2396 | |
2397 | 2397 | // Extract from beginning part of contents in the guestbook |
2398 | - if(!$obj->title) |
|
2398 | + if (!$obj->title) |
|
2399 | 2399 | { |
2400 | 2400 | $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
2401 | 2401 | } |
@@ -2406,13 +2406,13 @@ discard block |
||
2406 | 2406 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
2407 | 2407 | |
2408 | 2408 | // Update if already exists |
2409 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
2409 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
2410 | 2410 | { |
2411 | - if($oDocument->get('module_srl') != $obj->module_srl) |
|
2411 | + if ($oDocument->get('module_srl') != $obj->module_srl) |
|
2412 | 2412 | { |
2413 | 2413 | return new BaseObject(-1, 'msg_invalid_request'); |
2414 | 2414 | } |
2415 | - if(!$oDocument->isGranted()) |
|
2415 | + if (!$oDocument->isGranted()) |
|
2416 | 2416 | { |
2417 | 2417 | return new BaseObject(-1, 'msg_invalid_request'); |
2418 | 2418 | } |
@@ -2430,7 +2430,7 @@ discard block |
||
2430 | 2430 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
2431 | 2431 | } |
2432 | 2432 | // Set the attachment to be invalid state |
2433 | - if($oDocument->hasUploadedFiles()) |
|
2433 | + if ($oDocument->hasUploadedFiles()) |
|
2434 | 2434 | { |
2435 | 2435 | $args = new stdClass; |
2436 | 2436 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -2448,11 +2448,11 @@ discard block |
||
2448 | 2448 | */ |
2449 | 2449 | function procDocumentGetList() |
2450 | 2450 | { |
2451 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2451 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2452 | 2452 | $documentSrls = Context::get('document_srls'); |
2453 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2453 | + if ($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2454 | 2454 | |
2455 | - if(count($documentSrlList) > 0) |
|
2455 | + if (count($documentSrlList) > 0) |
|
2456 | 2456 | { |
2457 | 2457 | $oDocumentModel = getModel('document'); |
2458 | 2458 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
@@ -2476,10 +2476,10 @@ discard block |
||
2476 | 2476 | */ |
2477 | 2477 | function _checkCommentStatusForOldVersion(&$obj) |
2478 | 2478 | { |
2479 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2480 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2479 | + if (!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2480 | + if (!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2481 | 2481 | |
2482 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2482 | + if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2483 | 2483 | else $obj->commentStatus = 'DENY'; |
2484 | 2484 | } |
2485 | 2485 | |
@@ -2490,8 +2490,8 @@ discard block |
||
2490 | 2490 | */ |
2491 | 2491 | function _checkDocumentStatusForOldVersion(&$obj) |
2492 | 2492 | { |
2493 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2494 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2493 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2494 | + if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2495 | 2495 | } |
2496 | 2496 | |
2497 | 2497 | public function updateUploaedCount($documentSrlList) |
@@ -2499,10 +2499,10 @@ discard block |
||
2499 | 2499 | $oDocumentModel = getModel('document'); |
2500 | 2500 | $oFileModel = getModel('file'); |
2501 | 2501 | |
2502 | - if(is_array($documentSrlList)) |
|
2502 | + if (is_array($documentSrlList)) |
|
2503 | 2503 | { |
2504 | 2504 | $documentSrlList = array_unique($documentSrlList); |
2505 | - foreach($documentSrlList AS $key => $documentSrl) |
|
2505 | + foreach ($documentSrlList AS $key => $documentSrl) |
|
2506 | 2506 | { |
2507 | 2507 | $fileCount = $oFileModel->getFilesCount($documentSrl); |
2508 | 2508 | $args = new stdClass(); |
@@ -2523,14 +2523,14 @@ discard block |
||
2523 | 2523 | $oDocumentModel = getModel('document'); |
2524 | 2524 | $documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl); |
2525 | 2525 | |
2526 | - if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
2526 | + if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
2527 | 2527 | { |
2528 | - $oDocumentController=getController('document'); |
|
2529 | - foreach($obj->moduleSrlList AS $key=>$value) |
|
2528 | + $oDocumentController = getController('document'); |
|
2529 | + foreach ($obj->moduleSrlList AS $key=>$value) |
|
2530 | 2530 | { |
2531 | - foreach($documentExtraKeys AS $extraItem) |
|
2531 | + foreach ($documentExtraKeys AS $extraItem) |
|
2532 | 2532 | { |
2533 | - $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ; |
|
2533 | + $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid); |
|
2534 | 2534 | } |
2535 | 2535 | } |
2536 | 2536 | } |
@@ -2542,9 +2542,9 @@ discard block |
||
2542 | 2542 | $documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl); |
2543 | 2543 | |
2544 | 2544 | $oModuleController = getController('module'); |
2545 | - if(is_array($obj->moduleSrlList)) |
|
2545 | + if (is_array($obj->moduleSrlList)) |
|
2546 | 2546 | { |
2547 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
2547 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
2548 | 2548 | { |
2549 | 2549 | $oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig); |
2550 | 2550 | } |
@@ -24,19 +24,27 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function procDocumentVoteUp() |
26 | 26 | { |
27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
27 | + if(!Context::get('is_logged')) { |
|
28 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | $document_srl = Context::get('target_srl'); |
30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
32 | + if(!$document_srl) { |
|
33 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $oDocumentModel = getModel('document'); |
33 | 37 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
34 | 38 | $module_srl = $oDocument->get('module_srl'); |
35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
39 | + if(!$module_srl) { |
|
40 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
41 | + } |
|
36 | 42 | |
37 | 43 | $oModuleModel = getModel('module'); |
38 | 44 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
45 | + if($document_config->use_vote_up=='N') { |
|
46 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
47 | + } |
|
40 | 48 | |
41 | 49 | $point = 1; |
42 | 50 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +77,27 @@ discard block |
||
69 | 77 | */ |
70 | 78 | function procDocumentVoteDown() |
71 | 79 | { |
72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
80 | + if(!Context::get('is_logged')) { |
|
81 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
82 | + } |
|
73 | 83 | |
74 | 84 | $document_srl = Context::get('target_srl'); |
75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
85 | + if(!$document_srl) { |
|
86 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
87 | + } |
|
76 | 88 | |
77 | 89 | $oDocumentModel = getModel('document'); |
78 | 90 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
79 | 91 | $module_srl = $oDocument->get('module_srl'); |
80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
92 | + if(!$module_srl) { |
|
93 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
94 | + } |
|
81 | 95 | |
82 | 96 | $oModuleModel = getModel('module'); |
83 | 97 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
98 | + if($document_config->use_vote_down=='N') { |
|
99 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
100 | + } |
|
85 | 101 | |
86 | 102 | $point = -1; |
87 | 103 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +111,14 @@ discard block |
||
95 | 111 | */ |
96 | 112 | function procDocumentDeclare() |
97 | 113 | { |
98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
114 | + if(!Context::get('is_logged')) { |
|
115 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
116 | + } |
|
99 | 117 | |
100 | 118 | $document_srl = Context::get('target_srl'); |
101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
119 | + if(!$document_srl) { |
|
120 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
121 | + } |
|
102 | 122 | |
103 | 123 | return $this->declaredDocument($document_srl); |
104 | 124 | } |
@@ -140,7 +160,9 @@ discard block |
||
140 | 160 | $args->history_srl = $history_srl; |
141 | 161 | $args->module_srl = $module_srl; |
142 | 162 | $args->document_srl = $document_srl; |
143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
163 | + if(!$args->history_srl && !$args->module_srl && !$args->document_srl) { |
|
164 | + return; |
|
165 | + } |
|
144 | 166 | executeQuery("document.deleteHistory", $args); |
145 | 167 | } |
146 | 168 | |
@@ -152,15 +174,21 @@ discard block |
||
152 | 174 | function triggerDeleteModuleDocuments(&$obj) |
153 | 175 | { |
154 | 176 | $module_srl = $obj->module_srl; |
155 | - if(!$module_srl) return new BaseObject(); |
|
177 | + if(!$module_srl) { |
|
178 | + return new BaseObject(); |
|
179 | + } |
|
156 | 180 | // Delete the document |
157 | 181 | $oDocumentAdminController = getAdminController('document'); |
158 | 182 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
159 | - if(!$output->toBool()) return $output; |
|
183 | + if(!$output->toBool()) { |
|
184 | + return $output; |
|
185 | + } |
|
160 | 186 | // Delete the category |
161 | 187 | $oDocumentController = getController('document'); |
162 | 188 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
163 | - if(!$output->toBool()) return $output; |
|
189 | + if(!$output->toBool()) { |
|
190 | + return $output; |
|
191 | + } |
|
164 | 192 | // Delete extra key and variable, because module deleted |
165 | 193 | $this->deleteDocumentExtraKeys($module_srl); |
166 | 194 | |
@@ -202,10 +230,18 @@ discard block |
||
202 | 230 | $oDB = &DB::getInstance(); |
203 | 231 | $oDB->begin(); |
204 | 232 | // List variables |
205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
233 | + if($obj->comment_status) { |
|
234 | + $obj->commentStatus = $obj->comment_status; |
|
235 | + } |
|
236 | + if(!$obj->commentStatus) { |
|
237 | + $obj->commentStatus = 'DENY'; |
|
238 | + } |
|
239 | + if($obj->commentStatus == 'DENY') { |
|
240 | + $this->_checkCommentStatusForOldVersion($obj); |
|
241 | + } |
|
242 | + if($obj->allow_trackback!='Y') { |
|
243 | + $obj->allow_trackback = 'N'; |
|
244 | + } |
|
209 | 245 | if($obj->homepage) |
210 | 246 | { |
211 | 247 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -215,9 +251,15 @@ discard block |
||
215 | 251 | } |
216 | 252 | } |
217 | 253 | |
218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
254 | + if($obj->notify_message != 'Y') { |
|
255 | + $obj->notify_message = 'N'; |
|
256 | + } |
|
257 | + if(!$obj->email_address) { |
|
258 | + $obj->email_address = ''; |
|
259 | + } |
|
260 | + if(!$isRestore) { |
|
261 | + $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
262 | + } |
|
221 | 263 | |
222 | 264 | // can modify regdate only manager |
223 | 265 | $grant = Context::get('grant'); |
@@ -227,7 +269,9 @@ discard block |
||
227 | 269 | } |
228 | 270 | |
229 | 271 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
272 | + if(!is_string($obj->extra_vars)) { |
|
273 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
274 | + } |
|
231 | 275 | // Remove the columns for automatic saving |
232 | 276 | unset($obj->_saved_doc_srl); |
233 | 277 | unset($obj->_saved_doc_title); |
@@ -235,10 +279,15 @@ discard block |
||
235 | 279 | unset($obj->_saved_doc_message); |
236 | 280 | // Call a trigger (before) |
237 | 281 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
238 | - if(!$output->toBool()) return $output; |
|
282 | + if(!$output->toBool()) { |
|
283 | + return $output; |
|
284 | + } |
|
239 | 285 | // Register it if no given document_srl exists |
240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
286 | + if(!$obj->document_srl) { |
|
287 | + $obj->document_srl = getNextSequence(); |
|
288 | + } elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) { |
|
289 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
290 | + } |
|
242 | 291 | |
243 | 292 | $oDocumentModel = getModel('document'); |
244 | 293 | // Set to 0 if the category_srl doesn't exist |
@@ -249,12 +298,19 @@ discard block |
||
249 | 298 | { |
250 | 299 | return new BaseObject(-1, 'msg_not_permitted'); |
251 | 300 | } |
252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
301 | + if(count($category_list) > 0 && !$category_list[$obj->category_srl]) { |
|
302 | + $obj->category_srl = 0; |
|
303 | + } |
|
253 | 304 | } |
254 | 305 | // Set the read counts and update order. |
255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
257 | - else $obj->update_order = $obj->list_order; |
|
306 | + if(!$obj->readed_count) { |
|
307 | + $obj->readed_count = 0; |
|
308 | + } |
|
309 | + if($isLatest) { |
|
310 | + $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
311 | + } else { |
|
312 | + $obj->update_order = $obj->list_order; |
|
313 | + } |
|
258 | 314 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
259 | 315 | if($obj->password && !$obj->password_is_hashed) |
260 | 316 | { |
@@ -276,9 +332,13 @@ discard block |
||
276 | 332 | // If the tile is empty, extract string from the contents. |
277 | 333 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
278 | 334 | settype($obj->title, "string"); |
279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
335 | + if($obj->title == '') { |
|
336 | + $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
337 | + } |
|
280 | 338 | // If no tile extracted from the contents, leave it untitled. |
281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
339 | + if($obj->title == '') { |
|
340 | + $obj->title = 'Untitled'; |
|
341 | + } |
|
282 | 342 | // Remove XE's own tags from the contents. |
283 | 343 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
284 | 344 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -290,13 +350,19 @@ discard block |
||
290 | 350 | $obj->content = nl2br($obj->content); |
291 | 351 | } |
292 | 352 | // Remove iframe and script if not a top adminisrator in the session. |
293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
353 | + if($logged_info->is_admin != 'Y') { |
|
354 | + $obj->content = removeHackTag($obj->content); |
|
355 | + } |
|
294 | 356 | // An error appears if both log-in info and user name don't exist. |
295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
357 | + if(!$logged_info->member_srl && !$obj->nick_name) { |
|
358 | + return new BaseObject(-1,'msg_invalid_request'); |
|
359 | + } |
|
296 | 360 | |
297 | 361 | $obj->lang_code = Context::getLangType(); |
298 | 362 | // Insert data into the DB |
299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
363 | + if(!$obj->status) { |
|
364 | + $this->_checkDocumentStatusForOldVersion($obj); |
|
365 | + } |
|
300 | 366 | $output = executeQuery('document.insertDocument', $obj); |
301 | 367 | if(!$output->toBool()) |
302 | 368 | { |
@@ -313,19 +379,25 @@ discard block |
||
313 | 379 | if(isset($obj->{'extra_vars'.$idx})) |
314 | 380 | { |
315 | 381 | $tmp = $obj->{'extra_vars'.$idx}; |
316 | - if(is_array($tmp)) |
|
317 | - $value = implode('|@|', $tmp); |
|
318 | - else |
|
319 | - $value = trim($tmp); |
|
382 | + if(is_array($tmp)) { |
|
383 | + $value = implode('|@|', $tmp); |
|
384 | + } else { |
|
385 | + $value = trim($tmp); |
|
386 | + } |
|
387 | + } else if(isset($obj->{$extra_item->name})) { |
|
388 | + $value = trim($obj->{$extra_item->name}); |
|
389 | + } |
|
390 | + if($value == NULL) { |
|
391 | + continue; |
|
320 | 392 | } |
321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | - if($value == NULL) continue; |
|
323 | 393 | |
324 | 394 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
325 | 395 | } |
326 | 396 | } |
327 | 397 | // Update the category if the category_srl exists. |
328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
398 | + if($obj->category_srl) { |
|
399 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
400 | + } |
|
329 | 401 | // Call a trigger (after) |
330 | 402 | if($output->toBool()) |
331 | 403 | { |
@@ -367,27 +439,39 @@ discard block |
||
367 | 439 | return new BaseObject(-1, 'msg_invalid_request'); |
368 | 440 | } |
369 | 441 | |
370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
442 | + if(!$source_obj->document_srl || !$obj->document_srl) { |
|
443 | + return new BaseObject(-1,'msg_invalied_request'); |
|
444 | + } |
|
445 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
446 | + $obj->status = 'SECRET'; |
|
447 | + } |
|
448 | + if(!$obj->status) { |
|
449 | + $obj->status = 'PUBLIC'; |
|
450 | + } |
|
373 | 451 | |
374 | 452 | // Call a trigger (before) |
375 | 453 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
376 | - if(!$output->toBool()) return $output; |
|
454 | + if(!$output->toBool()) { |
|
455 | + return $output; |
|
456 | + } |
|
377 | 457 | |
378 | 458 | // begin transaction |
379 | 459 | $oDB = &DB::getInstance(); |
380 | 460 | $oDB->begin(); |
381 | 461 | |
382 | 462 | $oModuleModel = getModel('module'); |
383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
463 | + if(!$obj->module_srl) { |
|
464 | + $obj->module_srl = $source_obj->get('module_srl'); |
|
465 | + } |
|
384 | 466 | $module_srl = $obj->module_srl; |
385 | 467 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
386 | 468 | if(!$document_config) |
387 | 469 | { |
388 | 470 | $document_config = new stdClass(); |
389 | 471 | } |
390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
472 | + if(!isset($document_config->use_history)) { |
|
473 | + $document_config->use_history = 'N'; |
|
474 | + } |
|
391 | 475 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
392 | 476 | |
393 | 477 | if($bUseHistory) |
@@ -396,22 +480,31 @@ discard block |
||
396 | 480 | $args->history_srl = getNextSequence(); |
397 | 481 | $args->document_srl = $obj->document_srl; |
398 | 482 | $args->module_srl = $module_srl; |
399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
483 | + if($document_config->use_history == 'Y') { |
|
484 | + $args->content = $source_obj->get('content'); |
|
485 | + } |
|
400 | 486 | $args->nick_name = $logged_info->nick_name; |
401 | 487 | $args->member_srl = $logged_info->member_srl; |
402 | 488 | $args->regdate = $source_obj->get('last_update'); |
403 | 489 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
404 | 490 | $output = executeQuery("document.insertHistory", $args); |
405 | - } |
|
406 | - else |
|
491 | + } else |
|
407 | 492 | { |
408 | 493 | $obj->ipaddress = $source_obj->get('ipaddress'); |
409 | 494 | } |
410 | 495 | // List variables |
411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
496 | + if($obj->comment_status) { |
|
497 | + $obj->commentStatus = $obj->comment_status; |
|
498 | + } |
|
499 | + if(!$obj->commentStatus) { |
|
500 | + $obj->commentStatus = 'DENY'; |
|
501 | + } |
|
502 | + if($obj->commentStatus == 'DENY') { |
|
503 | + $this->_checkCommentStatusForOldVersion($obj); |
|
504 | + } |
|
505 | + if($obj->allow_trackback!='Y') { |
|
506 | + $obj->allow_trackback = 'N'; |
|
507 | + } |
|
415 | 508 | if($obj->homepage) |
416 | 509 | { |
417 | 510 | $obj->homepage = removeHackTag($obj->homepage); |
@@ -421,7 +514,9 @@ discard block |
||
421 | 514 | } |
422 | 515 | } |
423 | 516 | |
424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
517 | + if($obj->notify_message != 'Y') { |
|
518 | + $obj->notify_message = 'N'; |
|
519 | + } |
|
425 | 520 | |
426 | 521 | // can modify regdate only manager |
427 | 522 | $grant = Context::get('grant'); |
@@ -431,7 +526,9 @@ discard block |
||
431 | 526 | } |
432 | 527 | |
433 | 528 | // Serialize the $extra_vars |
434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
529 | + if(!is_string($obj->extra_vars)) { |
|
530 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
531 | + } |
|
435 | 532 | // Remove the columns for automatic saving |
436 | 533 | unset($obj->_saved_doc_srl); |
437 | 534 | unset($obj->_saved_doc_title); |
@@ -443,7 +540,9 @@ discard block |
||
443 | 540 | if($source_obj->get('category_srl')!=$obj->category_srl) |
444 | 541 | { |
445 | 542 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
543 | + if(!$category_list[$obj->category_srl]) { |
|
544 | + $obj->category_srl = 0; |
|
545 | + } |
|
447 | 546 | } |
448 | 547 | // Change the update order |
449 | 548 | $obj->update_order = getNextSequence() * -1; |
@@ -478,9 +577,13 @@ discard block |
||
478 | 577 | // If the tile is empty, extract string from the contents. |
479 | 578 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
480 | 579 | settype($obj->title, "string"); |
481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
580 | + if($obj->title == '') { |
|
581 | + $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
582 | + } |
|
482 | 583 | // If no tile extracted from the contents, leave it untitled. |
483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
584 | + if($obj->title == '') { |
|
585 | + $obj->title = 'Untitled'; |
|
586 | + } |
|
484 | 587 | // Remove XE's own tags from the contents. |
485 | 588 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
486 | 589 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -500,8 +603,7 @@ discard block |
||
500 | 603 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
501 | 604 | $lang_code_args->lang_code = Context::getLangType(); |
502 | 605 | $output = executeQuery('document.updateDocumentsLangCode', $lang_code_args); |
503 | - } |
|
504 | - else |
|
606 | + } else |
|
505 | 607 | { |
506 | 608 | $extra_content = new stdClass; |
507 | 609 | $extra_content->title = $obj->title; |
@@ -520,7 +622,9 @@ discard block |
||
520 | 622 | $obj->content = removeHackTag($obj->content); |
521 | 623 | } |
522 | 624 | // if temporary document, regdate is now setting |
523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
625 | + if($source_obj->get('status') == $this->getConfigStatus('temp')) { |
|
626 | + $obj->regdate = date('YmdHis'); |
|
627 | + } |
|
524 | 628 | |
525 | 629 | // Insert data into the DB |
526 | 630 | $output = executeQuery('document.updateDocument', $obj); |
@@ -543,25 +647,37 @@ discard block |
||
543 | 647 | if(isset($obj->{'extra_vars'.$idx})) |
544 | 648 | { |
545 | 649 | $tmp = $obj->{'extra_vars'.$idx}; |
546 | - if(is_array($tmp)) |
|
547 | - $value = implode('|@|', $tmp); |
|
548 | - else |
|
549 | - $value = trim($tmp); |
|
650 | + if(is_array($tmp)) { |
|
651 | + $value = implode('|@|', $tmp); |
|
652 | + } else { |
|
653 | + $value = trim($tmp); |
|
654 | + } |
|
655 | + } else if(isset($obj->{$extra_item->name})) { |
|
656 | + $value = trim($obj->{$extra_item->name}); |
|
657 | + } |
|
658 | + if($value == NULL) { |
|
659 | + continue; |
|
550 | 660 | } |
551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | - if($value == NULL) continue; |
|
553 | 661 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
554 | 662 | } |
555 | 663 | } |
556 | 664 | // Inert extra vars for multi-language support of title and contents. |
557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
665 | + if($extra_content->title) { |
|
666 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
667 | + } |
|
668 | + if($extra_content->content) { |
|
669 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
670 | + } |
|
559 | 671 | } |
560 | 672 | // Update the category if the category_srl exists. |
561 | 673 | if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
562 | 674 | { |
563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
675 | + if($source_obj->get('category_srl') != $obj->category_srl) { |
|
676 | + $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
677 | + } |
|
678 | + if($obj->category_srl) { |
|
679 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
680 | + } |
|
565 | 681 | } |
566 | 682 | // Call a trigger (after) |
567 | 683 | if($output->toBool()) |
@@ -606,7 +722,9 @@ discard block |
||
606 | 722 | $trigger_obj = new stdClass(); |
607 | 723 | $trigger_obj->document_srl = $document_srl; |
608 | 724 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
609 | - if(!$output->toBool()) return $output; |
|
725 | + if(!$output->toBool()) { |
|
726 | + return $output; |
|
727 | + } |
|
610 | 728 | |
611 | 729 | // begin transaction |
612 | 730 | $oDB = &DB::getInstance(); |
@@ -618,12 +736,17 @@ discard block |
||
618 | 736 | $oDocumentModel = getModel('document'); |
619 | 737 | // Check if the documnet exists |
620 | 738 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
739 | + } else if($isEmptyTrash && $oDocument == null) { |
|
740 | + return new BaseObject(-1, 'document is not exists'); |
|
621 | 741 | } |
622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
623 | 742 | |
624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
743 | + if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) { |
|
744 | + return new BaseObject(-1, 'msg_invalid_document'); |
|
745 | + } |
|
625 | 746 | // Check if a permossion is granted |
626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
747 | + if(!$oDocument->isGranted()) { |
|
748 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
749 | + } |
|
627 | 750 | |
628 | 751 | //if empty trash, document already deleted, therefore document not delete |
629 | 752 | $args = new stdClass(); |
@@ -643,7 +766,9 @@ discard block |
||
643 | 766 | |
644 | 767 | $this->deleteDocumentHistory(null, $document_srl, null); |
645 | 768 | // Update category information if the category_srl exists. |
646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
769 | + if($oDocument->get('category_srl')) { |
|
770 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
771 | + } |
|
647 | 772 | // Delete a declared list |
648 | 773 | executeQuery('document.deleteDeclared', $args); |
649 | 774 | // Delete extra variable |
@@ -723,8 +848,11 @@ discard block |
||
723 | 848 | { |
724 | 849 | $trash_args = new stdClass(); |
725 | 850 | // Get trash_srl if a given trash_srl doesn't exist |
726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
727 | - else $trash_args->trash_srl = $obj->trash_srl; |
|
851 | + if(!$obj->trash_srl) { |
|
852 | + $trash_args->trash_srl = getNextSequence(); |
|
853 | + } else { |
|
854 | + $trash_args->trash_srl = $obj->trash_srl; |
|
855 | + } |
|
728 | 856 | // Get its module_srl which the document belongs to |
729 | 857 | $oDocumentModel = getModel('document'); |
730 | 858 | $oDocument = $oDocumentModel->getDocument($obj->document_srl); |
@@ -732,7 +860,9 @@ discard block |
||
732 | 860 | $trash_args->module_srl = $oDocument->get('module_srl'); |
733 | 861 | $obj->module_srl = $oDocument->get('module_srl'); |
734 | 862 | // Cannot throw data from the trash to the trash |
735 | - if($trash_args->module_srl == 0) return false; |
|
863 | + if($trash_args->module_srl == 0) { |
|
864 | + return false; |
|
865 | + } |
|
736 | 866 | // Data setting |
737 | 867 | $trash_args->document_srl = $obj->document_srl; |
738 | 868 | $trash_args->description = $obj->description; |
@@ -793,7 +923,9 @@ discard block |
||
793 | 923 | }*/ |
794 | 924 | |
795 | 925 | // update category |
796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
926 | + if($oDocument->get('category_srl')) { |
|
927 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
928 | + } |
|
797 | 929 | |
798 | 930 | // remove thumbnails |
799 | 931 | FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
@@ -838,7 +970,9 @@ discard block |
||
838 | 970 | function updateReadedCount(&$oDocument) |
839 | 971 | { |
840 | 972 | // Pass if Crawler access |
841 | - if(isCrawler()) return false; |
|
973 | + if(isCrawler()) { |
|
974 | + return false; |
|
975 | + } |
|
842 | 976 | |
843 | 977 | $document_srl = $oDocument->document_srl; |
844 | 978 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,10 +980,14 @@ discard block |
||
846 | 980 | |
847 | 981 | // Call a trigger when the read count is updated (before) |
848 | 982 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
983 | + if(!$trigger_output->toBool()) { |
|
984 | + return $trigger_output; |
|
985 | + } |
|
850 | 986 | |
851 | 987 | // Pass if read count is increaded on the session information |
852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
988 | + if($_SESSION['readed_document'][$document_srl]) { |
|
989 | + return false; |
|
990 | + } |
|
853 | 991 | |
854 | 992 | // Pass if the author's IP address is as same as visitor's. |
855 | 993 | if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
@@ -914,7 +1052,9 @@ discard block |
||
914 | 1052 | */ |
915 | 1053 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
916 | 1054 | { |
917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
1055 | + if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) { |
|
1056 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1057 | + } |
|
918 | 1058 | |
919 | 1059 | $obj = new stdClass(); |
920 | 1060 | $obj->module_srl = $module_srl; |
@@ -931,8 +1071,7 @@ discard block |
||
931 | 1071 | if(!$output->data) |
932 | 1072 | { |
933 | 1073 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
934 | - } |
|
935 | - else |
|
1074 | + } else |
|
936 | 1075 | { |
937 | 1076 | $output = executeQuery('document.updateDocumentExtraKey', $obj); |
938 | 1077 | // Update the extra var(eid) |
@@ -958,10 +1097,14 @@ discard block |
||
958 | 1097 | */ |
959 | 1098 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
960 | 1099 | { |
961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
1100 | + if(!$module_srl) { |
|
1101 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1102 | + } |
|
962 | 1103 | $obj = new stdClass(); |
963 | 1104 | $obj->module_srl = $module_srl; |
964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1105 | + if(!is_null($var_idx)) { |
|
1106 | + $obj->var_idx = $var_idx; |
|
1107 | + } |
|
965 | 1108 | |
966 | 1109 | $oDB = DB::getInstance(); |
967 | 1110 | $oDB->begin(); |
@@ -1025,8 +1168,12 @@ discard block |
||
1025 | 1168 | */ |
1026 | 1169 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
1027 | 1170 | { |
1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
1171 | + if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) { |
|
1172 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1173 | + } |
|
1174 | + if(!$lang_code) { |
|
1175 | + $lang_code = Context::getLangType(); |
|
1176 | + } |
|
1030 | 1177 | |
1031 | 1178 | $obj = new stdClass; |
1032 | 1179 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1199,18 @@ discard block |
||
1052 | 1199 | { |
1053 | 1200 | $obj = new stdClass(); |
1054 | 1201 | $obj->module_srl = $module_srl; |
1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
1202 | + if(!is_null($document_srl)) { |
|
1203 | + $obj->document_srl = $document_srl; |
|
1204 | + } |
|
1205 | + if(!is_null($var_idx)) { |
|
1206 | + $obj->var_idx = $var_idx; |
|
1207 | + } |
|
1208 | + if(!is_null($lang_code)) { |
|
1209 | + $obj->lang_code = $lang_code; |
|
1210 | + } |
|
1211 | + if(!is_null($eid)) { |
|
1212 | + $obj->eid = $eid; |
|
1213 | + } |
|
1059 | 1214 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
1060 | 1215 | return $output; |
1061 | 1216 | } |
@@ -1069,8 +1224,11 @@ discard block |
||
1069 | 1224 | */ |
1070 | 1225 | function updateVotedCount($document_srl, $point = 1) |
1071 | 1226 | { |
1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
1073 | - else $failed_voted = 'failed_blamed'; |
|
1227 | + if($point > 0) { |
|
1228 | + $failed_voted = 'failed_voted'; |
|
1229 | + } else { |
|
1230 | + $failed_voted = 'failed_blamed'; |
|
1231 | + } |
|
1074 | 1232 | // Return fail if session already has information about votes |
1075 | 1233 | if($_SESSION['voted_document'][$document_srl]) |
1076 | 1234 | { |
@@ -1106,8 +1264,7 @@ discard block |
||
1106 | 1264 | if($member_srl) |
1107 | 1265 | { |
1108 | 1266 | $args->member_srl = $member_srl; |
1109 | - } |
|
1110 | - else |
|
1267 | + } else |
|
1111 | 1268 | { |
1112 | 1269 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
1113 | 1270 | } |
@@ -1129,17 +1286,20 @@ discard block |
||
1129 | 1286 | { |
1130 | 1287 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
1131 | 1288 | $output = executeQuery('document.updateBlamedCount', $args); |
1132 | - } |
|
1133 | - else |
|
1289 | + } else |
|
1134 | 1290 | { |
1135 | 1291 | $args->voted_count = $oDocument->get('voted_count') + $point; |
1136 | 1292 | $output = executeQuery('document.updateVotedCount', $args); |
1137 | 1293 | } |
1138 | - if(!$output->toBool()) return $output; |
|
1294 | + if(!$output->toBool()) { |
|
1295 | + return $output; |
|
1296 | + } |
|
1139 | 1297 | // Leave logs |
1140 | 1298 | $args->point = $point; |
1141 | 1299 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
1142 | - if(!$output->toBool()) return $output; |
|
1300 | + if(!$output->toBool()) { |
|
1301 | + return $output; |
|
1302 | + } |
|
1143 | 1303 | |
1144 | 1304 | $obj = new stdClass; |
1145 | 1305 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1175,8 +1335,7 @@ discard block |
||
1175 | 1335 | { |
1176 | 1336 | $output->setMessage('success_voted'); |
1177 | 1337 | $output->add('voted_count', $obj->after_point); |
1178 | - } |
|
1179 | - else |
|
1338 | + } else |
|
1180 | 1339 | { |
1181 | 1340 | $output->setMessage('success_blamed'); |
1182 | 1341 | $output->add('blamed_count', $obj->after_point); |
@@ -1193,13 +1352,17 @@ discard block |
||
1193 | 1352 | function declaredDocument($document_srl) |
1194 | 1353 | { |
1195 | 1354 | // Fail if session information already has a reported document |
1196 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1355 | + if($_SESSION['declared_document'][$document_srl]) { |
|
1356 | + return new BaseObject(-1, 'failed_declared'); |
|
1357 | + } |
|
1197 | 1358 | |
1198 | 1359 | // Check if previously reported |
1199 | 1360 | $args = new stdClass(); |
1200 | 1361 | $args->document_srl = $document_srl; |
1201 | 1362 | $output = executeQuery('document.getDeclaredDocument', $args); |
1202 | - if(!$output->toBool()) return $output; |
|
1363 | + if(!$output->toBool()) { |
|
1364 | + return $output; |
|
1365 | + } |
|
1203 | 1366 | |
1204 | 1367 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
1205 | 1368 | |
@@ -1243,8 +1406,7 @@ discard block |
||
1243 | 1406 | if($member_srl) |
1244 | 1407 | { |
1245 | 1408 | $args->member_srl = $member_srl; |
1246 | - } |
|
1247 | - else |
|
1409 | + } else |
|
1248 | 1410 | { |
1249 | 1411 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
1250 | 1412 | } |
@@ -1264,9 +1426,14 @@ discard block |
||
1264 | 1426 | $oDB->begin(); |
1265 | 1427 | |
1266 | 1428 | // Add the declared document |
1267 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1268 | - else $output = executeQuery('document.insertDeclaredDocument', $args); |
|
1269 | - if(!$output->toBool()) return $output; |
|
1429 | + if($declared_count > 0) { |
|
1430 | + $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1431 | + } else { |
|
1432 | + $output = executeQuery('document.insertDeclaredDocument', $args); |
|
1433 | + } |
|
1434 | + if(!$output->toBool()) { |
|
1435 | + return $output; |
|
1436 | + } |
|
1270 | 1437 | // Leave logs |
1271 | 1438 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
1272 | 1439 | if(!$output->toBool()) |
@@ -1365,9 +1532,10 @@ discard block |
||
1365 | 1532 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
1366 | 1533 | $obj->list_order = $parent_category->list_order; |
1367 | 1534 | $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
1368 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1369 | - } |
|
1370 | - else |
|
1535 | + if(!$obj->category_srl) { |
|
1536 | + $obj->category_srl = getNextSequence(); |
|
1537 | + } |
|
1538 | + } else |
|
1371 | 1539 | { |
1372 | 1540 | $obj->list_order = $obj->category_srl = getNextSequence(); |
1373 | 1541 | } |
@@ -1407,13 +1575,17 @@ discard block |
||
1407 | 1575 | { |
1408 | 1576 | // Create a document model object |
1409 | 1577 | $oDocumentModel = getModel('document'); |
1410 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1578 | + if(!$document_count) { |
|
1579 | + $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1580 | + } |
|
1411 | 1581 | |
1412 | 1582 | $args = new stdClass; |
1413 | 1583 | $args->category_srl = $category_srl; |
1414 | 1584 | $args->document_count = $document_count; |
1415 | 1585 | $output = executeQuery('document.updateCategoryCount', $args); |
1416 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1586 | + if($output->toBool()) { |
|
1587 | + $this->makeCategoryFile($module_srl); |
|
1588 | + } |
|
1417 | 1589 | |
1418 | 1590 | return $output; |
1419 | 1591 | } |
@@ -1426,7 +1598,9 @@ discard block |
||
1426 | 1598 | function updateCategory($obj) |
1427 | 1599 | { |
1428 | 1600 | $output = executeQuery('document.updateCategory', $obj); |
1429 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1601 | + if($output->toBool()) { |
|
1602 | + $this->makeCategoryFile($obj->module_srl); |
|
1603 | + } |
|
1430 | 1604 | return $output; |
1431 | 1605 | } |
1432 | 1606 | |
@@ -1443,11 +1617,17 @@ discard block |
||
1443 | 1617 | $category_info = $oDocumentModel->getCategory($category_srl); |
1444 | 1618 | // Display an error that the category cannot be deleted if it has a child |
1445 | 1619 | $output = executeQuery('document.getChildCategoryCount', $args); |
1446 | - if(!$output->toBool()) return $output; |
|
1447 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1620 | + if(!$output->toBool()) { |
|
1621 | + return $output; |
|
1622 | + } |
|
1623 | + if($output->data->count>0) { |
|
1624 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1625 | + } |
|
1448 | 1626 | // Delete a category information |
1449 | 1627 | $output = executeQuery('document.deleteCategory', $args); |
1450 | - if(!$output->toBool()) return $output; |
|
1628 | + if(!$output->toBool()) { |
|
1629 | + return $output; |
|
1630 | + } |
|
1451 | 1631 | |
1452 | 1632 | $this->makeCategoryFile($category_info->module_srl); |
1453 | 1633 | // remvove cache |
@@ -1462,8 +1642,9 @@ discard block |
||
1462 | 1642 | $args->page = ++$page; |
1463 | 1643 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
1464 | 1644 | |
1465 | - if($output->data == array()) |
|
1466 | - break; |
|
1645 | + if($output->data == array()) { |
|
1646 | + break; |
|
1647 | + } |
|
1467 | 1648 | |
1468 | 1649 | foreach($output->data as $val) |
1469 | 1650 | { |
@@ -1515,18 +1696,26 @@ discard block |
||
1515 | 1696 | // Seek a full list of categories |
1516 | 1697 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1517 | 1698 | $category_srl_list = array_keys($category_list); |
1518 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1699 | + if(count($category_srl_list)<2) { |
|
1700 | + return new BaseObject(); |
|
1701 | + } |
|
1519 | 1702 | |
1520 | 1703 | $prev_category = NULL; |
1521 | 1704 | foreach($category_list as $key => $val) |
1522 | 1705 | { |
1523 | - if($key==$category_srl) break; |
|
1706 | + if($key==$category_srl) { |
|
1707 | + break; |
|
1708 | + } |
|
1524 | 1709 | $prev_category = $val; |
1525 | 1710 | } |
1526 | 1711 | // Return if the previous category doesn't exist |
1527 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1712 | + if(!$prev_category) { |
|
1713 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1714 | + } |
|
1528 | 1715 | // Return if the selected category is the top level |
1529 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1716 | + if($category_srl_list[0]==$category_srl) { |
|
1717 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1718 | + } |
|
1530 | 1719 | // Information of the selected category |
1531 | 1720 | $cur_args = new stdClass; |
1532 | 1721 | $cur_args->category_srl = $category_srl; |
@@ -1562,15 +1751,21 @@ discard block |
||
1562 | 1751 | // Seek a full list of categories |
1563 | 1752 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1564 | 1753 | $category_srl_list = array_keys($category_list); |
1565 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1754 | + if(count($category_srl_list)<2) { |
|
1755 | + return new BaseObject(); |
|
1756 | + } |
|
1566 | 1757 | |
1567 | 1758 | for($i=0;$i<count($category_srl_list);$i++) |
1568 | 1759 | { |
1569 | - if($category_srl_list[$i]==$category_srl) break; |
|
1760 | + if($category_srl_list[$i]==$category_srl) { |
|
1761 | + break; |
|
1762 | + } |
|
1570 | 1763 | } |
1571 | 1764 | |
1572 | 1765 | $next_category_srl = $category_srl_list[$i+1]; |
1573 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1766 | + if(!$category_list[$next_category_srl]) { |
|
1767 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1768 | + } |
|
1574 | 1769 | $next_category = $category_list[$next_category_srl]; |
1575 | 1770 | // Information of the selected category |
1576 | 1771 | $cur_args = new stdClass; |
@@ -1597,7 +1792,9 @@ discard block |
||
1597 | 1792 | { |
1598 | 1793 | $oDocumentModel = getModel('document'); |
1599 | 1794 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
1600 | - if(!count($extra_keys)) return; |
|
1795 | + if(!count($extra_keys)) { |
|
1796 | + return; |
|
1797 | + } |
|
1601 | 1798 | |
1602 | 1799 | $js_code = array(); |
1603 | 1800 | $js_code[] = '<script>//<![CDATA['; |
@@ -1616,7 +1813,9 @@ discard block |
||
1616 | 1813 | } |
1617 | 1814 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
1618 | 1815 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
1619 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1816 | + if($val->is_required == 'Y') { |
|
1817 | + $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1818 | + } |
|
1620 | 1819 | } |
1621 | 1820 | |
1622 | 1821 | $js_code[] = '})(jQuery);'; |
@@ -1634,7 +1833,9 @@ discard block |
||
1634 | 1833 | function procDocumentInsertCategory($args = null) |
1635 | 1834 | { |
1636 | 1835 | // List variables |
1637 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1836 | + if(!$args) { |
|
1837 | + $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1838 | + } |
|
1638 | 1839 | $args->title = $args->category_title; |
1639 | 1840 | $args->description = $args->category_description; |
1640 | 1841 | $args->color = $args->category_color; |
@@ -1650,11 +1851,18 @@ discard block |
||
1650 | 1851 | $columnList = array('module_srl', 'module'); |
1651 | 1852 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1652 | 1853 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1653 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1854 | + if(!$grant->manager) { |
|
1855 | + return new BaseObject(-1,'msg_not_permitted'); |
|
1856 | + } |
|
1654 | 1857 | |
1655 | - if($args->expand !="Y") $args->expand = "N"; |
|
1656 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1657 | - else $args->group_srls = implode(',', $args->group_srls); |
|
1858 | + if($args->expand !="Y") { |
|
1859 | + $args->expand = "N"; |
|
1860 | + } |
|
1861 | + if(!is_array($args->group_srls)) { |
|
1862 | + $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1863 | + } else { |
|
1864 | + $args->group_srls = implode(',', $args->group_srls); |
|
1865 | + } |
|
1658 | 1866 | $args->parent_srl = (int)$args->parent_srl; |
1659 | 1867 | |
1660 | 1868 | $oDocumentModel = getModel('document'); |
@@ -1665,7 +1873,9 @@ discard block |
||
1665 | 1873 | if($args->category_srl) |
1666 | 1874 | { |
1667 | 1875 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1668 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1876 | + if($category_info->category_srl != $args->category_srl) { |
|
1877 | + $args->category_srl = null; |
|
1878 | + } |
|
1669 | 1879 | } |
1670 | 1880 | // Update if exists |
1671 | 1881 | if($args->category_srl) |
@@ -1677,8 +1887,7 @@ discard block |
||
1677 | 1887 | return $output; |
1678 | 1888 | } |
1679 | 1889 | // Insert if not exist |
1680 | - } |
|
1681 | - else |
|
1890 | + } else |
|
1682 | 1891 | { |
1683 | 1892 | $output = $this->insertCategory($args); |
1684 | 1893 | if(!$output->toBool()) |
@@ -1720,7 +1929,9 @@ discard block |
||
1720 | 1929 | $columnList = array('module_srl', 'module'); |
1721 | 1930 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
1722 | 1931 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1723 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1932 | + if(!$grant->manager) { |
|
1933 | + return new BaseObject(-1,'msg_not_permitted'); |
|
1934 | + } |
|
1724 | 1935 | |
1725 | 1936 | // First child of the parent_category_srl |
1726 | 1937 | $source_args = new stdClass; |
@@ -1733,30 +1944,39 @@ discard block |
||
1733 | 1944 | $args->parent_srl = $parent_category_srl; |
1734 | 1945 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
1735 | 1946 | |
1736 | - if(!$output->toBool()) return $output; |
|
1947 | + if(!$output->toBool()) { |
|
1948 | + return $output; |
|
1949 | + } |
|
1737 | 1950 | $args->list_order = (int)$output->data->list_order; |
1738 | - if(!$args->list_order) $args->list_order = 0; |
|
1951 | + if(!$args->list_order) { |
|
1952 | + $args->list_order = 0; |
|
1953 | + } |
|
1739 | 1954 | $args->list_order--; |
1740 | 1955 | |
1741 | 1956 | $source_args->category_srl = $source_category_srl; |
1742 | 1957 | $source_args->parent_srl = $parent_category_srl; |
1743 | 1958 | $source_args->list_order = $args->list_order; |
1744 | 1959 | $output = $this->updateCategory($source_args); |
1745 | - if(!$output->toBool()) return $output; |
|
1960 | + if(!$output->toBool()) { |
|
1961 | + return $output; |
|
1962 | + } |
|
1746 | 1963 | // Sibling of the $target_category_srl |
1747 | - } |
|
1748 | - else if($target_category_srl > 0) |
|
1964 | + } else if($target_category_srl > 0) |
|
1749 | 1965 | { |
1750 | 1966 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
1751 | 1967 | // Move all siblings of the $target_category down |
1752 | 1968 | $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
1753 | - if(!$output->toBool()) return $output; |
|
1969 | + if(!$output->toBool()) { |
|
1970 | + return $output; |
|
1971 | + } |
|
1754 | 1972 | |
1755 | 1973 | $source_args->category_srl = $source_category_srl; |
1756 | 1974 | $source_args->parent_srl = $target_category->parent_srl; |
1757 | 1975 | $source_args->list_order = $target_category->list_order+1; |
1758 | 1976 | $output = $this->updateCategory($source_args); |
1759 | - if(!$output->toBool()) return $output; |
|
1977 | + if(!$output->toBool()) { |
|
1978 | + return $output; |
|
1979 | + } |
|
1760 | 1980 | } |
1761 | 1981 | // Re-generate the xml file |
1762 | 1982 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1781,14 +2001,20 @@ discard block |
||
1781 | 2001 | $columnList = array('module_srl', 'module'); |
1782 | 2002 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1783 | 2003 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1784 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
2004 | + if(!$grant->manager) { |
|
2005 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2006 | + } |
|
1785 | 2007 | |
1786 | 2008 | $oDocumentModel = getModel('document'); |
1787 | 2009 | // Get original information |
1788 | 2010 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1789 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
2011 | + if($category_info->parent_srl) { |
|
2012 | + $parent_srl = $category_info->parent_srl; |
|
2013 | + } |
|
1790 | 2014 | // Display an error that the category cannot be deleted if it has a child node |
1791 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
2015 | + if($oDocumentModel->getCategoryChlidCount($args->category_srl)) { |
|
2016 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
2017 | + } |
|
1792 | 2018 | // Remove from the DB |
1793 | 2019 | $output = $this->deleteCategory($args->category_srl); |
1794 | 2020 | if(!$output->toBool()) |
@@ -1822,7 +2048,9 @@ discard block |
||
1822 | 2048 | $columnList = array('module_srl', 'module'); |
1823 | 2049 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1824 | 2050 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1825 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
2051 | + if(!$grant->manager) { |
|
2052 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2053 | + } |
|
1826 | 2054 | |
1827 | 2055 | $xml_file = $this->makeCategoryFile($module_srl); |
1828 | 2056 | // Set return value |
@@ -1837,14 +2065,18 @@ discard block |
||
1837 | 2065 | function makeCategoryFile($module_srl) |
1838 | 2066 | { |
1839 | 2067 | // Return if there is no information you need for creating a cache file |
1840 | - if(!$module_srl) return false; |
|
2068 | + if(!$module_srl) { |
|
2069 | + return false; |
|
2070 | + } |
|
1841 | 2071 | // Get module information (to obtain mid) |
1842 | 2072 | $oModuleModel = getModel('module'); |
1843 | 2073 | $columnList = array('module_srl', 'mid', 'site_srl'); |
1844 | 2074 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1845 | 2075 | $mid = $module_info->mid; |
1846 | 2076 | |
1847 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
2077 | + if(!is_dir('./files/cache/document_category')) { |
|
2078 | + FileHandler::makeDir('./files/cache/document_category'); |
|
2079 | + } |
|
1848 | 2080 | // Cache file's name |
1849 | 2081 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
1850 | 2082 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1856,13 +2088,17 @@ discard block |
||
1856 | 2088 | |
1857 | 2089 | $category_list = $output->data; |
1858 | 2090 | |
1859 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
2091 | + if(!is_array($category_list)) { |
|
2092 | + $category_list = array($category_list); |
|
2093 | + } |
|
1860 | 2094 | |
1861 | 2095 | $category_count = count($category_list); |
1862 | 2096 | for($i=0;$i<$category_count;$i++) |
1863 | 2097 | { |
1864 | 2098 | $category_srl = $category_list[$i]->category_srl; |
1865 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
2099 | + if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) { |
|
2100 | + $category_list[$i]->group_srls = ''; |
|
2101 | + } |
|
1866 | 2102 | $list[$category_srl] = $category_list[$i]; |
1867 | 2103 | } |
1868 | 2104 | // Create the xml file without node data if no data is obtained |
@@ -1874,7 +2110,9 @@ discard block |
||
1874 | 2110 | return $xml_file; |
1875 | 2111 | } |
1876 | 2112 | // Change to an array if only a single data is obtained |
1877 | - if(!is_array($list)) $list = array($list); |
|
2113 | + if(!is_array($list)) { |
|
2114 | + $list = array($list); |
|
2115 | + } |
|
1878 | 2116 | // Create a tree for loop |
1879 | 2117 | foreach($list as $category_srl => $node) |
1880 | 2118 | { |
@@ -1953,13 +2191,17 @@ discard block |
||
1953 | 2191 | */ |
1954 | 2192 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
1955 | 2193 | { |
1956 | - if(!$source_node) return; |
|
2194 | + if(!$source_node) { |
|
2195 | + return; |
|
2196 | + } |
|
1957 | 2197 | |
1958 | 2198 | foreach($source_node as $category_srl => $node) |
1959 | 2199 | { |
1960 | 2200 | $child_buff = ""; |
1961 | 2201 | // Get data of the child nodes |
1962 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
2202 | + if($category_srl && $tree[$category_srl]) { |
|
2203 | + $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
2204 | + } |
|
1963 | 2205 | // List variables |
1964 | 2206 | $expand = ($node->expand) ? $node->expand : 'N'; |
1965 | 2207 | $group_srls = ($node->group_srls) ? $node->group_srls : ''; |
@@ -1969,8 +2211,11 @@ discard block |
||
1969 | 2211 | $color = ($node->color) ? $node->color : ''; |
1970 | 2212 | $description = ($node->description) ? $node->description : ''; |
1971 | 2213 | // If node->group_srls value exists |
1972 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
1973 | - else $group_check_code = "true"; |
|
2214 | + if($group_srls) { |
|
2215 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
2216 | + } else { |
|
2217 | + $group_check_code = "true"; |
|
2218 | + } |
|
1974 | 2219 | |
1975 | 2220 | $title = $node->title; |
1976 | 2221 | $oModuleAdminModel = getAdminModel('module'); |
@@ -2010,8 +2255,11 @@ discard block |
||
2010 | 2255 | $node->document_count |
2011 | 2256 | ); |
2012 | 2257 | |
2013 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2014 | - else $buff .= sprintf('<node %s />', $attribute); |
|
2258 | + if($child_buff) { |
|
2259 | + $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2260 | + } else { |
|
2261 | + $buff .= sprintf('<node %s />', $attribute); |
|
2262 | + } |
|
2015 | 2263 | } |
2016 | 2264 | return $buff; |
2017 | 2265 | } |
@@ -2030,7 +2278,9 @@ discard block |
||
2030 | 2278 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
2031 | 2279 | { |
2032 | 2280 | $output = array("buff"=>"", "category_srl_list"=>array()); |
2033 | - if(!$source_node) return $output; |
|
2281 | + if(!$source_node) { |
|
2282 | + return $output; |
|
2283 | + } |
|
2034 | 2284 | |
2035 | 2285 | // Set to an arraty for looping and then generate php script codes to be included |
2036 | 2286 | foreach($source_node as $category_srl => $node) |
@@ -2129,7 +2379,9 @@ discard block |
||
2129 | 2379 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
2130 | 2380 | { |
2131 | 2381 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
2132 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2382 | + if(!is_array($document_popup_menu_list)) { |
|
2383 | + $document_popup_menu_list = array(); |
|
2384 | + } |
|
2133 | 2385 | |
2134 | 2386 | $obj = new stdClass(); |
2135 | 2387 | $obj->url = $url; |
@@ -2147,7 +2399,9 @@ discard block |
||
2147 | 2399 | */ |
2148 | 2400 | function procDocumentAddCart() |
2149 | 2401 | { |
2150 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2402 | + if(!Context::get('is_logged')) { |
|
2403 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
2404 | + } |
|
2151 | 2405 | |
2152 | 2406 | // Get document_srl |
2153 | 2407 | $srls = explode(',',Context::get('srls')); |
@@ -2155,11 +2409,15 @@ discard block |
||
2155 | 2409 | { |
2156 | 2410 | $srl = trim($srls[$i]); |
2157 | 2411 | |
2158 | - if(!$srl) continue; |
|
2412 | + if(!$srl) { |
|
2413 | + continue; |
|
2414 | + } |
|
2159 | 2415 | |
2160 | 2416 | $document_srls[] = $srl; |
2161 | 2417 | } |
2162 | - if(!count($document_srls)) return; |
|
2418 | + if(!count($document_srls)) { |
|
2419 | + return; |
|
2420 | + } |
|
2163 | 2421 | |
2164 | 2422 | // Get module_srl of the documents |
2165 | 2423 | $args = new stdClass; |
@@ -2167,14 +2425,18 @@ discard block |
||
2167 | 2425 | $args->document_srls = implode(',',$document_srls); |
2168 | 2426 | $args->order_type = 'asc'; |
2169 | 2427 | $output = executeQueryArray('document.getDocuments', $args); |
2170 | - if(!$output->data) return new BaseObject(); |
|
2428 | + if(!$output->data) { |
|
2429 | + return new BaseObject(); |
|
2430 | + } |
|
2171 | 2431 | |
2172 | 2432 | unset($document_srls); |
2173 | 2433 | foreach($output->data as $key => $val) |
2174 | 2434 | { |
2175 | 2435 | $document_srls[$val->module_srl][] = $val->document_srl; |
2176 | 2436 | } |
2177 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2437 | + if(!$document_srls || !count($document_srls)) { |
|
2438 | + return new BaseObject(); |
|
2439 | + } |
|
2178 | 2440 | |
2179 | 2441 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
2180 | 2442 | $oModuleModel = getModel('module'); |
@@ -2199,7 +2461,9 @@ discard block |
||
2199 | 2461 | } |
2200 | 2462 | } |
2201 | 2463 | } |
2202 | - if(!count($document_srls)) return new BaseObject(); |
|
2464 | + if(!count($document_srls)) { |
|
2465 | + return new BaseObject(); |
|
2466 | + } |
|
2203 | 2467 | |
2204 | 2468 | foreach($document_srls as $module_srl => $documents) |
2205 | 2469 | { |
@@ -2207,9 +2471,14 @@ discard block |
||
2207 | 2471 | for($i=0;$i<$cnt;$i++) |
2208 | 2472 | { |
2209 | 2473 | $document_srl = (int)trim($documents[$i]); |
2210 | - if(!$document_srls) continue; |
|
2211 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2212 | - else $_SESSION['document_management'][$document_srl] = true; |
|
2474 | + if(!$document_srls) { |
|
2475 | + continue; |
|
2476 | + } |
|
2477 | + if($_SESSION['document_management'][$document_srl]) { |
|
2478 | + unset($_SESSION['document_management'][$document_srl]); |
|
2479 | + } else { |
|
2480 | + $_SESSION['document_management'][$document_srl] = true; |
|
2481 | + } |
|
2213 | 2482 | } |
2214 | 2483 | } |
2215 | 2484 | } |
@@ -2221,7 +2490,9 @@ discard block |
||
2221 | 2490 | function procDocumentManageCheckedDocument() |
2222 | 2491 | { |
2223 | 2492 | @set_time_limit(0); |
2224 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2493 | + if(!Context::get('is_logged')) { |
|
2494 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2495 | + } |
|
2225 | 2496 | |
2226 | 2497 | if(!checkCSRF()) |
2227 | 2498 | { |
@@ -2231,14 +2502,21 @@ discard block |
||
2231 | 2502 | $type = Context::get('type'); |
2232 | 2503 | $target_module = Context::get('target_module'); |
2233 | 2504 | $module_srl = Context::get('module_srl'); |
2234 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
2505 | + if($target_module && !$module_srl) { |
|
2506 | + $module_srl = $target_module; |
|
2507 | + } |
|
2235 | 2508 | $category_srl = Context::get('target_category'); |
2236 | 2509 | $message_content = Context::get('message_content'); |
2237 | - if($message_content) $message_content = nl2br($message_content); |
|
2510 | + if($message_content) { |
|
2511 | + $message_content = nl2br($message_content); |
|
2512 | + } |
|
2238 | 2513 | |
2239 | 2514 | $cart = Context::get('cart'); |
2240 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
2241 | - else $document_srl_list = $cart; |
|
2515 | + if(!is_array($cart)) { |
|
2516 | + $document_srl_list = explode('|@|', $cart); |
|
2517 | + } else { |
|
2518 | + $document_srl_list = $cart; |
|
2519 | + } |
|
2242 | 2520 | |
2243 | 2521 | $document_srl_count = count($document_srl_list); |
2244 | 2522 | |
@@ -2248,7 +2526,9 @@ discard block |
||
2248 | 2526 | { |
2249 | 2527 | $oDocument = $oDocumentModel->getDocument($document_srl); |
2250 | 2528 | $document_items[] = $oDocument; |
2251 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2529 | + if(!$oDocument->isGranted()) { |
|
2530 | + return $this->stop('msg_not_permitted'); |
|
2531 | + } |
|
2252 | 2532 | } |
2253 | 2533 | |
2254 | 2534 | // Send a message |
@@ -2264,10 +2544,15 @@ discard block |
||
2264 | 2544 | |
2265 | 2545 | foreach($document_items as $oDocument) |
2266 | 2546 | { |
2267 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
2547 | + if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) { |
|
2548 | + continue; |
|
2549 | + } |
|
2268 | 2550 | |
2269 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2270 | - else $purl = ""; |
|
2551 | + if($type=='move') { |
|
2552 | + $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2553 | + } else { |
|
2554 | + $purl = ""; |
|
2555 | + } |
|
2271 | 2556 | $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
2272 | 2557 | |
2273 | 2558 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
@@ -2280,24 +2565,30 @@ discard block |
||
2280 | 2565 | $oDocumentAdminController = getAdminController('document'); |
2281 | 2566 | if($type == 'move') |
2282 | 2567 | { |
2283 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2568 | + if(!$module_srl) { |
|
2569 | + return new BaseObject(-1, 'fail_to_move'); |
|
2570 | + } |
|
2284 | 2571 | |
2285 | 2572 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
2286 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2573 | + if(!$output->toBool()) { |
|
2574 | + return new BaseObject(-1, 'fail_to_move'); |
|
2575 | + } |
|
2287 | 2576 | |
2288 | 2577 | $msg_code = 'success_moved'; |
2289 | 2578 | |
2290 | - } |
|
2291 | - else if($type == 'copy') |
|
2579 | + } else if($type == 'copy') |
|
2292 | 2580 | { |
2293 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2581 | + if(!$module_srl) { |
|
2582 | + return new BaseObject(-1, 'fail_to_move'); |
|
2583 | + } |
|
2294 | 2584 | |
2295 | 2585 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
2296 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2586 | + if(!$output->toBool()) { |
|
2587 | + return new BaseObject(-1, 'fail_to_move'); |
|
2588 | + } |
|
2297 | 2589 | |
2298 | 2590 | $msg_code = 'success_copied'; |
2299 | - } |
|
2300 | - else if($type =='delete') |
|
2591 | + } else if($type =='delete') |
|
2301 | 2592 | { |
2302 | 2593 | $oDB = &DB::getInstance(); |
2303 | 2594 | $oDB->begin(); |
@@ -2305,12 +2596,13 @@ discard block |
||
2305 | 2596 | { |
2306 | 2597 | $document_srl = $document_srl_list[$i]; |
2307 | 2598 | $output = $this->deleteDocument($document_srl, true); |
2308 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2599 | + if(!$output->toBool()) { |
|
2600 | + return new BaseObject(-1, 'fail_to_delete'); |
|
2601 | + } |
|
2309 | 2602 | } |
2310 | 2603 | $oDB->commit(); |
2311 | 2604 | $msg_code = 'success_deleted'; |
2312 | - } |
|
2313 | - else if($type == 'trash') |
|
2605 | + } else if($type == 'trash') |
|
2314 | 2606 | { |
2315 | 2607 | $args = new stdClass(); |
2316 | 2608 | $args->description = $message_content; |
@@ -2320,12 +2612,13 @@ discard block |
||
2320 | 2612 | for($i=0;$i<$document_srl_count;$i++) { |
2321 | 2613 | $args->document_srl = $document_srl_list[$i]; |
2322 | 2614 | $output = $this->moveDocumentToTrash($args); |
2323 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2615 | + if(!$output || !$output->toBool()) { |
|
2616 | + return new BaseObject(-1, 'fail_to_trash'); |
|
2617 | + } |
|
2324 | 2618 | } |
2325 | 2619 | $oDB->commit(); |
2326 | 2620 | $msg_code = 'success_trashed'; |
2327 | - } |
|
2328 | - else if($type == 'cancelDeclare') |
|
2621 | + } else if($type == 'cancelDeclare') |
|
2329 | 2622 | { |
2330 | 2623 | $args->document_srl = $document_srl_list; |
2331 | 2624 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2347,18 +2640,27 @@ discard block |
||
2347 | 2640 | function procDocumentInsertModuleConfig() |
2348 | 2641 | { |
2349 | 2642 | $module_srl = Context::get('target_module_srl'); |
2350 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
2351 | - else $module_srl = array($module_srl); |
|
2643 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
2644 | + $module_srl = explode(',',$module_srl); |
|
2645 | + } else { |
|
2646 | + $module_srl = array($module_srl); |
|
2647 | + } |
|
2352 | 2648 | |
2353 | 2649 | $document_config = new stdClass(); |
2354 | 2650 | $document_config->use_history = Context::get('use_history'); |
2355 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
2651 | + if(!$document_config->use_history) { |
|
2652 | + $document_config->use_history = 'N'; |
|
2653 | + } |
|
2356 | 2654 | |
2357 | 2655 | $document_config->use_vote_up = Context::get('use_vote_up'); |
2358 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2656 | + if(!$document_config->use_vote_up) { |
|
2657 | + $document_config->use_vote_up = 'Y'; |
|
2658 | + } |
|
2359 | 2659 | |
2360 | 2660 | $document_config->use_vote_down = Context::get('use_vote_down'); |
2361 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2661 | + if(!$document_config->use_vote_down) { |
|
2662 | + $document_config->use_vote_down = 'Y'; |
|
2663 | + } |
|
2362 | 2664 | |
2363 | 2665 | $document_config->use_status = Context::get('use_status'); |
2364 | 2666 | |
@@ -2366,7 +2668,9 @@ discard block |
||
2366 | 2668 | for($i=0;$i<count($module_srl);$i++) |
2367 | 2669 | { |
2368 | 2670 | $srl = trim($module_srl[$i]); |
2369 | - if(!$srl) continue; |
|
2671 | + if(!$srl) { |
|
2672 | + continue; |
|
2673 | + } |
|
2370 | 2674 | $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
2371 | 2675 | } |
2372 | 2676 | $this->setError(-1); |
@@ -2383,7 +2687,9 @@ discard block |
||
2383 | 2687 | function procDocumentTempSave() |
2384 | 2688 | { |
2385 | 2689 | // Check login information |
2386 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2690 | + if(!Context::get('is_logged')) { |
|
2691 | + return new BaseObject(-1, 'msg_not_logged'); |
|
2692 | + } |
|
2387 | 2693 | $module_info = Context::get('module_info'); |
2388 | 2694 | $logged_info = Context::get('logged_info'); |
2389 | 2695 | |
@@ -2421,8 +2727,7 @@ discard block |
||
2421 | 2727 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
2422 | 2728 | $msg_code = 'success_updated'; |
2423 | 2729 | // Otherwise, get a new |
2424 | - } |
|
2425 | - else |
|
2730 | + } else |
|
2426 | 2731 | { |
2427 | 2732 | $output = $oDocumentController->insertDocument($obj); |
2428 | 2733 | $msg_code = 'success_registed'; |
@@ -2448,17 +2753,20 @@ discard block |
||
2448 | 2753 | */ |
2449 | 2754 | function procDocumentGetList() |
2450 | 2755 | { |
2451 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2756 | + if(!Context::get('is_logged')) { |
|
2757 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2758 | + } |
|
2452 | 2759 | $documentSrls = Context::get('document_srls'); |
2453 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2760 | + if($documentSrls) { |
|
2761 | + $documentSrlList = explode(',', $documentSrls); |
|
2762 | + } |
|
2454 | 2763 | |
2455 | 2764 | if(count($documentSrlList) > 0) |
2456 | 2765 | { |
2457 | 2766 | $oDocumentModel = getModel('document'); |
2458 | 2767 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
2459 | 2768 | $documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList); |
2460 | - } |
|
2461 | - else |
|
2769 | + } else |
|
2462 | 2770 | { |
2463 | 2771 | global $lang; |
2464 | 2772 | $documentList = array(); |
@@ -2476,11 +2784,18 @@ discard block |
||
2476 | 2784 | */ |
2477 | 2785 | function _checkCommentStatusForOldVersion(&$obj) |
2478 | 2786 | { |
2479 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2480 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2787 | + if(!isset($obj->allow_comment)) { |
|
2788 | + $obj->allow_comment = 'N'; |
|
2789 | + } |
|
2790 | + if(!isset($obj->lock_comment)) { |
|
2791 | + $obj->lock_comment = 'N'; |
|
2792 | + } |
|
2481 | 2793 | |
2482 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2483 | - else $obj->commentStatus = 'DENY'; |
|
2794 | + if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') { |
|
2795 | + $obj->commentStatus = 'ALLOW'; |
|
2796 | + } else { |
|
2797 | + $obj->commentStatus = 'DENY'; |
|
2798 | + } |
|
2484 | 2799 | } |
2485 | 2800 | |
2486 | 2801 | /** |
@@ -2490,8 +2805,12 @@ discard block |
||
2490 | 2805 | */ |
2491 | 2806 | function _checkDocumentStatusForOldVersion(&$obj) |
2492 | 2807 | { |
2493 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2494 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2808 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
2809 | + $obj->status = $this->getConfigStatus('secret'); |
|
2810 | + } |
|
2811 | + if(!$obj->status && $obj->is_secret != 'Y') { |
|
2812 | + $obj->status = $this->getConfigStatus('public'); |
|
2813 | + } |
|
2495 | 2814 | } |
2496 | 2815 | |
2497 | 2816 | public function updateUploaedCount($documentSrlList) |