GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#2346)
by
unknown
10:33 queued 03:17
created
modules/document/document.controller.php 2 patches
Braces   +535 added lines, -216 removed lines patch added patch discarded remove patch
@@ -24,19 +24,27 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
@@ -1144,18 +1301,21 @@  discard block
 block discarded – undo
1144 1301
 		{
1145 1302
 			$args->blamed_count = $trigger_obj->after_point;
1146 1303
 			$output = executeQuery('document.updateBlamedCount', $args);
1147
-		}
1148
-		else
1304
+		} else
1149 1305
 		{
1150 1306
 			$args->voted_count = $trigger_obj->after_point;
1151 1307
 			$output = executeQuery('document.updateVotedCount', $args);
1152 1308
 		}
1153
-		if(!$output->toBool()) return $output;
1309
+		if(!$output->toBool()) {
1310
+			return $output;
1311
+		}
1154 1312
 
1155 1313
 		// Leave logs
1156 1314
 		$args->point = $trigger_obj->point;
1157 1315
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1158
-		if(!$output->toBool()) return $output;
1316
+		if(!$output->toBool()) {
1317
+			return $output;
1318
+		}
1159 1319
 
1160 1320
 		// Call a trigger (after)
1161 1321
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj);
@@ -1184,8 +1344,7 @@  discard block
 block discarded – undo
1184 1344
 		{
1185 1345
 			$output->setMessage('success_voted');
1186 1346
 			$output->add('voted_count', $trigger_obj->after_point);
1187
-		}
1188
-		else
1347
+		} else
1189 1348
 		{
1190 1349
 			$output->setMessage('success_blamed');
1191 1350
 			$output->add('blamed_count', $trigger_obj->after_point);
@@ -1202,13 +1361,17 @@  discard block
 block discarded – undo
1202 1361
 	function declaredDocument($document_srl)
1203 1362
 	{
1204 1363
 		// Fail if session information already has a reported document
1205
-		if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared');
1364
+		if($_SESSION['declared_document'][$document_srl]) {
1365
+			return new BaseObject(-1, 'failed_declared');
1366
+		}
1206 1367
 
1207 1368
 		// Check if previously reported
1208 1369
 		$args = new stdClass();
1209 1370
 		$args->document_srl = $document_srl;
1210 1371
 		$output = executeQuery('document.getDeclaredDocument', $args);
1211
-		if(!$output->toBool()) return $output;
1372
+		if(!$output->toBool()) {
1373
+			return $output;
1374
+		}
1212 1375
 
1213 1376
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1214 1377
 
@@ -1252,8 +1415,7 @@  discard block
 block discarded – undo
1252 1415
 		if($member_srl)
1253 1416
 		{
1254 1417
 			$args->member_srl = $member_srl;
1255
-		}
1256
-		else
1418
+		} else
1257 1419
 		{
1258 1420
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1259 1421
 		}
@@ -1273,9 +1435,14 @@  discard block
 block discarded – undo
1273 1435
 		$oDB->begin();
1274 1436
 
1275 1437
 		// Add the declared document
1276
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1277
-		else $output = executeQuery('document.insertDeclaredDocument', $args);
1278
-		if(!$output->toBool()) return $output;
1438
+		if($declared_count > 0) {
1439
+			$output = executeQuery('document.updateDeclaredDocument', $args);
1440
+		} else {
1441
+			$output = executeQuery('document.insertDeclaredDocument', $args);
1442
+		}
1443
+		if(!$output->toBool()) {
1444
+			return $output;
1445
+		}
1279 1446
 		// Leave logs
1280 1447
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1281 1448
 		if(!$output->toBool())
@@ -1374,9 +1541,10 @@  discard block
 block discarded – undo
1374 1541
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1375 1542
 			$obj->list_order = $parent_category->list_order;
1376 1543
 			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1377
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1378
-		}
1379
-		else
1544
+			if(!$obj->category_srl) {
1545
+				$obj->category_srl = getNextSequence();
1546
+			}
1547
+		} else
1380 1548
 		{
1381 1549
 			$obj->list_order = $obj->category_srl = getNextSequence();
1382 1550
 		}
@@ -1416,13 +1584,17 @@  discard block
 block discarded – undo
1416 1584
 	{
1417 1585
 		// Create a document model object
1418 1586
 		$oDocumentModel = getModel('document');
1419
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1587
+		if(!$document_count) {
1588
+			$document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1589
+		}
1420 1590
 
1421 1591
 		$args = new stdClass;
1422 1592
 		$args->category_srl = $category_srl;
1423 1593
 		$args->document_count = $document_count;
1424 1594
 		$output = executeQuery('document.updateCategoryCount', $args);
1425
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1595
+		if($output->toBool()) {
1596
+			$this->makeCategoryFile($module_srl);
1597
+		}
1426 1598
 
1427 1599
 		return $output;
1428 1600
 	}
@@ -1435,7 +1607,9 @@  discard block
 block discarded – undo
1435 1607
 	function updateCategory($obj)
1436 1608
 	{
1437 1609
 		$output = executeQuery('document.updateCategory', $obj);
1438
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1610
+		if($output->toBool()) {
1611
+			$this->makeCategoryFile($obj->module_srl);
1612
+		}
1439 1613
 		return $output;
1440 1614
 	}
1441 1615
 
@@ -1452,11 +1626,17 @@  discard block
 block discarded – undo
1452 1626
 		$category_info = $oDocumentModel->getCategory($category_srl);
1453 1627
 		// Display an error that the category cannot be deleted if it has a child
1454 1628
 		$output = executeQuery('document.getChildCategoryCount', $args);
1455
-		if(!$output->toBool()) return $output;
1456
-		if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1629
+		if(!$output->toBool()) {
1630
+			return $output;
1631
+		}
1632
+		if($output->data->count>0) {
1633
+			return new BaseObject(-1, 'msg_cannot_delete_for_child');
1634
+		}
1457 1635
 		// Delete a category information
1458 1636
 		$output = executeQuery('document.deleteCategory', $args);
1459
-		if(!$output->toBool()) return $output;
1637
+		if(!$output->toBool()) {
1638
+			return $output;
1639
+		}
1460 1640
 
1461 1641
 		$this->makeCategoryFile($category_info->module_srl);
1462 1642
 		// remvove cache
@@ -1471,8 +1651,9 @@  discard block
 block discarded – undo
1471 1651
 				$args->page = ++$page;
1472 1652
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1473 1653
 
1474
-				if($output->data == array())
1475
-					break;
1654
+				if($output->data == array()) {
1655
+									break;
1656
+				}
1476 1657
 
1477 1658
 				foreach($output->data as $val)
1478 1659
 				{
@@ -1524,18 +1705,26 @@  discard block
 block discarded – undo
1524 1705
 		// Seek a full list of categories
1525 1706
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1526 1707
 		$category_srl_list = array_keys($category_list);
1527
-		if(count($category_srl_list)<2) return new BaseObject();
1708
+		if(count($category_srl_list)<2) {
1709
+			return new BaseObject();
1710
+		}
1528 1711
 
1529 1712
 		$prev_category = NULL;
1530 1713
 		foreach($category_list as $key => $val)
1531 1714
 		{
1532
-			if($key==$category_srl) break;
1715
+			if($key==$category_srl) {
1716
+				break;
1717
+			}
1533 1718
 			$prev_category = $val;
1534 1719
 		}
1535 1720
 		// Return if the previous category doesn't exist
1536
-		if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1721
+		if(!$prev_category) {
1722
+			return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1723
+		}
1537 1724
 		// Return if the selected category is the top level
1538
-		if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1725
+		if($category_srl_list[0]==$category_srl) {
1726
+			return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1727
+		}
1539 1728
 		// Information of the selected category
1540 1729
 		$cur_args = new stdClass;
1541 1730
 		$cur_args->category_srl = $category_srl;
@@ -1571,15 +1760,21 @@  discard block
 block discarded – undo
1571 1760
 		// Seek a full list of categories
1572 1761
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1573 1762
 		$category_srl_list = array_keys($category_list);
1574
-		if(count($category_srl_list)<2) return new BaseObject();
1763
+		if(count($category_srl_list)<2) {
1764
+			return new BaseObject();
1765
+		}
1575 1766
 
1576 1767
 		for($i=0;$i<count($category_srl_list);$i++)
1577 1768
 		{
1578
-			if($category_srl_list[$i]==$category_srl) break;
1769
+			if($category_srl_list[$i]==$category_srl) {
1770
+				break;
1771
+			}
1579 1772
 		}
1580 1773
 
1581 1774
 		$next_category_srl = $category_srl_list[$i+1];
1582
-		if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1775
+		if(!$category_list[$next_category_srl]) {
1776
+			return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1777
+		}
1583 1778
 		$next_category = $category_list[$next_category_srl];
1584 1779
 		// Information of the selected category
1585 1780
 		$cur_args = new stdClass;
@@ -1606,7 +1801,9 @@  discard block
 block discarded – undo
1606 1801
 	{
1607 1802
 		$oDocumentModel = getModel('document');
1608 1803
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1609
-		if(!count($extra_keys)) return;
1804
+		if(!count($extra_keys)) {
1805
+			return;
1806
+		}
1610 1807
 
1611 1808
 		$js_code = array();
1612 1809
 		$js_code[] = '<script>//<![CDATA[';
@@ -1625,7 +1822,9 @@  discard block
 block discarded – undo
1625 1822
 			}
1626 1823
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1627 1824
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1628
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1825
+			if($val->is_required == 'Y') {
1826
+				$js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1827
+			}
1629 1828
 		}
1630 1829
 
1631 1830
 		$js_code[] = '})(jQuery);';
@@ -1643,7 +1842,9 @@  discard block
 block discarded – undo
1643 1842
 	function procDocumentInsertCategory($args = null)
1644 1843
 	{
1645 1844
 		// List variables
1646
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1845
+		if(!$args) {
1846
+			$args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1847
+		}
1647 1848
 		$args->title = $args->category_title;
1648 1849
 		$args->description = $args->category_description;
1649 1850
 		$args->color = $args->category_color;
@@ -1659,11 +1860,18 @@  discard block
 block discarded – undo
1659 1860
 		$columnList = array('module_srl', 'module');
1660 1861
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1661 1862
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1662
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1863
+		if(!$grant->manager) {
1864
+			return new BaseObject(-1,'msg_not_permitted');
1865
+		}
1663 1866
 
1664
-		if($args->expand !="Y") $args->expand = "N";
1665
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1666
-		else $args->group_srls = implode(',', $args->group_srls);
1867
+		if($args->expand !="Y") {
1868
+			$args->expand = "N";
1869
+		}
1870
+		if(!is_array($args->group_srls)) {
1871
+			$args->group_srls = str_replace('|@|',',',$args->group_srls);
1872
+		} else {
1873
+			$args->group_srls = implode(',', $args->group_srls);
1874
+		}
1667 1875
 		$args->parent_srl = (int)$args->parent_srl;
1668 1876
 
1669 1877
 		$oDocumentModel = getModel('document');
@@ -1674,7 +1882,9 @@  discard block
 block discarded – undo
1674 1882
 		if($args->category_srl)
1675 1883
 		{
1676 1884
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1677
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1885
+			if($category_info->category_srl != $args->category_srl) {
1886
+				$args->category_srl = null;
1887
+			}
1678 1888
 		}
1679 1889
 		// Update if exists
1680 1890
 		if($args->category_srl)
@@ -1686,8 +1896,7 @@  discard block
 block discarded – undo
1686 1896
 				return $output;
1687 1897
 			}
1688 1898
 			// Insert if not exist
1689
-		}
1690
-		else
1899
+		} else
1691 1900
 		{
1692 1901
 			$output = $this->insertCategory($args);
1693 1902
 			if(!$output->toBool())
@@ -1729,7 +1938,9 @@  discard block
 block discarded – undo
1729 1938
 		$columnList = array('module_srl', 'module');
1730 1939
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1731 1940
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1732
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1941
+		if(!$grant->manager) {
1942
+			return new BaseObject(-1,'msg_not_permitted');
1943
+		}
1733 1944
 
1734 1945
 		// First child of the parent_category_srl
1735 1946
 		$source_args = new stdClass;
@@ -1742,30 +1953,39 @@  discard block
 block discarded – undo
1742 1953
 			$args->parent_srl = $parent_category_srl;
1743 1954
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1744 1955
 
1745
-			if(!$output->toBool()) return $output;
1956
+			if(!$output->toBool()) {
1957
+				return $output;
1958
+			}
1746 1959
 			$args->list_order = (int)$output->data->list_order;
1747
-			if(!$args->list_order) $args->list_order = 0;
1960
+			if(!$args->list_order) {
1961
+				$args->list_order = 0;
1962
+			}
1748 1963
 			$args->list_order--;
1749 1964
 
1750 1965
 			$source_args->category_srl = $source_category_srl;
1751 1966
 			$source_args->parent_srl = $parent_category_srl;
1752 1967
 			$source_args->list_order = $args->list_order;
1753 1968
 			$output = $this->updateCategory($source_args);
1754
-			if(!$output->toBool()) return $output;
1969
+			if(!$output->toBool()) {
1970
+				return $output;
1971
+			}
1755 1972
 			// Sibling of the $target_category_srl
1756
-		}
1757
-		else if($target_category_srl > 0)
1973
+		} else if($target_category_srl > 0)
1758 1974
 		{
1759 1975
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1760 1976
 			// Move all siblings of the $target_category down
1761 1977
 			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1762
-			if(!$output->toBool()) return $output;
1978
+			if(!$output->toBool()) {
1979
+				return $output;
1980
+			}
1763 1981
 
1764 1982
 			$source_args->category_srl = $source_category_srl;
1765 1983
 			$source_args->parent_srl = $target_category->parent_srl;
1766 1984
 			$source_args->list_order = $target_category->list_order+1;
1767 1985
 			$output = $this->updateCategory($source_args);
1768
-			if(!$output->toBool()) return $output;
1986
+			if(!$output->toBool()) {
1987
+				return $output;
1988
+			}
1769 1989
 		}
1770 1990
 		// Re-generate the xml file
1771 1991
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1790,14 +2010,20 @@  discard block
 block discarded – undo
1790 2010
 		$columnList = array('module_srl', 'module');
1791 2011
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1792 2012
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1793
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
2013
+		if(!$grant->manager) {
2014
+			return new BaseObject(-1,'msg_not_permitted');
2015
+		}
1794 2016
 
1795 2017
 		$oDocumentModel = getModel('document');
1796 2018
 		// Get original information
1797 2019
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1798
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
2020
+		if($category_info->parent_srl) {
2021
+			$parent_srl = $category_info->parent_srl;
2022
+		}
1799 2023
 		// Display an error that the category cannot be deleted if it has a child node
1800
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child');
2024
+		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) {
2025
+			return new BaseObject(-1, 'msg_cannot_delete_for_child');
2026
+		}
1801 2027
 		// Remove from the DB
1802 2028
 		$output = $this->deleteCategory($args->category_srl);
1803 2029
 		if(!$output->toBool())
@@ -1831,7 +2057,9 @@  discard block
 block discarded – undo
1831 2057
 		$columnList = array('module_srl', 'module');
1832 2058
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1833 2059
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1834
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
2060
+		if(!$grant->manager) {
2061
+			return new BaseObject(-1,'msg_not_permitted');
2062
+		}
1835 2063
 
1836 2064
 		$xml_file = $this->makeCategoryFile($module_srl);
1837 2065
 		// Set return value
@@ -1846,14 +2074,18 @@  discard block
 block discarded – undo
1846 2074
 	function makeCategoryFile($module_srl)
1847 2075
 	{
1848 2076
 		// Return if there is no information you need for creating a cache file
1849
-		if(!$module_srl) return false;
2077
+		if(!$module_srl) {
2078
+			return false;
2079
+		}
1850 2080
 		// Get module information (to obtain mid)
1851 2081
 		$oModuleModel = getModel('module');
1852 2082
 		$columnList = array('module_srl', 'mid', 'site_srl');
1853 2083
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1854 2084
 		$mid = $module_info->mid;
1855 2085
 
1856
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
2086
+		if(!is_dir('./files/cache/document_category')) {
2087
+			FileHandler::makeDir('./files/cache/document_category');
2088
+		}
1857 2089
 		// Cache file's name
1858 2090
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1859 2091
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1865,13 +2097,17 @@  discard block
 block discarded – undo
1865 2097
 
1866 2098
 		$category_list = $output->data;
1867 2099
 
1868
-		if(!is_array($category_list)) $category_list = array($category_list);
2100
+		if(!is_array($category_list)) {
2101
+			$category_list = array($category_list);
2102
+		}
1869 2103
 
1870 2104
 		$category_count = count($category_list);
1871 2105
 		for($i=0;$i<$category_count;$i++)
1872 2106
 		{
1873 2107
 			$category_srl = $category_list[$i]->category_srl;
1874
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
2108
+			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) {
2109
+				$category_list[$i]->group_srls = '';
2110
+			}
1875 2111
 			$list[$category_srl] = $category_list[$i];
1876 2112
 		}
1877 2113
 		// Create the xml file without node data if no data is obtained
@@ -1883,7 +2119,9 @@  discard block
 block discarded – undo
1883 2119
 			return $xml_file;
1884 2120
 		}
1885 2121
 		// Change to an array if only a single data is obtained
1886
-		if(!is_array($list)) $list = array($list);
2122
+		if(!is_array($list)) {
2123
+			$list = array($list);
2124
+		}
1887 2125
 		// Create a tree for loop
1888 2126
 		foreach($list as $category_srl => $node)
1889 2127
 		{
@@ -1962,13 +2200,17 @@  discard block
 block discarded – undo
1962 2200
 	 */
1963 2201
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1964 2202
 	{
1965
-		if(!$source_node) return;
2203
+		if(!$source_node) {
2204
+			return;
2205
+		}
1966 2206
 
1967 2207
 		foreach($source_node as $category_srl => $node)
1968 2208
 		{
1969 2209
 			$child_buff = "";
1970 2210
 			// Get data of the child nodes
1971
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
2211
+			if($category_srl && $tree[$category_srl]) {
2212
+				$child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
2213
+			}
1972 2214
 			// List variables
1973 2215
 			$expand = ($node->expand) ? $node->expand : 'N';
1974 2216
 			$group_srls = ($node->group_srls) ? $node->group_srls : '';
@@ -1978,8 +2220,11 @@  discard block
 block discarded – undo
1978 2220
 			$color = ($node->color) ? $node->color : '';
1979 2221
 			$description = ($node->description) ? $node->description : '';
1980 2222
 			// If node->group_srls value exists
1981
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1982
-			else $group_check_code = "true";
2223
+			if($group_srls) {
2224
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
2225
+			} else {
2226
+				$group_check_code = "true";
2227
+			}
1983 2228
 
1984 2229
 			$title = $node->title;
1985 2230
 			$oModuleAdminModel = getAdminModel('module');
@@ -2019,8 +2264,11 @@  discard block
 block discarded – undo
2019 2264
 				$node->document_count
2020 2265
 			);
2021 2266
 
2022
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2023
-			else $buff .=  sprintf('<node %s />', $attribute);
2267
+			if($child_buff) {
2268
+				$buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2269
+			} else {
2270
+				$buff .=  sprintf('<node %s />', $attribute);
2271
+			}
2024 2272
 		}
2025 2273
 		return $buff;
2026 2274
 	}
@@ -2039,7 +2287,9 @@  discard block
 block discarded – undo
2039 2287
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2040 2288
 	{
2041 2289
 		$output = array("buff"=>"", "category_srl_list"=>array());
2042
-		if(!$source_node) return $output;
2290
+		if(!$source_node) {
2291
+			return $output;
2292
+		}
2043 2293
 
2044 2294
 		// Set to an arraty for looping and then generate php script codes to be included
2045 2295
 		foreach($source_node as $category_srl => $node)
@@ -2138,7 +2388,9 @@  discard block
 block discarded – undo
2138 2388
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2139 2389
 	{
2140 2390
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2141
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2391
+		if(!is_array($document_popup_menu_list)) {
2392
+			$document_popup_menu_list = array();
2393
+		}
2142 2394
 
2143 2395
 		$obj = new stdClass();
2144 2396
 		$obj->url = $url;
@@ -2156,7 +2408,9 @@  discard block
 block discarded – undo
2156 2408
 	 */
2157 2409
 	function procDocumentAddCart()
2158 2410
 	{
2159
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2411
+		if(!Context::get('is_logged')) {
2412
+			return new BaseObject(-1, 'msg_not_permitted');
2413
+		}
2160 2414
 
2161 2415
 		// Get document_srl
2162 2416
 		$srls = explode(',',Context::get('srls'));
@@ -2164,11 +2418,15 @@  discard block
 block discarded – undo
2164 2418
 		{
2165 2419
 			$srl = trim($srls[$i]);
2166 2420
 
2167
-			if(!$srl) continue;
2421
+			if(!$srl) {
2422
+				continue;
2423
+			}
2168 2424
 
2169 2425
 			$document_srls[] = $srl;
2170 2426
 		}
2171
-		if(!count($document_srls)) return;
2427
+		if(!count($document_srls)) {
2428
+			return;
2429
+		}
2172 2430
 
2173 2431
 		// Get module_srl of the documents
2174 2432
 		$args = new stdClass;
@@ -2176,14 +2434,18 @@  discard block
 block discarded – undo
2176 2434
 		$args->document_srls = implode(',',$document_srls);
2177 2435
 		$args->order_type = 'asc';
2178 2436
 		$output = executeQueryArray('document.getDocuments', $args);
2179
-		if(!$output->data) return new BaseObject();
2437
+		if(!$output->data) {
2438
+			return new BaseObject();
2439
+		}
2180 2440
 
2181 2441
 		unset($document_srls);
2182 2442
 		foreach($output->data as $key => $val)
2183 2443
 		{
2184 2444
 			$document_srls[$val->module_srl][] = $val->document_srl;
2185 2445
 		}
2186
-		if(!$document_srls || !count($document_srls)) return new BaseObject();
2446
+		if(!$document_srls || !count($document_srls)) {
2447
+			return new BaseObject();
2448
+		}
2187 2449
 
2188 2450
 		// 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)
2189 2451
 		$oModuleModel = getModel('module');
@@ -2208,7 +2470,9 @@  discard block
 block discarded – undo
2208 2470
 				}
2209 2471
 			}
2210 2472
 		}
2211
-		if(!count($document_srls)) return new BaseObject();
2473
+		if(!count($document_srls)) {
2474
+			return new BaseObject();
2475
+		}
2212 2476
 
2213 2477
 		foreach($document_srls as $module_srl => $documents)
2214 2478
 		{
@@ -2216,9 +2480,14 @@  discard block
 block discarded – undo
2216 2480
 			for($i=0;$i<$cnt;$i++)
2217 2481
 			{
2218 2482
 				$document_srl = (int)trim($documents[$i]);
2219
-				if(!$document_srls) continue;
2220
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2221
-				else $_SESSION['document_management'][$document_srl] = true;
2483
+				if(!$document_srls) {
2484
+					continue;
2485
+				}
2486
+				if($_SESSION['document_management'][$document_srl]) {
2487
+					unset($_SESSION['document_management'][$document_srl]);
2488
+				} else {
2489
+					$_SESSION['document_management'][$document_srl] = true;
2490
+				}
2222 2491
 			}
2223 2492
 		}
2224 2493
 	}
@@ -2230,7 +2499,9 @@  discard block
 block discarded – undo
2230 2499
 	function procDocumentManageCheckedDocument()
2231 2500
 	{
2232 2501
 		@set_time_limit(0);
2233
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2502
+		if(!Context::get('is_logged')) {
2503
+			return new BaseObject(-1,'msg_not_permitted');
2504
+		}
2234 2505
 
2235 2506
 		if(!checkCSRF())
2236 2507
 		{
@@ -2240,14 +2511,21 @@  discard block
 block discarded – undo
2240 2511
 		$type = Context::get('type');
2241 2512
 		$target_module = Context::get('target_module');
2242 2513
 		$module_srl = Context::get('module_srl');
2243
-		if($target_module && !$module_srl) $module_srl = $target_module;
2514
+		if($target_module && !$module_srl) {
2515
+			$module_srl = $target_module;
2516
+		}
2244 2517
 		$category_srl = Context::get('target_category');
2245 2518
 		$message_content = Context::get('message_content');
2246
-		if($message_content) $message_content = nl2br($message_content);
2519
+		if($message_content) {
2520
+			$message_content = nl2br($message_content);
2521
+		}
2247 2522
 
2248 2523
 		$cart = Context::get('cart');
2249
-		if(!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2250
-		else $document_srl_list = $cart;
2524
+		if(!is_array($cart)) {
2525
+			$document_srl_list = explode('|@|', $cart);
2526
+		} else {
2527
+			$document_srl_list = $cart;
2528
+		}
2251 2529
 
2252 2530
 		$document_srl_count = count($document_srl_list);
2253 2531
 
@@ -2257,7 +2535,9 @@  discard block
 block discarded – undo
2257 2535
 		{
2258 2536
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2259 2537
 			$document_items[] = $oDocument;
2260
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2538
+			if(!$oDocument->isGranted()) {
2539
+				return $this->stop('msg_not_permitted');
2540
+			}
2261 2541
 		}
2262 2542
 
2263 2543
 		// Send a message
@@ -2273,10 +2553,15 @@  discard block
 block discarded – undo
2273 2553
 
2274 2554
 			foreach($document_items as $oDocument)
2275 2555
 			{
2276
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2556
+				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) {
2557
+					continue;
2558
+				}
2277 2559
 
2278
-				if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2279
-				else $purl = "";
2560
+				if($type=='move') {
2561
+					$purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2562
+				} else {
2563
+					$purl = "";
2564
+				}
2280 2565
 				$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));
2281 2566
 
2282 2567
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
@@ -2289,24 +2574,30 @@  discard block
 block discarded – undo
2289 2574
 		$oDocumentAdminController = getAdminController('document');
2290 2575
 		if($type == 'move')
2291 2576
 		{
2292
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2577
+			if(!$module_srl) {
2578
+				return new BaseObject(-1, 'fail_to_move');
2579
+			}
2293 2580
 
2294 2581
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2295
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2582
+			if(!$output->toBool()) {
2583
+				return new BaseObject(-1, 'fail_to_move');
2584
+			}
2296 2585
 
2297 2586
 			$msg_code = 'success_moved';
2298 2587
 
2299
-		}
2300
-		else if($type == 'copy')
2588
+		} else if($type == 'copy')
2301 2589
 		{
2302
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2590
+			if(!$module_srl) {
2591
+				return new BaseObject(-1, 'fail_to_move');
2592
+			}
2303 2593
 
2304 2594
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2305
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2595
+			if(!$output->toBool()) {
2596
+				return new BaseObject(-1, 'fail_to_move');
2597
+			}
2306 2598
 
2307 2599
 			$msg_code = 'success_copied';
2308
-		}
2309
-		else if($type =='delete')
2600
+		} else if($type =='delete')
2310 2601
 		{
2311 2602
 			$oDB = &DB::getInstance();
2312 2603
 			$oDB->begin();
@@ -2314,12 +2605,13 @@  discard block
 block discarded – undo
2314 2605
 			{
2315 2606
 				$document_srl = $document_srl_list[$i];
2316 2607
 				$output = $this->deleteDocument($document_srl, true);
2317
-				if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete');
2608
+				if(!$output->toBool()) {
2609
+					return new BaseObject(-1, 'fail_to_delete');
2610
+				}
2318 2611
 			}
2319 2612
 			$oDB->commit();
2320 2613
 			$msg_code = 'success_deleted';
2321
-		}
2322
-		else if($type == 'trash')
2614
+		} else if($type == 'trash')
2323 2615
 		{
2324 2616
 			$args = new stdClass();
2325 2617
 			$args->description = $message_content;
@@ -2329,12 +2621,13 @@  discard block
 block discarded – undo
2329 2621
 			for($i=0;$i<$document_srl_count;$i++) {
2330 2622
 				$args->document_srl = $document_srl_list[$i];
2331 2623
 				$output = $this->moveDocumentToTrash($args);
2332
-				if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash');
2624
+				if(!$output || !$output->toBool()) {
2625
+					return new BaseObject(-1, 'fail_to_trash');
2626
+				}
2333 2627
 			}
2334 2628
 			$oDB->commit();
2335 2629
 			$msg_code = 'success_trashed';
2336
-		}
2337
-		else if($type == 'cancelDeclare')
2630
+		} else if($type == 'cancelDeclare')
2338 2631
 		{
2339 2632
 			$args->document_srl = $document_srl_list;
2340 2633
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2356,18 +2649,27 @@  discard block
 block discarded – undo
2356 2649
 	function procDocumentInsertModuleConfig()
2357 2650
 	{
2358 2651
 		$module_srl = Context::get('target_module_srl');
2359
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2360
-		else $module_srl = array($module_srl);
2652
+		if(preg_match('/^([0-9,]+)$/',$module_srl)) {
2653
+			$module_srl = explode(',',$module_srl);
2654
+		} else {
2655
+			$module_srl = array($module_srl);
2656
+		}
2361 2657
 
2362 2658
 		$document_config = new stdClass();
2363 2659
 		$document_config->use_history = Context::get('use_history');
2364
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2660
+		if(!$document_config->use_history) {
2661
+			$document_config->use_history = 'N';
2662
+		}
2365 2663
 
2366 2664
 		$document_config->use_vote_up = Context::get('use_vote_up');
2367
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2665
+		if(!$document_config->use_vote_up) {
2666
+			$document_config->use_vote_up = 'Y';
2667
+		}
2368 2668
 
2369 2669
 		$document_config->use_vote_down = Context::get('use_vote_down');
2370
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2670
+		if(!$document_config->use_vote_down) {
2671
+			$document_config->use_vote_down = 'Y';
2672
+		}
2371 2673
 
2372 2674
 		$document_config->use_status = Context::get('use_status');
2373 2675
 
@@ -2375,7 +2677,9 @@  discard block
 block discarded – undo
2375 2677
 		for($i=0;$i<count($module_srl);$i++)
2376 2678
 		{
2377 2679
 			$srl = trim($module_srl[$i]);
2378
-			if(!$srl) continue;
2680
+			if(!$srl) {
2681
+				continue;
2682
+			}
2379 2683
 			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2380 2684
 		}
2381 2685
 		$this->setError(-1);
@@ -2392,7 +2696,9 @@  discard block
 block discarded – undo
2392 2696
 	function procDocumentTempSave()
2393 2697
 	{
2394 2698
 		// Check login information
2395
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged');
2699
+		if(!Context::get('is_logged')) {
2700
+			return new BaseObject(-1, 'msg_not_logged');
2701
+		}
2396 2702
 		$module_info = Context::get('module_info');
2397 2703
 		$logged_info = Context::get('logged_info');
2398 2704
 
@@ -2430,8 +2736,7 @@  discard block
 block discarded – undo
2430 2736
 			$output = $oDocumentController->updateDocument($oDocument, $obj);
2431 2737
 			$msg_code = 'success_updated';
2432 2738
 			// Otherwise, get a new
2433
-		}
2434
-		else
2739
+		} else
2435 2740
 		{
2436 2741
 			$output = $oDocumentController->insertDocument($obj);
2437 2742
 			$msg_code = 'success_registed';
@@ -2457,17 +2762,20 @@  discard block
 block discarded – undo
2457 2762
 	 */
2458 2763
 	function procDocumentGetList()
2459 2764
 	{
2460
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2765
+		if(!Context::get('is_logged')) {
2766
+			return new BaseObject(-1,'msg_not_permitted');
2767
+		}
2461 2768
 		$documentSrls = Context::get('document_srls');
2462
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2769
+		if($documentSrls) {
2770
+			$documentSrlList = explode(',', $documentSrls);
2771
+		}
2463 2772
 
2464 2773
 		if(count($documentSrlList) > 0)
2465 2774
 		{
2466 2775
 			$oDocumentModel = getModel('document');
2467 2776
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
2468 2777
 			$documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList);
2469
-		}
2470
-		else
2778
+		} else
2471 2779
 		{
2472 2780
 			global $lang;
2473 2781
 			$documentList = array();
@@ -2485,11 +2793,18 @@  discard block
 block discarded – undo
2485 2793
 	 */
2486 2794
 	function _checkCommentStatusForOldVersion(&$obj)
2487 2795
 	{
2488
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2489
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2796
+		if(!isset($obj->allow_comment)) {
2797
+			$obj->allow_comment = 'N';
2798
+		}
2799
+		if(!isset($obj->lock_comment)) {
2800
+			$obj->lock_comment = 'N';
2801
+		}
2490 2802
 
2491
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2492
-		else $obj->commentStatus = 'DENY';
2803
+		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') {
2804
+			$obj->commentStatus = 'ALLOW';
2805
+		} else {
2806
+			$obj->commentStatus = 'DENY';
2807
+		}
2493 2808
 	}
2494 2809
 
2495 2810
 	/**
@@ -2499,8 +2814,12 @@  discard block
 block discarded – undo
2499 2814
 	 */
2500 2815
 	function _checkDocumentStatusForOldVersion(&$obj)
2501 2816
 	{
2502
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2503
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2817
+		if(!$obj->status && $obj->is_secret == 'Y') {
2818
+			$obj->status = $this->getConfigStatus('secret');
2819
+		}
2820
+		if(!$obj->status && $obj->is_secret != 'Y') {
2821
+			$obj->status = $this->getConfigStatus('public');
2822
+		}
2504 2823
 	}
2505 2824
 
2506 2825
 	public function updateUploaedCount($documentSrlList)
Please login to merge, or discard this patch.
Spacing   +368 added lines, -368 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 		$trigger_obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count');
1131 1131
 		$trigger_obj->after_point = $trigger_obj->before_point + $point;
1132 1132
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'before', $trigger_obj);
1133
-		if(!$trigger_output->toBool())
1133
+		if (!$trigger_output->toBool())
1134 1134
 		{
1135 1135
 			return $trigger_output;
1136 1136
 		}
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		$oDB->begin();
1141 1141
 
1142 1142
 		// Update the voted count
1143
-		if($trigger_obj->update_target === 'blamed_count')
1143
+		if ($trigger_obj->update_target === 'blamed_count')
1144 1144
 		{
1145 1145
 			$args->blamed_count = $trigger_obj->after_point;
1146 1146
 			$output = executeQuery('document.updateBlamedCount', $args);
@@ -1150,16 +1150,16 @@  discard block
 block discarded – undo
1150 1150
 			$args->voted_count = $trigger_obj->after_point;
1151 1151
 			$output = executeQuery('document.updateVotedCount', $args);
1152 1152
 		}
1153
-		if(!$output->toBool()) return $output;
1153
+		if (!$output->toBool()) return $output;
1154 1154
 
1155 1155
 		// Leave logs
1156 1156
 		$args->point = $trigger_obj->point;
1157 1157
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1158
-		if(!$output->toBool()) return $output;
1158
+		if (!$output->toBool()) return $output;
1159 1159
 
1160 1160
 		// Call a trigger (after)
1161 1161
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj);
1162
-		if(!$trigger_output->toBool())
1162
+		if (!$trigger_output->toBool())
1163 1163
 		{
1164 1164
 			$oDB->rollback();
1165 1165
 			return $trigger_output;
@@ -1168,10 +1168,10 @@  discard block
 block discarded – undo
1168 1168
 		$oDB->commit();
1169 1169
 
1170 1170
 		$oCacheHandler = CacheHandler::getInstance('object');
1171
-		if($oCacheHandler->isSupport())
1171
+		if ($oCacheHandler->isSupport())
1172 1172
 		{
1173 1173
 			//remove document item from cache
1174
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1174
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1175 1175
 			$oCacheHandler->delete($cache_key);
1176 1176
 		}
1177 1177
 
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 
1181 1181
 		// Return result
1182 1182
 		$output = new BaseObject();
1183
-		if($trigger_obj->update_target === 'voted_count')
1183
+		if ($trigger_obj->update_target === 'voted_count')
1184 1184
 		{
1185 1185
 			$output->setMessage('success_voted');
1186 1186
 			$output->add('voted_count', $trigger_obj->after_point);
@@ -1202,13 +1202,13 @@  discard block
 block discarded – undo
1202 1202
 	function declaredDocument($document_srl)
1203 1203
 	{
1204 1204
 		// Fail if session information already has a reported document
1205
-		if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared');
1205
+		if ($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared');
1206 1206
 
1207 1207
 		// Check if previously reported
1208 1208
 		$args = new stdClass();
1209 1209
 		$args->document_srl = $document_srl;
1210 1210
 		$output = executeQuery('document.getDeclaredDocument', $args);
1211
-		if(!$output->toBool()) return $output;
1211
+		if (!$output->toBool()) return $output;
1212 1212
 
1213 1213
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1214 1214
 
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 
1219 1219
 		// Call a trigger (before)
1220 1220
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj);
1221
-		if(!$trigger_output->toBool())
1221
+		if (!$trigger_output->toBool())
1222 1222
 		{
1223 1223
 			return $trigger_output;
1224 1224
 		}
@@ -1228,19 +1228,19 @@  discard block
 block discarded – undo
1228 1228
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1229 1229
 
1230 1230
 		// Pass if the author's IP address is as same as visitor's.
1231
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1231
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1232 1232
 			$_SESSION['declared_document'][$document_srl] = true;
1233 1233
 			return new BaseObject(-1, 'failed_declared');
1234 1234
 		}
1235 1235
 
1236 1236
 		// Check if document's author is a member.
1237
-		if($oDocument->get('member_srl'))
1237
+		if ($oDocument->get('member_srl'))
1238 1238
 		{
1239 1239
 			// Create a member model object
1240 1240
 			$oMemberModel = getModel('member');
1241 1241
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1242 1242
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1243
-			if($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1243
+			if ($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1244 1244
 			{
1245 1245
 				$_SESSION['declared_document'][$document_srl] = true;
1246 1246
 				return new BaseObject(-1, 'failed_declared');
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 		// Use member_srl for logged-in members and IP address for non-members.
1251 1251
 		$args = new stdClass;
1252
-		if($member_srl)
1252
+		if ($member_srl)
1253 1253
 		{
1254 1254
 			$args->member_srl = $member_srl;
1255 1255
 		}
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 		$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
1263 1263
 
1264 1264
 		// Pass after registering a sesson if reported/declared documents are in the logs.
1265
-		if($output->data->count)
1265
+		if ($output->data->count)
1266 1266
 		{
1267 1267
 			$_SESSION['declared_document'][$document_srl] = true;
1268 1268
 			return new BaseObject(-1, 'failed_declared');
@@ -1273,23 +1273,23 @@  discard block
 block discarded – undo
1273 1273
 		$oDB->begin();
1274 1274
 
1275 1275
 		// Add the declared document
1276
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1276
+		if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1277 1277
 		else $output = executeQuery('document.insertDeclaredDocument', $args);
1278
-		if(!$output->toBool()) return $output;
1278
+		if (!$output->toBool()) return $output;
1279 1279
 		// Leave logs
1280 1280
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1281
-		if(!$output->toBool())
1281
+		if (!$output->toBool())
1282 1282
 		{
1283 1283
 			$oDB->rollback();
1284 1284
 			return $output;
1285 1285
 		}
1286 1286
 
1287
-		$this->add('declared_count', $declared_count+1);
1287
+		$this->add('declared_count', $declared_count + 1);
1288 1288
 
1289 1289
 		// Call a trigger (after)
1290 1290
 		$trigger_obj->declared_count = $declared_count + 1;
1291 1291
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj);
1292
-		if(!$trigger_output->toBool())
1292
+		if (!$trigger_output->toBool())
1293 1293
 		{
1294 1294
 			$oDB->rollback();
1295 1295
 			return $trigger_output;
@@ -1319,16 +1319,16 @@  discard block
 block discarded – undo
1319 1319
 		$args->document_srl = $document_srl;
1320 1320
 		$args->comment_count = $comment_count;
1321 1321
 
1322
-		if($comment_inserted)
1322
+		if ($comment_inserted)
1323 1323
 		{
1324
-			$args->update_order = -1*getNextSequence();
1324
+			$args->update_order = -1 * getNextSequence();
1325 1325
 			$args->last_updater = $last_updater;
1326 1326
 
1327 1327
 			$oCacheHandler = CacheHandler::getInstance('object');
1328
-			if($oCacheHandler->isSupport())
1328
+			if ($oCacheHandler->isSupport())
1329 1329
 			{
1330 1330
 				//remove document item from cache
1331
-				$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1331
+				$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1332 1332
 				$oCacheHandler->delete($cache_key);
1333 1333
 			}
1334 1334
 		}
@@ -1349,10 +1349,10 @@  discard block
 block discarded – undo
1349 1349
 		$args->trackback_count = $trackback_count;
1350 1350
 
1351 1351
 		$oCacheHandler = CacheHandler::getInstance('object');
1352
-		if($oCacheHandler->isSupport())
1352
+		if ($oCacheHandler->isSupport())
1353 1353
 		{
1354 1354
 			//remove document item from cache
1355
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1355
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1356 1356
 			$oCacheHandler->delete($cache_key);
1357 1357
 		}
1358 1358
 
@@ -1367,14 +1367,14 @@  discard block
 block discarded – undo
1367 1367
 	function insertCategory($obj)
1368 1368
 	{
1369 1369
 		// Sort the order to display if a child category is added
1370
-		if($obj->parent_srl)
1370
+		if ($obj->parent_srl)
1371 1371
 		{
1372 1372
 			// Get its parent category
1373 1373
 			$oDocumentModel = getModel('document');
1374 1374
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1375 1375
 			$obj->list_order = $parent_category->list_order;
1376
-			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1377
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1376
+			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1);
1377
+			if (!$obj->category_srl) $obj->category_srl = getNextSequence();
1378 1378
 		}
1379 1379
 		else
1380 1380
 		{
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 		}
1383 1383
 
1384 1384
 		$output = executeQuery('document.insertCategory', $obj);
1385
-		if($output->toBool())
1385
+		if ($output->toBool())
1386 1386
 		{
1387 1387
 			$output->add('category_srl', $obj->category_srl);
1388 1388
 			$this->makeCategoryFile($obj->module_srl);
@@ -1416,13 +1416,13 @@  discard block
 block discarded – undo
1416 1416
 	{
1417 1417
 		// Create a document model object
1418 1418
 		$oDocumentModel = getModel('document');
1419
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1419
+		if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl);
1420 1420
 
1421 1421
 		$args = new stdClass;
1422 1422
 		$args->category_srl = $category_srl;
1423 1423
 		$args->document_count = $document_count;
1424 1424
 		$output = executeQuery('document.updateCategoryCount', $args);
1425
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1425
+		if ($output->toBool()) $this->makeCategoryFile($module_srl);
1426 1426
 
1427 1427
 		return $output;
1428 1428
 	}
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 	function updateCategory($obj)
1436 1436
 	{
1437 1437
 		$output = executeQuery('document.updateCategory', $obj);
1438
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1438
+		if ($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1439 1439
 		return $output;
1440 1440
 	}
1441 1441
 
@@ -1452,32 +1452,32 @@  discard block
 block discarded – undo
1452 1452
 		$category_info = $oDocumentModel->getCategory($category_srl);
1453 1453
 		// Display an error that the category cannot be deleted if it has a child
1454 1454
 		$output = executeQuery('document.getChildCategoryCount', $args);
1455
-		if(!$output->toBool()) return $output;
1456
-		if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1455
+		if (!$output->toBool()) return $output;
1456
+		if ($output->data->count > 0) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1457 1457
 		// Delete a category information
1458 1458
 		$output = executeQuery('document.deleteCategory', $args);
1459
-		if(!$output->toBool()) return $output;
1459
+		if (!$output->toBool()) return $output;
1460 1460
 
1461 1461
 		$this->makeCategoryFile($category_info->module_srl);
1462 1462
 		// remvove cache
1463 1463
 		$oCacheHandler = CacheHandler::getInstance('object');
1464
-		if($oCacheHandler->isSupport())
1464
+		if ($oCacheHandler->isSupport())
1465 1465
 		{
1466 1466
 			$page = 0;
1467
-			while(true) {
1467
+			while (true) {
1468 1468
 				$args = new stdClass();
1469 1469
 				$args->category_srl = $category_srl;
1470 1470
 				$args->list_count = 100;
1471 1471
 				$args->page = ++$page;
1472 1472
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1473 1473
 
1474
-				if($output->data == array())
1474
+				if ($output->data == array())
1475 1475
 					break;
1476 1476
 
1477
-				foreach($output->data as $val)
1477
+				foreach ($output->data as $val)
1478 1478
 				{
1479 1479
 					//remove document item from cache
1480
-					$cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl;
1480
+					$cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl;
1481 1481
 					$oCacheHandler->delete($cache_key);
1482 1482
 				}
1483 1483
 			}
@@ -1524,18 +1524,18 @@  discard block
 block discarded – undo
1524 1524
 		// Seek a full list of categories
1525 1525
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1526 1526
 		$category_srl_list = array_keys($category_list);
1527
-		if(count($category_srl_list)<2) return new BaseObject();
1527
+		if (count($category_srl_list) < 2) return new BaseObject();
1528 1528
 
1529 1529
 		$prev_category = NULL;
1530
-		foreach($category_list as $key => $val)
1530
+		foreach ($category_list as $key => $val)
1531 1531
 		{
1532
-			if($key==$category_srl) break;
1532
+			if ($key == $category_srl) break;
1533 1533
 			$prev_category = $val;
1534 1534
 		}
1535 1535
 		// Return if the previous category doesn't exist
1536
-		if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1536
+		if (!$prev_category) return new BaseObject(-1, Context::getLang('msg_category_not_moved'));
1537 1537
 		// Return if the selected category is the top level
1538
-		if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1538
+		if ($category_srl_list[0] == $category_srl) return new BaseObject(-1, Context::getLang('msg_category_not_moved'));
1539 1539
 		// Information of the selected category
1540 1540
 		$cur_args = new stdClass;
1541 1541
 		$cur_args->category_srl = $category_srl;
@@ -1571,15 +1571,15 @@  discard block
 block discarded – undo
1571 1571
 		// Seek a full list of categories
1572 1572
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1573 1573
 		$category_srl_list = array_keys($category_list);
1574
-		if(count($category_srl_list)<2) return new BaseObject();
1574
+		if (count($category_srl_list) < 2) return new BaseObject();
1575 1575
 
1576
-		for($i=0;$i<count($category_srl_list);$i++)
1576
+		for ($i = 0; $i < count($category_srl_list); $i++)
1577 1577
 		{
1578
-			if($category_srl_list[$i]==$category_srl) break;
1578
+			if ($category_srl_list[$i] == $category_srl) break;
1579 1579
 		}
1580 1580
 
1581
-		$next_category_srl = $category_srl_list[$i+1];
1582
-		if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1581
+		$next_category_srl = $category_srl_list[$i + 1];
1582
+		if (!$category_list[$next_category_srl]) return new BaseObject(-1, Context::getLang('msg_category_not_moved'));
1583 1583
 		$next_category = $category_list[$next_category_srl];
1584 1584
 		// Information of the selected category
1585 1585
 		$cur_args = new stdClass;
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 	{
1607 1607
 		$oDocumentModel = getModel('document');
1608 1608
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1609
-		if(!count($extra_keys)) return;
1609
+		if (!count($extra_keys)) return;
1610 1610
 
1611 1611
 		$js_code = array();
1612 1612
 		$js_code[] = '<script>//<![CDATA[';
@@ -1616,16 +1616,16 @@  discard block
 block discarded – undo
1616 1616
 
1617 1617
 		$logged_info = Context::get('logged_info');
1618 1618
 
1619
-		foreach($extra_keys as $idx => $val)
1619
+		foreach ($extra_keys as $idx => $val)
1620 1620
 		{
1621 1621
 			$idx = $val->idx;
1622
-			if($val->type == 'kr_zip')
1622
+			if ($val->type == 'kr_zip')
1623 1623
 			{
1624 1624
 				$idx .= '[]';
1625 1625
 			}
1626 1626
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1627 1627
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1628
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1628
+			if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1629 1629
 		}
1630 1630
 
1631 1631
 		$js_code[] = '})(jQuery);';
@@ -1643,12 +1643,12 @@  discard block
 block discarded – undo
1643 1643
 	function procDocumentInsertCategory($args = null)
1644 1644
 	{
1645 1645
 		// List variables
1646
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1646
+		if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid');
1647 1647
 		$args->title = $args->category_title;
1648 1648
 		$args->description = $args->category_description;
1649 1649
 		$args->color = $args->category_color;
1650 1650
 
1651
-		if(!$args->module_srl && $args->mid)
1651
+		if (!$args->module_srl && $args->mid)
1652 1652
 		{
1653 1653
 			$mid = $args->mid;
1654 1654
 			unset($args->mid);
@@ -1659,28 +1659,28 @@  discard block
 block discarded – undo
1659 1659
 		$columnList = array('module_srl', 'module');
1660 1660
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1661 1661
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1662
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1662
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1663 1663
 
1664
-		if($args->expand !="Y") $args->expand = "N";
1665
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1664
+		if ($args->expand != "Y") $args->expand = "N";
1665
+		if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls);
1666 1666
 		else $args->group_srls = implode(',', $args->group_srls);
1667
-		$args->parent_srl = (int)$args->parent_srl;
1667
+		$args->parent_srl = (int) $args->parent_srl;
1668 1668
 
1669 1669
 		$oDocumentModel = getModel('document');
1670 1670
 
1671 1671
 		$oDB = &DB::getInstance();
1672 1672
 		$oDB->begin();
1673 1673
 		// Check if already exists
1674
-		if($args->category_srl)
1674
+		if ($args->category_srl)
1675 1675
 		{
1676 1676
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1677
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1677
+			if ($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1678 1678
 		}
1679 1679
 		// Update if exists
1680
-		if($args->category_srl)
1680
+		if ($args->category_srl)
1681 1681
 		{
1682 1682
 			$output = $this->updateCategory($args);
1683
-			if(!$output->toBool())
1683
+			if (!$output->toBool())
1684 1684
 			{
1685 1685
 				$oDB->rollback();
1686 1686
 				return $output;
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 		else
1691 1691
 		{
1692 1692
 			$output = $this->insertCategory($args);
1693
-			if(!$output->toBool())
1693
+			if (!$output->toBool())
1694 1694
 			{
1695 1695
 				$oDB->rollback();
1696 1696
 				return $output;
@@ -1729,11 +1729,11 @@  discard block
 block discarded – undo
1729 1729
 		$columnList = array('module_srl', 'module');
1730 1730
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1731 1731
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1732
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1732
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1733 1733
 
1734 1734
 		// First child of the parent_category_srl
1735 1735
 		$source_args = new stdClass;
1736
-		if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1736
+		if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1737 1737
 		{
1738 1738
 			$parent_category = $oDocumentModel->getCategory($parent_category_srl);
1739 1739
 
@@ -1742,30 +1742,30 @@  discard block
 block discarded – undo
1742 1742
 			$args->parent_srl = $parent_category_srl;
1743 1743
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1744 1744
 
1745
-			if(!$output->toBool()) return $output;
1746
-			$args->list_order = (int)$output->data->list_order;
1747
-			if(!$args->list_order) $args->list_order = 0;
1745
+			if (!$output->toBool()) return $output;
1746
+			$args->list_order = (int) $output->data->list_order;
1747
+			if (!$args->list_order) $args->list_order = 0;
1748 1748
 			$args->list_order--;
1749 1749
 
1750 1750
 			$source_args->category_srl = $source_category_srl;
1751 1751
 			$source_args->parent_srl = $parent_category_srl;
1752 1752
 			$source_args->list_order = $args->list_order;
1753 1753
 			$output = $this->updateCategory($source_args);
1754
-			if(!$output->toBool()) return $output;
1754
+			if (!$output->toBool()) return $output;
1755 1755
 			// Sibling of the $target_category_srl
1756 1756
 		}
1757
-		else if($target_category_srl > 0)
1757
+		else if ($target_category_srl > 0)
1758 1758
 		{
1759 1759
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1760 1760
 			// Move all siblings of the $target_category down
1761
-			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1762
-			if(!$output->toBool()) return $output;
1761
+			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1);
1762
+			if (!$output->toBool()) return $output;
1763 1763
 
1764 1764
 			$source_args->category_srl = $source_category_srl;
1765 1765
 			$source_args->parent_srl = $target_category->parent_srl;
1766
-			$source_args->list_order = $target_category->list_order+1;
1766
+			$source_args->list_order = $target_category->list_order + 1;
1767 1767
 			$output = $this->updateCategory($source_args);
1768
-			if(!$output->toBool()) return $output;
1768
+			if (!$output->toBool()) return $output;
1769 1769
 		}
1770 1770
 		// Re-generate the xml file
1771 1771
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
 	function procDocumentDeleteCategory()
1782 1782
 	{
1783 1783
 		// List variables
1784
-		$args = Context::gets('module_srl','category_srl');
1784
+		$args = Context::gets('module_srl', 'category_srl');
1785 1785
 
1786 1786
 		$oDB = &DB::getInstance();
1787 1787
 		$oDB->begin();
@@ -1790,17 +1790,17 @@  discard block
 block discarded – undo
1790 1790
 		$columnList = array('module_srl', 'module');
1791 1791
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1792 1792
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1793
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1793
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1794 1794
 
1795 1795
 		$oDocumentModel = getModel('document');
1796 1796
 		// Get original information
1797 1797
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1798
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1798
+		if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1799 1799
 		// Display an error that the category cannot be deleted if it has a child node
1800
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1800
+		if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1801 1801
 		// Remove from the DB
1802 1802
 		$output = $this->deleteCategory($args->category_srl);
1803
-		if(!$output->toBool())
1803
+		if (!$output->toBool())
1804 1804
 		{
1805 1805
 			$oDB->rollback();
1806 1806
 			return $output;
@@ -1831,11 +1831,11 @@  discard block
 block discarded – undo
1831 1831
 		$columnList = array('module_srl', 'module');
1832 1832
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1833 1833
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1834
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1834
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1835 1835
 
1836 1836
 		$xml_file = $this->makeCategoryFile($module_srl);
1837 1837
 		// Set return value
1838
-		$this->add('xml_file',$xml_file);
1838
+		$this->add('xml_file', $xml_file);
1839 1839
 	}
1840 1840
 
1841 1841
 	/**
@@ -1846,14 +1846,14 @@  discard block
 block discarded – undo
1846 1846
 	function makeCategoryFile($module_srl)
1847 1847
 	{
1848 1848
 		// Return if there is no information you need for creating a cache file
1849
-		if(!$module_srl) return false;
1849
+		if (!$module_srl) return false;
1850 1850
 		// Get module information (to obtain mid)
1851 1851
 		$oModuleModel = getModel('module');
1852 1852
 		$columnList = array('module_srl', 'mid', 'site_srl');
1853 1853
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1854 1854
 		$mid = $module_info->mid;
1855 1855
 
1856
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1856
+		if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1857 1857
 		// Cache file's name
1858 1858
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1859 1859
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1865,17 +1865,17 @@  discard block
 block discarded – undo
1865 1865
 
1866 1866
 		$category_list = $output->data;
1867 1867
 
1868
-		if(!is_array($category_list)) $category_list = array($category_list);
1868
+		if (!is_array($category_list)) $category_list = array($category_list);
1869 1869
 
1870 1870
 		$category_count = count($category_list);
1871
-		for($i=0;$i<$category_count;$i++)
1871
+		for ($i = 0; $i < $category_count; $i++)
1872 1872
 		{
1873 1873
 			$category_srl = $category_list[$i]->category_srl;
1874
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1874
+			if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1875 1875
 			$list[$category_srl] = $category_list[$i];
1876 1876
 		}
1877 1877
 		// Create the xml file without node data if no data is obtained
1878
-		if(!$list)
1878
+		if (!$list)
1879 1879
 		{
1880 1880
 			$xml_buff = "<root />";
1881 1881
 			FileHandler::writeFile($xml_file, $xml_buff);
@@ -1883,12 +1883,12 @@  discard block
 block discarded – undo
1883 1883
 			return $xml_file;
1884 1884
 		}
1885 1885
 		// Change to an array if only a single data is obtained
1886
-		if(!is_array($list)) $list = array($list);
1886
+		if (!is_array($list)) $list = array($list);
1887 1887
 		// Create a tree for loop
1888
-		foreach($list as $category_srl => $node)
1888
+		foreach ($list as $category_srl => $node)
1889 1889
 		{
1890 1890
 			$node->mid = $mid;
1891
-			$parent_srl = (int)$node->parent_srl;
1891
+			$parent_srl = (int) $node->parent_srl;
1892 1892
 			$tree[$parent_srl][$category_srl] = $node;
1893 1893
 		}
1894 1894
 		// A common header to set permissions and groups of the cache file
@@ -1962,13 +1962,13 @@  discard block
 block discarded – undo
1962 1962
 	 */
1963 1963
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1964 1964
 	{
1965
-		if(!$source_node) return;
1965
+		if (!$source_node) return;
1966 1966
 
1967
-		foreach($source_node as $category_srl => $node)
1967
+		foreach ($source_node as $category_srl => $node)
1968 1968
 		{
1969 1969
 			$child_buff = "";
1970 1970
 			// Get data of the child nodes
1971
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1971
+			if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1972 1972
 			// List variables
1973 1973
 			$expand = ($node->expand) ? $node->expand : 'N';
1974 1974
 			$group_srls = ($node->group_srls) ? $node->group_srls : '';
@@ -1978,27 +1978,27 @@  discard block
 block discarded – undo
1978 1978
 			$color = ($node->color) ? $node->color : '';
1979 1979
 			$description = ($node->description) ? $node->description : '';
1980 1980
 			// If node->group_srls value exists
1981
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1981
+			if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls);
1982 1982
 			else $group_check_code = "true";
1983 1983
 
1984 1984
 			$title = $node->title;
1985 1985
 			$oModuleAdminModel = getAdminModel('module');
1986 1986
 
1987 1987
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
1988
-			if(count($langs))
1988
+			if (count($langs))
1989 1989
 			{
1990
-				foreach($langs as $key => $val)
1990
+				foreach ($langs as $key => $val)
1991 1991
 				{
1992
-					$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));
1992
+					$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));
1993 1993
 				}
1994 1994
 			}
1995 1995
 
1996 1996
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
1997
-			if(count($langx))
1997
+			if (count($langx))
1998 1998
 			{
1999
-				foreach($langx as $key => $val)
1999
+				foreach ($langx as $key => $val)
2000 2000
 				{
2001
-					$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));
2001
+					$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));
2002 2002
 				}
2003 2003
 			}
2004 2004
 
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
 				$category_srl,
2012 2012
 				$group_check_code,
2013 2013
 				$category_srl,
2014
-				var_export(getUrl('','mid',$node->mid,'category',$category_srl), true),
2014
+				var_export(getUrl('', 'mid', $node->mid, 'category', $category_srl), true),
2015 2015
 				var_export($expand, true),
2016 2016
 				var_export($color, true),
2017 2017
 				$group_check_code,
@@ -2019,8 +2019,8 @@  discard block
 block discarded – undo
2019 2019
 				$node->document_count
2020 2020
 			);
2021 2021
 
2022
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2023
-			else $buff .=  sprintf('<node %s />', $attribute);
2022
+			if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2023
+			else $buff .= sprintf('<node %s />', $attribute);
2024 2024
 		}
2025 2025
 		return $buff;
2026 2026
 	}
@@ -2039,13 +2039,13 @@  discard block
 block discarded – undo
2039 2039
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2040 2040
 	{
2041 2041
 		$output = array("buff"=>"", "category_srl_list"=>array());
2042
-		if(!$source_node) return $output;
2042
+		if (!$source_node) return $output;
2043 2043
 
2044 2044
 		// Set to an arraty for looping and then generate php script codes to be included
2045
-		foreach($source_node as $category_srl => $node)
2045
+		foreach ($source_node as $category_srl => $node)
2046 2046
 		{
2047 2047
 			// Get data from child nodes first if exist.
2048
-			if($category_srl && $tree[$category_srl]){
2048
+			if ($category_srl && $tree[$category_srl]) {
2049 2049
 				$child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff);
2050 2050
 			} else {
2051 2051
 				$child_output = array("buff"=>"", "category_srl_list"=>array());
@@ -2056,14 +2056,14 @@  discard block
 block discarded – undo
2056 2056
 			$output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']);
2057 2057
 
2058 2058
 			// If node->group_srls value exists
2059
-			if($node->group_srls) {
2060
-				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls);
2059
+			if ($node->group_srls) {
2060
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls);
2061 2061
 			} else {
2062 2062
 				$group_check_code = "true";
2063 2063
 			}
2064 2064
 
2065 2065
 			// List variables
2066
-			$selected = '"' . implode('","', $child_output['category_srl_list']) . '"';
2066
+			$selected = '"'.implode('","', $child_output['category_srl_list']).'"';
2067 2067
 			$child_buff = $child_output['buff'];
2068 2068
 			$expand = $node->expand;
2069 2069
 
@@ -2072,32 +2072,32 @@  discard block
 block discarded – undo
2072 2072
 			$oModuleAdminModel = getAdminModel('module');
2073 2073
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
2074 2074
 
2075
-			if(count($langs))
2075
+			if (count($langs))
2076 2076
 			{
2077
-				foreach($langs as $key => $val)
2077
+				foreach ($langs as $key => $val)
2078 2078
 				{
2079 2079
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2080 2080
 					$php_header_buff .= sprintf(
2081 2081
 						'$_titles[%d]["%s"] = %s; ',
2082 2082
 						$category_srl,
2083 2083
 						$key,
2084
-						var_export(str_replace('"','\\"', $val), true)
2084
+						var_export(str_replace('"', '\\"', $val), true)
2085 2085
 					);
2086 2086
 				}
2087 2087
 			}
2088 2088
 
2089 2089
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2090 2090
 
2091
-			if(count($langx))
2091
+			if (count($langx))
2092 2092
 			{
2093
-				foreach($langx as $key => $val)
2093
+				foreach ($langx as $key => $val)
2094 2094
 				{
2095 2095
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2096 2096
 					$php_header_buff .= sprintf(
2097 2097
 						'$_descriptions[%d]["%s"] = %s; ',
2098 2098
 						$category_srl,
2099 2099
 						$key,
2100
-						var_export(str_replace('"','\\"', $val), true)
2100
+						var_export(str_replace('"', '\\"', $val), true)
2101 2101
 					);
2102 2102
 				}
2103 2103
 			}
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 			);
2122 2122
 
2123 2123
 			// Generate buff data
2124
-			$output['buff'] .=  sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2124
+			$output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2125 2125
 		}
2126 2126
 
2127 2127
 		return $output;
@@ -2138,7 +2138,7 @@  discard block
 block discarded – undo
2138 2138
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2139 2139
 	{
2140 2140
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2141
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2141
+		if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2142 2142
 
2143 2143
 		$obj = new stdClass();
2144 2144
 		$obj->url = $url;
@@ -2156,68 +2156,68 @@  discard block
 block discarded – undo
2156 2156
 	 */
2157 2157
 	function procDocumentAddCart()
2158 2158
 	{
2159
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2159
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2160 2160
 
2161 2161
 		// Get document_srl
2162
-		$srls = explode(',',Context::get('srls'));
2163
-		for($i = 0; $i < count($srls); $i++)
2162
+		$srls = explode(',', Context::get('srls'));
2163
+		for ($i = 0; $i < count($srls); $i++)
2164 2164
 		{
2165 2165
 			$srl = trim($srls[$i]);
2166 2166
 
2167
-			if(!$srl) continue;
2167
+			if (!$srl) continue;
2168 2168
 
2169 2169
 			$document_srls[] = $srl;
2170 2170
 		}
2171
-		if(!count($document_srls)) return;
2171
+		if (!count($document_srls)) return;
2172 2172
 
2173 2173
 		// Get module_srl of the documents
2174 2174
 		$args = new stdClass;
2175 2175
 		$args->list_count = count($document_srls);
2176
-		$args->document_srls = implode(',',$document_srls);
2176
+		$args->document_srls = implode(',', $document_srls);
2177 2177
 		$args->order_type = 'asc';
2178 2178
 		$output = executeQueryArray('document.getDocuments', $args);
2179
-		if(!$output->data) return new BaseObject();
2179
+		if (!$output->data) return new BaseObject();
2180 2180
 
2181 2181
 		unset($document_srls);
2182
-		foreach($output->data as $key => $val)
2182
+		foreach ($output->data as $key => $val)
2183 2183
 		{
2184 2184
 			$document_srls[$val->module_srl][] = $val->document_srl;
2185 2185
 		}
2186
-		if(!$document_srls || !count($document_srls)) return new BaseObject();
2186
+		if (!$document_srls || !count($document_srls)) return new BaseObject();
2187 2187
 
2188 2188
 		// 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)
2189 2189
 		$oModuleModel = getModel('module');
2190 2190
 		$module_srls = array_keys($document_srls);
2191
-		for($i=0;$i<count($module_srls);$i++)
2191
+		for ($i = 0; $i < count($module_srls); $i++)
2192 2192
 		{
2193 2193
 			$module_srl = $module_srls[$i];
2194 2194
 			$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
2195 2195
 			$logged_info = Context::get('logged_info');
2196
-			if($logged_info->is_admin != 'Y')
2196
+			if ($logged_info->is_admin != 'Y')
2197 2197
 			{
2198
-				if(!$module_info)
2198
+				if (!$module_info)
2199 2199
 				{
2200 2200
 					unset($document_srls[$module_srl]);
2201 2201
 					continue;
2202 2202
 				}
2203 2203
 				$grant = $oModuleModel->getGrant($module_info, $logged_info);
2204
-				if(!$grant->manager)
2204
+				if (!$grant->manager)
2205 2205
 				{
2206 2206
 					unset($document_srls[$module_srl]);
2207 2207
 					continue;
2208 2208
 				}
2209 2209
 			}
2210 2210
 		}
2211
-		if(!count($document_srls)) return new BaseObject();
2211
+		if (!count($document_srls)) return new BaseObject();
2212 2212
 
2213
-		foreach($document_srls as $module_srl => $documents)
2213
+		foreach ($document_srls as $module_srl => $documents)
2214 2214
 		{
2215 2215
 			$cnt = count($documents);
2216
-			for($i=0;$i<$cnt;$i++)
2216
+			for ($i = 0; $i < $cnt; $i++)
2217 2217
 			{
2218
-				$document_srl = (int)trim($documents[$i]);
2219
-				if(!$document_srls) continue;
2220
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2218
+				$document_srl = (int) trim($documents[$i]);
2219
+				if (!$document_srls) continue;
2220
+				if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2221 2221
 				else $_SESSION['document_management'][$document_srl] = true;
2222 2222
 			}
2223 2223
 		}
@@ -2230,9 +2230,9 @@  discard block
 block discarded – undo
2230 2230
 	function procDocumentManageCheckedDocument()
2231 2231
 	{
2232 2232
 		@set_time_limit(0);
2233
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2233
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2234 2234
 
2235
-		if(!checkCSRF())
2235
+		if (!checkCSRF())
2236 2236
 		{
2237 2237
 			return new BaseObject(-1, 'msg_invalid_request');
2238 2238
 		}
@@ -2240,44 +2240,44 @@  discard block
 block discarded – undo
2240 2240
 		$type = Context::get('type');
2241 2241
 		$target_module = Context::get('target_module');
2242 2242
 		$module_srl = Context::get('module_srl');
2243
-		if($target_module && !$module_srl) $module_srl = $target_module;
2243
+		if ($target_module && !$module_srl) $module_srl = $target_module;
2244 2244
 		$category_srl = Context::get('target_category');
2245 2245
 		$message_content = Context::get('message_content');
2246
-		if($message_content) $message_content = nl2br($message_content);
2246
+		if ($message_content) $message_content = nl2br($message_content);
2247 2247
 
2248 2248
 		$cart = Context::get('cart');
2249
-		if(!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2249
+		if (!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2250 2250
 		else $document_srl_list = $cart;
2251 2251
 
2252 2252
 		$document_srl_count = count($document_srl_list);
2253 2253
 
2254 2254
 		$oDocumentModel = getModel('document');
2255 2255
 		$document_items = array();
2256
-		foreach($document_srl_list as $document_srl)
2256
+		foreach ($document_srl_list as $document_srl)
2257 2257
 		{
2258 2258
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2259 2259
 			$document_items[] = $oDocument;
2260
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2260
+			if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2261 2261
 		}
2262 2262
 
2263 2263
 		// Send a message
2264
-		if($message_content)
2264
+		if ($message_content)
2265 2265
 		{
2266 2266
 
2267 2267
 			$oCommunicationController = getController('communication');
2268 2268
 
2269 2269
 			$logged_info = Context::get('logged_info');
2270 2270
 
2271
-			$title = cut_str($message_content,10,'...');
2271
+			$title = cut_str($message_content, 10, '...');
2272 2272
 			$sender_member_srl = $logged_info->member_srl;
2273 2273
 
2274
-			foreach($document_items as $oDocument)
2274
+			foreach ($document_items as $oDocument)
2275 2275
 			{
2276
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2276
+				if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue;
2277 2277
 
2278
-				if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2278
+				if ($type == 'move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2279 2279
 				else $purl = "";
2280
-				$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));
2280
+				$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));
2281 2281
 
2282 2282
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
2283 2283
 			}
@@ -2287,54 +2287,54 @@  discard block
 block discarded – undo
2287 2287
 		$oSpamController->setAvoidLog();
2288 2288
 
2289 2289
 		$oDocumentAdminController = getAdminController('document');
2290
-		if($type == 'move')
2290
+		if ($type == 'move')
2291 2291
 		{
2292
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2292
+			if (!$module_srl) return new BaseObject(-1, 'fail_to_move');
2293 2293
 
2294 2294
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2295
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2295
+			if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2296 2296
 
2297 2297
 			$msg_code = 'success_moved';
2298 2298
 
2299 2299
 		}
2300
-		else if($type == 'copy')
2300
+		else if ($type == 'copy')
2301 2301
 		{
2302
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2302
+			if (!$module_srl) return new BaseObject(-1, 'fail_to_move');
2303 2303
 
2304 2304
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2305
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2305
+			if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2306 2306
 
2307 2307
 			$msg_code = 'success_copied';
2308 2308
 		}
2309
-		else if($type =='delete')
2309
+		else if ($type == 'delete')
2310 2310
 		{
2311 2311
 			$oDB = &DB::getInstance();
2312 2312
 			$oDB->begin();
2313
-			for($i=0;$i<$document_srl_count;$i++)
2313
+			for ($i = 0; $i < $document_srl_count; $i++)
2314 2314
 			{
2315 2315
 				$document_srl = $document_srl_list[$i];
2316 2316
 				$output = $this->deleteDocument($document_srl, true);
2317
-				if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete');
2317
+				if (!$output->toBool()) return new BaseObject(-1, 'fail_to_delete');
2318 2318
 			}
2319 2319
 			$oDB->commit();
2320 2320
 			$msg_code = 'success_deleted';
2321 2321
 		}
2322
-		else if($type == 'trash')
2322
+		else if ($type == 'trash')
2323 2323
 		{
2324 2324
 			$args = new stdClass();
2325 2325
 			$args->description = $message_content;
2326 2326
 
2327 2327
 			$oDB = &DB::getInstance();
2328 2328
 			$oDB->begin();
2329
-			for($i=0;$i<$document_srl_count;$i++) {
2329
+			for ($i = 0; $i < $document_srl_count; $i++) {
2330 2330
 				$args->document_srl = $document_srl_list[$i];
2331 2331
 				$output = $this->moveDocumentToTrash($args);
2332
-				if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash');
2332
+				if (!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash');
2333 2333
 			}
2334 2334
 			$oDB->commit();
2335 2335
 			$msg_code = 'success_trashed';
2336 2336
 		}
2337
-		else if($type == 'cancelDeclare')
2337
+		else if ($type == 'cancelDeclare')
2338 2338
 		{
2339 2339
 			$args->document_srl = $document_srl_list;
2340 2340
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2356,27 +2356,27 @@  discard block
 block discarded – undo
2356 2356
 	function procDocumentInsertModuleConfig()
2357 2357
 	{
2358 2358
 		$module_srl = Context::get('target_module_srl');
2359
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2359
+		if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl);
2360 2360
 		else $module_srl = array($module_srl);
2361 2361
 
2362 2362
 		$document_config = new stdClass();
2363 2363
 		$document_config->use_history = Context::get('use_history');
2364
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2364
+		if (!$document_config->use_history) $document_config->use_history = 'N';
2365 2365
 
2366 2366
 		$document_config->use_vote_up = Context::get('use_vote_up');
2367
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2367
+		if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2368 2368
 
2369 2369
 		$document_config->use_vote_down = Context::get('use_vote_down');
2370
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2370
+		if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2371 2371
 
2372 2372
 		$document_config->use_status = Context::get('use_status');
2373 2373
 
2374 2374
 		$oModuleController = getController('module');
2375
-		for($i=0;$i<count($module_srl);$i++)
2375
+		for ($i = 0; $i < count($module_srl); $i++)
2376 2376
 		{
2377 2377
 			$srl = trim($module_srl[$i]);
2378
-			if(!$srl) continue;
2379
-			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2378
+			if (!$srl) continue;
2379
+			$output = $oModuleController->insertModulePartConfig('document', $srl, $document_config);
2380 2380
 		}
2381 2381
 		$this->setError(-1);
2382 2382
 		$this->setMessage('success_updated', 'info');
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
 	function procDocumentTempSave()
2393 2393
 	{
2394 2394
 		// Check login information
2395
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged');
2395
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged');
2396 2396
 		$module_info = Context::get('module_info');
2397 2397
 		$logged_info = Context::get('logged_info');
2398 2398
 
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
 		unset($obj->is_notice);
2405 2405
 
2406 2406
 		// Extract from beginning part of contents in the guestbook
2407
-		if(!$obj->title)
2407
+		if (!$obj->title)
2408 2408
 		{
2409 2409
 			$obj->title = cut_str(strip_tags($obj->content), 20, '...');
2410 2410
 		}
@@ -2415,13 +2415,13 @@  discard block
 block discarded – undo
2415 2415
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2416 2416
 
2417 2417
 		// Update if already exists
2418
-		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2418
+		if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2419 2419
 		{
2420
-			if($oDocument->get('module_srl') != $obj->module_srl)
2420
+			if ($oDocument->get('module_srl') != $obj->module_srl)
2421 2421
 			{
2422 2422
 				return new BaseObject(-1, 'msg_invalid_request');
2423 2423
 			}
2424
-			if(!$oDocument->isGranted())
2424
+			if (!$oDocument->isGranted())
2425 2425
 			{
2426 2426
 				return new BaseObject(-1, 'msg_invalid_request');
2427 2427
 			}
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
 			$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2440 2440
 		}
2441 2441
 		// Set the attachment to be invalid state
2442
-		if($oDocument->hasUploadedFiles())
2442
+		if ($oDocument->hasUploadedFiles())
2443 2443
 		{
2444 2444
 			$args = new stdClass;
2445 2445
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -2457,11 +2457,11 @@  discard block
 block discarded – undo
2457 2457
 	 */
2458 2458
 	function procDocumentGetList()
2459 2459
 	{
2460
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2460
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2461 2461
 		$documentSrls = Context::get('document_srls');
2462
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2462
+		if ($documentSrls) $documentSrlList = explode(',', $documentSrls);
2463 2463
 
2464
-		if(count($documentSrlList) > 0)
2464
+		if (count($documentSrlList) > 0)
2465 2465
 		{
2466 2466
 			$oDocumentModel = getModel('document');
2467 2467
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
@@ -2485,10 +2485,10 @@  discard block
 block discarded – undo
2485 2485
 	 */
2486 2486
 	function _checkCommentStatusForOldVersion(&$obj)
2487 2487
 	{
2488
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2489
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2488
+		if (!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2489
+		if (!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2490 2490
 
2491
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2491
+		if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2492 2492
 		else $obj->commentStatus = 'DENY';
2493 2493
 	}
2494 2494
 
@@ -2499,8 +2499,8 @@  discard block
 block discarded – undo
2499 2499
 	 */
2500 2500
 	function _checkDocumentStatusForOldVersion(&$obj)
2501 2501
 	{
2502
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2503
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2502
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2503
+		if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2504 2504
 	}
2505 2505
 
2506 2506
 	public function updateUploaedCount($documentSrlList)
@@ -2508,10 +2508,10 @@  discard block
 block discarded – undo
2508 2508
 		$oDocumentModel = getModel('document');
2509 2509
 		$oFileModel = getModel('file');
2510 2510
 
2511
-		if(is_array($documentSrlList))
2511
+		if (is_array($documentSrlList))
2512 2512
 		{
2513 2513
 			$documentSrlList = array_unique($documentSrlList);
2514
-			foreach($documentSrlList AS $key => $documentSrl)
2514
+			foreach ($documentSrlList AS $key => $documentSrl)
2515 2515
 			{
2516 2516
 				$fileCount = $oFileModel->getFilesCount($documentSrl);
2517 2517
 				$args = new stdClass();
@@ -2532,14 +2532,14 @@  discard block
 block discarded – undo
2532 2532
 		$oDocumentModel = getModel('document');
2533 2533
 		$documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl);
2534 2534
 
2535
-		if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2535
+		if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2536 2536
 		{
2537
-			$oDocumentController=getController('document');
2538
-			foreach($obj->moduleSrlList AS $key=>$value)
2537
+			$oDocumentController = getController('document');
2538
+			foreach ($obj->moduleSrlList AS $key=>$value)
2539 2539
 			{
2540
-				foreach($documentExtraKeys AS $extraItem)
2540
+				foreach ($documentExtraKeys AS $extraItem)
2541 2541
 				{
2542
-					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ;
2542
+					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid);
2543 2543
 				}
2544 2544
 			}
2545 2545
 		}
@@ -2551,9 +2551,9 @@  discard block
 block discarded – undo
2551 2551
 		$documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl);
2552 2552
 
2553 2553
 		$oModuleController = getController('module');
2554
-		if(is_array($obj->moduleSrlList))
2554
+		if (is_array($obj->moduleSrlList))
2555 2555
 		{
2556
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
2556
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
2557 2557
 			{
2558 2558
 				$oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig);
2559 2559
 			}
Please login to merge, or discard this patch.
modules/comment/comment.controller.php 2 patches
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	function procCommentVoteUp()
29 29
 	{
30
-		if(!Context::get('is_logged'))
30
+		if (!Context::get('is_logged'))
31 31
 		{
32 32
 			return new BaseObject(-1, 'msg_invalid_request');
33 33
 		}
34 34
 
35 35
 		$comment_srl = Context::get('target_srl');
36
-		if(!$comment_srl)
36
+		if (!$comment_srl)
37 37
 		{
38 38
 			return new BaseObject(-1, 'msg_invalid_request');
39 39
 		}
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 		$oCommentModel = getModel('comment');
42 42
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
43 43
 		$module_srl = $oComment->get('module_srl');
44
-		if(!$module_srl)
44
+		if (!$module_srl)
45 45
 		{
46 46
 			return new BaseObject(-1, 'msg_invalid_request');
47 47
 		}
48 48
 
49 49
 		$oModuleModel = getModel('module');
50 50
 		$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl);
51
-		if($comment_config->use_vote_up == 'N')
51
+		if ($comment_config->use_vote_up == 'N')
52 52
 		{
53 53
 			return new BaseObject(-1, 'msg_invalid_request');
54 54
 		}
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	function procCommentVoteDown()
67 67
 	{
68
-		if(!Context::get('is_logged'))
68
+		if (!Context::get('is_logged'))
69 69
 		{
70 70
 			return new BaseObject(-1, 'msg_invalid_request');
71 71
 		}
72 72
 
73 73
 		$comment_srl = Context::get('target_srl');
74
-		if(!$comment_srl)
74
+		if (!$comment_srl)
75 75
 		{
76 76
 			return new BaseObject(-1, 'msg_invalid_request');
77 77
 		}
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		$oCommentModel = getModel('comment');
80 80
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
81 81
 		$module_srl = $oComment->get('module_srl');
82
-		if(!$module_srl)
82
+		if (!$module_srl)
83 83
 		{
84 84
 			return new BaseObject(-1, 'msg_invalid_request');
85 85
 		}
86 86
 
87 87
 		$oModuleModel = getModel('module');
88 88
 		$comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl);
89
-		if($comment_config->use_vote_down == 'N')
89
+		if ($comment_config->use_vote_down == 'N')
90 90
 		{
91 91
 			return new BaseObject(-1, 'msg_invalid_request');
92 92
 		}
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	function procCommentDeclare()
105 105
 	{
106
-		if(!Context::get('is_logged'))
106
+		if (!Context::get('is_logged'))
107 107
 		{
108 108
 			return new BaseObject(-1, 'msg_invalid_request');
109 109
 		}
110 110
 
111 111
 		$comment_srl = Context::get('target_srl');
112
-		if(!$comment_srl)
112
+		if (!$comment_srl)
113 113
 		{
114 114
 			return new BaseObject(-1, 'msg_invalid_request');
115 115
 		}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	function triggerDeleteDocumentComments(&$obj)
125 125
 	{
126 126
 		$document_srl = $obj->document_srl;
127
-		if(!$document_srl)
127
+		if (!$document_srl)
128 128
 		{
129 129
 			return new BaseObject();
130 130
 		}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	function triggerDeleteModuleComments(&$obj)
140 140
 	{
141 141
 		$module_srl = $obj->module_srl;
142
-		if(!$module_srl)
142
+		if (!$module_srl)
143 143
 		{
144 144
 			return new BaseObject();
145 145
 		}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	function isModuleUsingPublishValidation($module_srl = NULL)
168 168
 	{
169
-		if($module_srl == NULL)
169
+		if ($module_srl == NULL)
170 170
 		{
171 171
 			return FALSE;
172 172
 		}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
176 176
 		$module_part_config = $oModuleModel->getModulePartConfig('comment', $module_info->module_srl);
177 177
 		$use_validation = FALSE;
178
-		if(isset($module_part_config->use_comment_validation) && $module_part_config->use_comment_validation == "Y")
178
+		if (isset($module_part_config->use_comment_validation) && $module_part_config->use_comment_validation == "Y")
179 179
 		{
180 180
 			$use_validation = TRUE;
181 181
 		}
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	function insertComment($obj, $manual_inserted = FALSE)
192 192
 	{
193
-		if(!$manual_inserted && !checkCSRF())
193
+		if (!$manual_inserted && !checkCSRF())
194 194
 		{
195 195
 			return new BaseObject(-1, 'msg_invalid_request');
196 196
 		}
197 197
 
198
-		if(!is_object($obj))
198
+		if (!is_object($obj))
199 199
 		{
200 200
 			$obj = new stdClass();
201 201
 		}
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 		// check if comment's module is using comment validation and set the publish status to 0 (false)
204 204
 		// for inserting query, otherwise default is 1 (true - means comment is published)
205 205
 		$using_validation = $this->isModuleUsingPublishValidation($obj->module_srl);
206
-		if(!$manual_inserted)
206
+		if (!$manual_inserted)
207 207
 		{
208
-			if(Context::get('is_logged'))
208
+			if (Context::get('is_logged'))
209 209
 			{
210 210
 				$logged_info = Context::get('logged_info');
211
-				if($logged_info->is_admin == 'Y')
211
+				if ($logged_info->is_admin == 'Y')
212 212
 				{
213 213
 					$is_admin = TRUE;
214 214
 				}
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 			$is_admin = FALSE;
224 224
 		}
225 225
 
226
-		if(!$using_validation)
226
+		if (!$using_validation)
227 227
 		{
228 228
 			$obj->status = 1;
229 229
 		}
230 230
 		else
231 231
 		{
232
-			if($is_admin)
232
+			if ($is_admin)
233 233
 			{
234 234
 				$obj->status = 1;
235 235
 			}
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 
243 243
 		// call a trigger (before)
244 244
 		$output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj);
245
-		if(!$output->toBool())
245
+		if (!$output->toBool())
246 246
 		{
247 247
 			return $output;
248 248
 		}
249 249
 
250 250
 		// check if a posting of the corresponding document_srl exists
251 251
 		$document_srl = $obj->document_srl;
252
-		if(!$document_srl)
252
+		if (!$document_srl)
253 253
 		{
254 254
 			return new BaseObject(-1, 'msg_invalid_document');
255 255
 		}
@@ -258,36 +258,36 @@  discard block
 block discarded – undo
258 258
 		$oDocumentModel = getModel('document');
259 259
 
260 260
 		// even for manual_inserted if password exists, hash it.
261
-		if($obj->password)
261
+		if ($obj->password)
262 262
 		{
263 263
 			$obj->password = getModel('member')->hashPassword($obj->password);
264 264
 		}
265 265
 
266 266
 		// get the original posting
267
-		if(!$manual_inserted)
267
+		if (!$manual_inserted)
268 268
 		{
269 269
 			$oDocument = $oDocumentModel->getDocument($document_srl);
270 270
 
271
-			if($document_srl != $oDocument->document_srl)
271
+			if ($document_srl != $oDocument->document_srl)
272 272
 			{
273 273
 				return new BaseObject(-1, 'msg_invalid_document');
274 274
 			}
275
-			if($oDocument->isLocked())
275
+			if ($oDocument->isLocked())
276 276
 			{
277 277
 				return new BaseObject(-1, 'msg_invalid_request');
278 278
 			}
279 279
 
280
-			if($obj->homepage)
280
+			if ($obj->homepage)
281 281
 			{
282 282
 				$obj->homepage = removeHackTag($obj->homepage);
283
-				if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
283
+				if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
284 284
 				{
285 285
 					$obj->homepage = 'http://'.$obj->homepage;
286 286
 				}
287 287
 			}
288 288
 
289 289
 			// input the member's information if logged-in
290
-			if(Context::get('is_logged'))
290
+			if (Context::get('is_logged'))
291 291
 			{
292 292
 				$logged_info = Context::get('logged_info');
293 293
 				$obj->member_srl = $logged_info->member_srl;
@@ -302,16 +302,16 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 
304 304
 		// error display if neither of log-in info and user name exist.
305
-		if(!$logged_info->member_srl && !$obj->nick_name)
305
+		if (!$logged_info->member_srl && !$obj->nick_name)
306 306
 		{
307 307
 			return new BaseObject(-1, 'msg_invalid_request');
308 308
 		}
309 309
 
310
-		if(!$obj->comment_srl)
310
+		if (!$obj->comment_srl)
311 311
 		{
312 312
 			$obj->comment_srl = getNextSequence();
313 313
 		}
314
-		elseif(!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) 
314
+		elseif (!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) 
315 315
 		{
316 316
 			return new BaseObject(-1, 'msg_not_permitted');
317 317
 		}
@@ -322,32 +322,32 @@  discard block
 block discarded – undo
322 322
 		// remove XE's own tags from the contents
323 323
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
324 324
 
325
-		if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
325
+		if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
326 326
 		{
327
-			if($obj->use_html != 'Y')
327
+			if ($obj->use_html != 'Y')
328 328
 			{
329 329
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
330 330
 			}
331 331
 			$obj->content = nl2br($obj->content);
332 332
 		}
333 333
 
334
-		if(!$obj->regdate)
334
+		if (!$obj->regdate)
335 335
 		{
336 336
 			$obj->regdate = date("YmdHis");
337 337
 		}
338 338
 
339 339
 		// remove iframe and script if not a top administrator on the session.
340
-		if($logged_info->is_admin != 'Y')
340
+		if ($logged_info->is_admin != 'Y')
341 341
 		{
342 342
 			$obj->content = removeHackTag($obj->content);
343 343
 		}
344 344
 
345
-		if(!$obj->notify_message)
345
+		if (!$obj->notify_message)
346 346
 		{
347 347
 			$obj->notify_message = 'N';
348 348
 		}
349 349
 
350
-		if(!$obj->is_secret)
350
+		if (!$obj->is_secret)
351 351
 		{
352 352
 			$obj->is_secret = 'N';
353 353
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		$list_args->regdate = $obj->regdate;
365 365
 
366 366
 		// If parent comment doesn't exist, set data directly
367
-		if(!$obj->parent_srl)
367
+		if (!$obj->parent_srl)
368 368
 		{
369 369
 			$list_args->head = $list_args->arrange = $obj->comment_srl;
370 370
 			$list_args->depth = 0;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
379 379
 
380 380
 			// return if no parent comment exists
381
-			if(!$parent_output->toBool() || !$parent_output->data)
381
+			if (!$parent_output->toBool() || !$parent_output->data)
382 382
 			{
383 383
 				return;
384 384
 			}
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 			$list_args->depth = $parent->depth + 1;
390 390
 
391 391
 			// if the depth of comments is less than 2, execute insert.
392
-			if($list_args->depth < 2)
392
+			if ($list_args->depth < 2)
393 393
 			{
394 394
 				$list_args->arrange = $obj->comment_srl;
395 395
 				// if the depth of comments is greater than 2, execute update.
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				$p_args->depth = $parent->depth;
404 404
 				$output = executeQuery('comment.getCommentParentNextSibling', $p_args);
405 405
 
406
-				if($output->data->arrange)
406
+				if ($output->data->arrange)
407 407
 				{
408 408
 					$list_args->arrange = $output->data->arrange;
409 409
 					$output = executeQuery('comment.updateCommentListArrange', $list_args);
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 		}
417 417
 
418 418
 		$output = executeQuery('comment.insertCommentList', $list_args);
419
-		if(!$output->toBool())
419
+		if (!$output->toBool())
420 420
 		{
421 421
 			return $output;
422 422
 		}
423 423
 
424 424
 		// insert comment
425 425
 		$output = executeQuery('comment.insertComment', $obj);
426
-		if(!$output->toBool())
426
+		if (!$output->toBool())
427 427
 		{
428 428
 			$oDB->rollback();
429 429
 			return $output;
@@ -439,29 +439,29 @@  discard block
 block discarded – undo
439 439
 		$oDocumentController = getController('document');
440 440
 
441 441
 		// Update the number of comments in the post
442
-		if(!$using_validation)
442
+		if (!$using_validation)
443 443
 		{
444 444
 			$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
445 445
 		}
446 446
 		else
447 447
 		{
448
-			if($is_admin)
448
+			if ($is_admin)
449 449
 			{
450 450
 				$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
451 451
 			}
452 452
 		}
453 453
 
454 454
 		// grant autority of the comment
455
-		if(!$manual_inserted)
455
+		if (!$manual_inserted)
456 456
 		{
457 457
 			$this->addGrant($obj->comment_srl);
458 458
 		}
459 459
 
460 460
 		// call a trigger(after)
461
-		if($output->toBool())
461
+		if ($output->toBool())
462 462
 		{
463 463
 			$trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
464
-			if(!$trigger_output->toBool())
464
+			if (!$trigger_output->toBool())
465 465
 			{
466 466
 				$oDB->rollback();
467 467
 				return $trigger_output;
@@ -471,16 +471,16 @@  discard block
 block discarded – undo
471 471
 		// commit
472 472
 		$oDB->commit();
473 473
 
474
-		if(!$manual_inserted)
474
+		if (!$manual_inserted)
475 475
 		{
476 476
 			// send a message if notify_message option in enabled in the original article
477 477
 			$oDocument->notify(Context::getLang('comment'), $obj->content);
478 478
 
479 479
 			// send a message if notify_message option in enabled in the original comment
480
-			if($obj->parent_srl)
480
+			if ($obj->parent_srl)
481 481
 			{
482 482
 				$oParent = $oCommentModel->getComment($obj->parent_srl);
483
-				if($oParent->get('member_srl') != $oDocument->get('member_srl'))
483
+				if ($oParent->get('member_srl') != $oDocument->get('member_srl'))
484 484
 				{
485 485
 					$oParent->notify(Context::getLang('comment'), $obj->content);
486 486
 				}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl);
509 509
 
510 510
 		$oMemberModel = getModel("member");
511
-		if(isset($obj->member_srl) && !is_null($obj->member_srl))
511
+		if (isset($obj->member_srl) && !is_null($obj->member_srl))
512 512
 		{
513 513
 			$member_info = $oMemberModel->getMemberInfoByMemberSrl($obj->member_srl);
514 514
 		}
@@ -528,47 +528,47 @@  discard block
 block discarded – undo
528 528
 		$module_info = $oModuleModel->getModuleInfoByDocumentSrl($obj->document_srl);
529 529
 
530 530
 		// If there is no problem to register comment then send an email to all admin were set in module admin panel
531
-		if($module_info->admin_mail && $member_info->is_admin != 'Y')
531
+		if ($module_info->admin_mail && $member_info->is_admin != 'Y')
532 532
 		{
533 533
 			$oMail = new Mail();
534 534
 			$oMail->setSender($obj->email_address, $obj->email_address);
535
-			$mail_title = "[XE - " . Context::get('mid') . "] A new comment was posted on document: \"" . $oDocument->getTitleText() . "\"";
535
+			$mail_title = "[XE - ".Context::get('mid')."] A new comment was posted on document: \"".$oDocument->getTitleText()."\"";
536 536
 			$oMail->setTitle($mail_title);
537
-			$url_comment = getFullUrl('','document_srl',$obj->document_srl).'#comment_'.$obj->comment_srl;
538
-			if($using_validation)
537
+			$url_comment = getFullUrl('', 'document_srl', $obj->document_srl).'#comment_'.$obj->comment_srl;
538
+			if ($using_validation)
539 539
 			{
540 540
 				$url_approve = getFullUrl('', 'module', 'admin', 'act', 'procCommentAdminChangePublishedStatusChecked', 'cart[]', $obj->comment_srl, 'will_publish', '1', 'search_target', 'is_published', 'search_keyword', 'N');
541 541
 				$url_trash = getFullUrl('', 'module', 'admin', 'act', 'procCommentAdminDeleteChecked', 'cart[]', $obj->comment_srl, 'search_target', 'is_trash', 'search_keyword', 'true');
542 542
 				$mail_content = "
543
-					A new comment on the document \"" . $oDocument->getTitleText() . "\" is waiting for your approval.
543
+					A new comment on the document \"" . $oDocument->getTitleText()."\" is waiting for your approval.
544 544
 					<br />
545 545
 					<br />
546
-					Author: " . $member_info->nick_name . "
547
-					<br />Author e-mail: " . $member_info->email_address . "
548
-					<br />From : <a href=\"" . $url_comment . "\">" . $url_comment . "</a>
546
+					Author: " . $member_info->nick_name."
547
+					<br />Author e-mail: " . $member_info->email_address."
548
+					<br />From : <a href=\"" . $url_comment."\">".$url_comment."</a>
549 549
 					<br />Comment:
550
-					<br />\"" . $obj->content . "\"
550
+					<br />\"" . $obj->content."\"
551 551
 					<br />Document:
552
-					<br />\"" . $oDocument->getContentText(). "\"
552
+					<br />\"" . $oDocument->getContentText()."\"
553 553
 					<br />
554 554
 					<br />
555
-					Approve it: <a href=\"" . $url_approve . "\">" . $url_approve . "</a>
556
-					<br />Trash it: <a href=\"" . $url_trash . "\">" . $url_trash . "</a>
557
-					<br />Currently " . $nr_comments_not_approved . " comments on \"" . Context::get('mid') . "\" module are waiting for approval. Please visit the moderation panel:
558
-					<br /><a href=\"" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl) . "\">" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl) . "</a>
555
+					Approve it: <a href=\"" . $url_approve."\">".$url_approve."</a>
556
+					<br />Trash it: <a href=\"" . $url_trash."\">".$url_trash."</a>
557
+					<br />Currently " . $nr_comments_not_approved." comments on \"".Context::get('mid')."\" module are waiting for approval. Please visit the moderation panel:
558
+					<br /><a href=\"" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl)."\">".getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl)."</a>
559 559
 					";
560 560
 				$oMail->setContent($mail_content);
561 561
 			}
562 562
 			else
563 563
 			{
564 564
 				$mail_content = "
565
-					Author: " . $member_info->nick_name . "
566
-					<br />Author e-mail: " . $member_info->email_address . "
567
-					<br />From : <a href=\"" . $url_comment . "\">" . $url_comment . "</a>
565
+					Author: " . $member_info->nick_name."
566
+					<br />Author e-mail: " . $member_info->email_address."
567
+					<br />From : <a href=\"" . $url_comment."\">".$url_comment."</a>
568 568
 					<br />Comment:
569
-					<br />\"" . $obj->content . "\"
569
+					<br />\"" . $obj->content."\"
570 570
 					<br />Document:
571
-					<br />\"" . $oDocument->getContentText(). "\"
571
+					<br />\"" . $oDocument->getContentText()."\"
572 572
 					";
573 573
 				$oMail->setContent($mail_content);
574 574
 
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
 			$target_mail = explode(',', $admins_emails);
598 598
 
599 599
 			// send email to all admins - START
600
-			for($i = 0; $i < count($target_mail); $i++)
600
+			for ($i = 0; $i < count($target_mail); $i++)
601 601
 			{
602 602
 				$email_address = trim($target_mail[$i]);
603
-				if(!$email_address)
603
+				if (!$email_address)
604 604
 				{
605 605
 					continue;
606 606
 				}
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
 	 */
647 647
 	function updateComment($obj, $is_admin = FALSE, $manual_updated = FALSE)
648 648
 	{
649
-		if(!$manual_updated && !checkCSRF())
649
+		if (!$manual_updated && !checkCSRF())
650 650
 		{
651 651
 			return new BaseObject(-1, 'msg_invalid_request');
652 652
 		}
653 653
 
654
-		if(!is_object($obj))
654
+		if (!is_object($obj))
655 655
 		{
656 656
 			$obj = new stdClass();
657 657
 		}
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
 		// call a trigger (before)
662 662
 		$output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj);
663
-		if(!$output->toBool())
663
+		if (!$output->toBool())
664 664
 		{
665 665
 			return $output;
666 666
 		}
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
 		// get the original data
672 672
 		$source_obj = $oCommentModel->getComment($obj->comment_srl);
673
-		if(!$source_obj->getMemberSrl())
673
+		if (!$source_obj->getMemberSrl())
674 674
 		{
675 675
 			$obj->member_srl = $source_obj->get('member_srl');
676 676
 			$obj->user_name = $source_obj->get('user_name');
@@ -680,30 +680,30 @@  discard block
 block discarded – undo
680 680
 		}
681 681
 
682 682
 		// check if permission is granted
683
-		if(!$is_admin && !$source_obj->isGranted())
683
+		if (!$is_admin && !$source_obj->isGranted())
684 684
 		{
685 685
 			return new BaseObject(-1, 'msg_not_permitted');
686 686
 		}
687 687
 
688
-		if($obj->password)
688
+		if ($obj->password)
689 689
 		{
690 690
 			$obj->password = getModel('member')->hashPassword($obj->password);
691 691
 		}
692 692
 
693
-		if($obj->homepage) 
693
+		if ($obj->homepage) 
694 694
 		{
695 695
 			$obj->homepage = removeHackTag($obj->homepage);
696
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
696
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
697 697
 			{
698 698
 				$obj->homepage = 'http://'.$obj->homepage;
699 699
 			}
700 700
 		}
701 701
 
702 702
 		// set modifier's information if logged-in and posting author and modifier are matched.
703
-		if(Context::get('is_logged'))
703
+		if (Context::get('is_logged'))
704 704
 		{
705 705
 			$logged_info = Context::get('logged_info');
706
-			if($source_obj->member_srl == $logged_info->member_srl)
706
+			if ($source_obj->member_srl == $logged_info->member_srl)
707 707
 			{
708 708
 				$obj->member_srl = $logged_info->member_srl;
709 709
 				$obj->user_name = $logged_info->user_name;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		}
715 715
 
716 716
 		// if nick_name of the logged-in author doesn't exist
717
-		if($source_obj->get('member_srl') && !$obj->nick_name)
717
+		if ($source_obj->get('member_srl') && !$obj->nick_name)
718 718
 		{
719 719
 			$obj->member_srl = $source_obj->get('member_srl');
720 720
 			$obj->user_name = $source_obj->get('user_name');
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 			$obj->homepage = $source_obj->get('homepage');
724 724
 		}
725 725
 
726
-		if(!$obj->content)
726
+		if (!$obj->content)
727 727
 		{
728 728
 			$obj->content = $source_obj->get('content');
729 729
 		}
@@ -731,9 +731,9 @@  discard block
 block discarded – undo
731 731
 		// remove XE's wn tags from contents
732 732
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
733 733
 
734
-		if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
734
+		if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
735 735
 		{
736
-			if($obj->use_html != 'Y')
736
+			if ($obj->use_html != 'Y')
737 737
 			{
738 738
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
739 739
 			}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 		}
742 742
 
743 743
 		// remove iframe and script if not a top administrator on the session
744
-		if($logged_info->is_admin != 'Y')
744
+		if ($logged_info->is_admin != 'Y')
745 745
 		{
746 746
 			$obj->content = removeHackTag($obj->content);
747 747
 		}
@@ -752,17 +752,17 @@  discard block
 block discarded – undo
752 752
 
753 753
 		// Update
754 754
 		$output = executeQuery('comment.updateComment', $obj);
755
-		if(!$output->toBool())
755
+		if (!$output->toBool())
756 756
 		{
757 757
 			$oDB->rollback();
758 758
 			return $output;
759 759
 		}
760 760
 
761 761
 		// call a trigger (after)
762
-		if($output->toBool())
762
+		if ($output->toBool())
763 763
 		{
764 764
 			$trigger_output = ModuleHandler::triggerCall('comment.updateComment', 'after', $obj);
765
-			if(!$trigger_output->toBool())
765
+			if (!$trigger_output->toBool())
766 766
 			{
767 767
 				$oDB->rollback();
768 768
 				return $trigger_output;
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
 		// check if comment already exists
793 793
 		$comment = $oCommentModel->getComment($comment_srl);
794
-		if($comment->comment_srl != $comment_srl)
794
+		if ($comment->comment_srl != $comment_srl)
795 795
 		{
796 796
 			return new BaseObject(-1, 'msg_invalid_request');
797 797
 		}
@@ -800,28 +800,28 @@  discard block
 block discarded – undo
800 800
 
801 801
 		// call a trigger (before)
802 802
 		$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
803
-		if(!$output->toBool())
803
+		if (!$output->toBool())
804 804
 		{
805 805
 			return $output;
806 806
 		}
807 807
 
808 808
 		// check if permission is granted
809
-		if(!$is_admin && !$comment->isGranted())
809
+		if (!$is_admin && !$comment->isGranted())
810 810
 		{
811 811
 			return new BaseObject(-1, 'msg_not_permitted');
812 812
 		}
813 813
 
814 814
 		// check if child comment exists on the comment
815 815
 		$childs = $oCommentModel->getChildComments($comment_srl);
816
-		if(count($childs) > 0)
816
+		if (count($childs) > 0)
817 817
 		{
818 818
 			$deleteAllComment = TRUE;
819
-			if(!$is_admin)
819
+			if (!$is_admin)
820 820
 			{
821 821
 				$logged_info = Context::get('logged_info');
822
-				foreach($childs as $val)
822
+				foreach ($childs as $val)
823 823
 				{
824
-					if($val->member_srl != $logged_info->member_srl)
824
+					if ($val->member_srl != $logged_info->member_srl)
825 825
 					{
826 826
 						$deleteAllComment = FALSE;
827 827
 						break;
@@ -829,16 +829,16 @@  discard block
 block discarded – undo
829 829
 				}
830 830
 			}
831 831
 
832
-			if(!$deleteAllComment)
832
+			if (!$deleteAllComment)
833 833
 			{
834 834
 				return new BaseObject(-1, 'fail_to_delete_have_children');
835 835
 			}
836 836
 			else
837 837
 			{
838
-				foreach($childs as $val)
838
+				foreach ($childs as $val)
839 839
 				{
840 840
 					$output = $this->deleteComment($val->comment_srl, $is_admin, $isMoveToTrash);
841
-					if(!$output->toBool())
841
+					if (!$output->toBool())
842 842
 					{
843 843
 						return $output;
844 844
 					}
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 		$args = new stdClass();
855 855
 		$args->comment_srl = $comment_srl;
856 856
 		$output = executeQuery('comment.deleteComment', $args);
857
-		if(!$output->toBool())
857
+		if (!$output->toBool())
858 858
 		{
859 859
 			$oDB->rollback();
860 860
 			return $output;
@@ -866,14 +866,14 @@  discard block
 block discarded – undo
866 866
 		$comment_count = $oCommentModel->getCommentCount($document_srl);
867 867
 
868 868
 		// only document is exists
869
-		if(isset($comment_count))
869
+		if (isset($comment_count))
870 870
 		{
871 871
 			// create the controller object of the document
872 872
 			$oDocumentController = getController('document');
873 873
 
874 874
 			// update comment count of the article posting
875 875
 			$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, NULL, FALSE);
876
-			if(!$output->toBool())
876
+			if (!$output->toBool())
877 877
 			{
878 878
 				$oDB->rollback();
879 879
 				return $output;
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 		}
882 882
 
883 883
 		// call a trigger (after)
884
-		if($output->toBool())
884
+		if ($output->toBool())
885 885
 		{
886 886
 			$comment->isMoveToTrash = $isMoveToTrash;
887 887
 			$trigger_output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
888
-			if(!$trigger_output->toBool())
888
+			if (!$trigger_output->toBool())
889 889
 			{
890 890
 				$oDB->rollback();
891 891
 				return $trigger_output;
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 			unset($comment->isMoveToTrash);
894 894
 		}
895 895
 
896
-		if(!$isMoveToTrash)
896
+		if (!$isMoveToTrash)
897 897
 		{
898 898
 			$this->_deleteDeclaredComments($args);
899 899
 			$this->_deleteVotedComments($args);
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 		$oCommentModel = getModel('comment');
938 938
 
939 939
 		// check if permission is granted
940
-		if(is_object($obj))
940
+		if (is_object($obj))
941 941
 		{
942 942
 			$oDocument = new documentItem();
943 943
 			$oDocument->setAttribute($obj);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 			$oDocument = $oDocumentModel->getDocument($document_srl);
948 948
 		}
949 949
 
950
-		if(!$oDocument->isExists() || !$oDocument->isGranted())
950
+		if (!$oDocument->isExists() || !$oDocument->isGranted())
951 951
 		{
952 952
 			return new BaseObject(-1, 'msg_not_permitted');
953 953
 		}
@@ -956,23 +956,23 @@  discard block
 block discarded – undo
956 956
 		$args = new stdClass();
957 957
 		$args->document_srl = $document_srl;
958 958
 		$comments = executeQueryArray('comment.getAllComments', $args);
959
-		if($comments->data)
959
+		if ($comments->data)
960 960
 		{
961 961
 			$commentSrlList = array();
962
-			foreach($comments->data as $comment)
962
+			foreach ($comments->data as $comment)
963 963
 			{
964 964
 				$commentSrlList[] = $comment->comment_srl;
965 965
 
966 966
 				// call a trigger (before)
967 967
 				$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
968
-				if(!$output->toBool())
968
+				if (!$output->toBool())
969 969
 				{
970 970
 					continue;
971 971
 				}
972 972
 
973 973
 				// call a trigger (after)
974 974
 				$output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
975
-				if(!$output->toBool())
975
+				if (!$output->toBool())
976 976
 				{
977 977
 					continue;
978 978
 				}
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		// delete the comment
983 983
 		$args->document_srl = $document_srl;
984 984
 		$output = executeQuery('comment.deleteComments', $args);
985
-		if(!$output->toBool())
985
+		if (!$output->toBool())
986 986
 		{
987 987
 			return $output;
988 988
 		}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 		$output = executeQuery('comment.deleteCommentsList', $args);
992 992
 
993 993
 		//delete declared, declared_log, voted_log
994
-		if(is_array($commentSrlList) && count($commentSrlList) > 0)
994
+		if (is_array($commentSrlList) && count($commentSrlList) > 0)
995 995
 		{
996 996
 			$args = new stdClass();
997 997
 			$args->comment_srl = join(',', $commentSrlList);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 	 */
1032 1032
 	function updateVotedCount($comment_srl, $point = 1)
1033 1033
 	{
1034
-		if($point > 0)
1034
+		if ($point > 0)
1035 1035
 		{
1036 1036
 			$failed_voted = 'failed_voted';
1037 1037
 			$success_message = 'success_voted';
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 
1045 1045
 		// invalid vote if vote info exists in the session info.
1046
-		if($_SESSION['voted_comment'][$comment_srl])
1046
+		if ($_SESSION['voted_comment'][$comment_srl])
1047 1047
 		{
1048 1048
 			return new BaseObject(-1, $failed_voted);
1049 1049
 		}
@@ -1052,21 +1052,21 @@  discard block
 block discarded – undo
1052 1052
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
1053 1053
 
1054 1054
 		// invalid vote if both ip addresses between author's and the current user are same.
1055
-		if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1055
+		if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1056 1056
 		{
1057 1057
 			$_SESSION['voted_comment'][$comment_srl] = TRUE;
1058 1058
 			return new BaseObject(-1, $failed_voted);
1059 1059
 		}
1060 1060
 
1061 1061
 		// if the comment author is a member
1062
-		if($oComment->get('member_srl'))
1062
+		if ($oComment->get('member_srl'))
1063 1063
 		{
1064 1064
 			// create the member model object
1065 1065
 			$oMemberModel = getModel('member');
1066 1066
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1067 1067
 
1068 1068
 			// session registered if the author information matches to the current logged-in user's.
1069
-			if($member_srl && $member_srl == abs($oComment->get('member_srl')))
1069
+			if ($member_srl && $member_srl == abs($oComment->get('member_srl')))
1070 1070
 			{
1071 1071
 				$_SESSION['voted_comment'][$comment_srl] = TRUE;
1072 1072
 				return new BaseObject(-1, $failed_voted);
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 		$args = new stdClass();
1077 1077
 
1078 1078
 		// If logged-in, use the member_srl. otherwise use the ipaddress.
1079
-		if($member_srl)
1079
+		if ($member_srl)
1080 1080
 		{
1081 1081
 			$args->member_srl = $member_srl;
1082 1082
 		}
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 		$output = executeQuery('comment.getCommentVotedLogInfo', $args);
1090 1090
 
1091 1091
 		// session registered if log info contains recommendation vote log.
1092
-		if($output->data->count)
1092
+		if ($output->data->count)
1093 1093
 		{
1094 1094
 			$_SESSION['voted_comment'][$comment_srl] = TRUE;
1095 1095
 			return new BaseObject(-1, $failed_voted);
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		$trigger_obj->before_point = ($point < 0) ? $oComment->get('blamed_count') : $oComment->get('voted_count');
1107 1107
 		$trigger_obj->after_point = $trigger_obj->before_point + $point;
1108 1108
 		$trigger_output = ModuleHandler::triggerCall('comment.updateVotedCount', 'before', $trigger_obj);
1109
-		if(!$trigger_output->toBool())
1109
+		if (!$trigger_output->toBool())
1110 1110
 		{
1111 1111
 			return $trigger_output;
1112 1112
 		}
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 		$oDB->begin();
1117 1117
 
1118 1118
 		// update the number of votes
1119
-		if($trigger_obj->update_target === 'blamed_count')
1119
+		if ($trigger_obj->update_target === 'blamed_count')
1120 1120
 		{
1121 1121
 			$args->blamed_count = $trigger_obj->after_point;
1122 1122
 			$output = executeQuery('comment.updateBlamedCount', $args);
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
 		// Call a trigger (after)
1135 1135
 		$trigger_output = ModuleHandler::triggerCall('comment.updateVotedCount', 'after', $trigger_obj);
1136
-		if(!$trigger_output->toBool())
1136
+		if (!$trigger_output->toBool())
1137 1137
 		{
1138 1138
 			$oDB->rollback();
1139 1139
 			return $trigger_output;
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 
1147 1147
 		// Return the result
1148 1148
 		$output = new BaseObject(0, $success_message);
1149
-		if($trigger_obj->update_target === 'voted_count')
1149
+		if ($trigger_obj->update_target === 'voted_count')
1150 1150
 		{
1151 1151
 			$output->add('voted_count', $trigger_obj->after_point);
1152 1152
 		}
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	function declaredComment($comment_srl)
1167 1167
 	{
1168 1168
 		// Fail if session information already has a reported document
1169
-		if($_SESSION['declared_comment'][$comment_srl])
1169
+		if ($_SESSION['declared_comment'][$comment_srl])
1170 1170
 		{
1171 1171
 			return new BaseObject(-1, 'failed_declared');
1172 1172
 		}
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 		$args = new stdClass();
1176 1176
 		$args->comment_srl = $comment_srl;
1177 1177
 		$output = executeQuery('comment.getDeclaredComment', $args);
1178
-		if(!$output->toBool())
1178
+		if (!$output->toBool())
1179 1179
 		{
1180 1180
 			return $output;
1181 1181
 		}
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 
1188 1188
 		// Call a trigger (before)
1189 1189
 		$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'before', $trigger_obj);
1190
-		if(!$trigger_output->toBool())
1190
+		if (!$trigger_output->toBool())
1191 1191
 		{
1192 1192
 			return $trigger_output;
1193 1193
 		}
@@ -1197,21 +1197,21 @@  discard block
 block discarded – undo
1197 1197
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
1198 1198
 
1199 1199
 		// failed if both ip addresses between author's and the current user are same.
1200
-		if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1200
+		if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1201 1201
 		{
1202 1202
 			$_SESSION['declared_comment'][$comment_srl] = TRUE;
1203 1203
 			return new BaseObject(-1, 'failed_declared');
1204 1204
 		}
1205 1205
 
1206 1206
 		// if the comment author is a member
1207
-		if($oComment->get('member_srl'))
1207
+		if ($oComment->get('member_srl'))
1208 1208
 		{
1209 1209
 			// create the member model object
1210 1210
 			$oMemberModel = getModel('member');
1211 1211
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1212 1212
 
1213 1213
 			// session registered if the author information matches to the current logged-in user's.
1214
-			if($member_srl && $member_srl == abs($oComment->get('member_srl')))
1214
+			if ($member_srl && $member_srl == abs($oComment->get('member_srl')))
1215 1215
 			{
1216 1216
 				$_SESSION['declared_comment'][$comment_srl] = TRUE;
1217 1217
 				return new BaseObject(-1, 'failed_declared');
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 		}
1220 1220
 
1221 1221
 		// If logged-in, use the member_srl. otherwise use the ipaddress.
1222
-		if($member_srl)
1222
+		if ($member_srl)
1223 1223
 		{
1224 1224
 			$args->member_srl = $member_srl;
1225 1225
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		$log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args);
1232 1232
 
1233 1233
 		// session registered if log info contains report log.
1234
-		if($log_output->data->count)
1234
+		if ($log_output->data->count)
1235 1235
 		{
1236 1236
 			$_SESSION['declared_comment'][$comment_srl] = TRUE;
1237 1237
 			return new BaseObject(-1, 'failed_declared');
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 		$oDB->begin();
1243 1243
 
1244 1244
 		// execute insert
1245
-		if($output->data->declared_count > 0)
1245
+		if ($output->data->declared_count > 0)
1246 1246
 		{
1247 1247
 			$output = executeQuery('comment.updateDeclaredComment', $args);
1248 1248
 		}
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 			$output = executeQuery('comment.insertDeclaredComment', $args);
1252 1252
 		}
1253 1253
 
1254
-		if(!$output->toBool())
1254
+		if (!$output->toBool())
1255 1255
 		{
1256 1256
 			$oDB->rollback();
1257 1257
 			return $output;
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 		// Call a trigger (after)
1264 1264
 		$trigger_obj->declared_count = $declared_count + 1;
1265 1265
 		$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'after', $trigger_obj);
1266
-		if(!$trigger_output->toBool())
1266
+		if (!$trigger_output->toBool())
1267 1267
 		{
1268 1268
 			$oDB->rollback();
1269 1269
 			return $trigger_output;
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 	function addCommentPopupMenu($url, $str, $icon = '', $target = 'self')
1289 1289
 	{
1290 1290
 		$comment_popup_menu_list = Context::get('comment_popup_menu_list');
1291
-		if(!is_array($comment_popup_menu_list))
1291
+		if (!is_array($comment_popup_menu_list))
1292 1292
 		{
1293 1293
 			$comment_popup_menu_list = array();
1294 1294
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 	function procCommentInsertModuleConfig()
1311 1311
 	{
1312 1312
 		$module_srl = Context::get('target_module_srl');
1313
-		if(preg_match('/^([0-9,]+)$/', $module_srl))
1313
+		if (preg_match('/^([0-9,]+)$/', $module_srl))
1314 1314
 		{
1315 1315
 			$module_srl = explode(',', $module_srl);
1316 1316
 		}
@@ -1321,33 +1321,33 @@  discard block
 block discarded – undo
1321 1321
 
1322 1322
 		$comment_config = new stdClass();
1323 1323
 		$comment_config->comment_count = (int) Context::get('comment_count');
1324
-		if(!$comment_config->comment_count)
1324
+		if (!$comment_config->comment_count)
1325 1325
 		{
1326 1326
 			$comment_config->comment_count = 50;
1327 1327
 		}
1328 1328
 
1329 1329
 		$comment_config->use_vote_up = Context::get('use_vote_up');
1330
-		if(!$comment_config->use_vote_up)
1330
+		if (!$comment_config->use_vote_up)
1331 1331
 		{
1332 1332
 			$comment_config->use_vote_up = 'Y';
1333 1333
 		}
1334 1334
 
1335 1335
 		$comment_config->use_vote_down = Context::get('use_vote_down');
1336
-		if(!$comment_config->use_vote_down)
1336
+		if (!$comment_config->use_vote_down)
1337 1337
 		{
1338 1338
 			$comment_config->use_vote_down = 'Y';
1339 1339
 		}
1340 1340
 
1341 1341
 		$comment_config->use_comment_validation = Context::get('use_comment_validation');
1342
-		if(!$comment_config->use_comment_validation)
1342
+		if (!$comment_config->use_comment_validation)
1343 1343
 		{
1344 1344
 			$comment_config->use_comment_validation = 'N';
1345 1345
 		}
1346 1346
 
1347
-		for($i = 0; $i < count($module_srl); $i++)
1347
+		for ($i = 0; $i < count($module_srl); $i++)
1348 1348
 		{
1349 1349
 			$srl = trim($module_srl[$i]);
1350
-			if(!$srl)
1350
+			if (!$srl)
1351 1351
 			{
1352 1352
 				continue;
1353 1353
 			}
@@ -1381,25 +1381,25 @@  discard block
 block discarded – undo
1381 1381
 	 */
1382 1382
 	function procCommentGetList()
1383 1383
 	{
1384
-		if(!Context::get('is_logged'))
1384
+		if (!Context::get('is_logged'))
1385 1385
 		{
1386 1386
 			return new BaseObject(-1, 'msg_not_permitted');
1387 1387
 		}
1388 1388
 
1389 1389
 		$commentSrls = Context::get('comment_srls');
1390
-		if($commentSrls)
1390
+		if ($commentSrls)
1391 1391
 		{
1392 1392
 			$commentSrlList = explode(',', $commentSrls);
1393 1393
 		}
1394 1394
 
1395
-		if(count($commentSrlList) > 0)
1395
+		if (count($commentSrlList) > 0)
1396 1396
 		{
1397 1397
 			$oCommentModel = getModel('comment');
1398 1398
 			$commentList = $oCommentModel->getComments($commentSrlList);
1399 1399
 
1400
-			if(is_array($commentList))
1400
+			if (is_array($commentList))
1401 1401
 			{
1402
-				foreach($commentList as $value)
1402
+				foreach ($commentList as $value)
1403 1403
 				{
1404 1404
 					$value->content = strip_tags($value->content);
1405 1405
 				}
@@ -1424,9 +1424,9 @@  discard block
 block discarded – undo
1424 1424
 		$commentConfig = $oModuleModel->getModulePartConfig('comment', $obj->originModuleSrl);
1425 1425
 
1426 1426
 		$oModuleController = getController('module');
1427
-		if(is_array($obj->moduleSrlList))
1427
+		if (is_array($obj->moduleSrlList))
1428 1428
 		{
1429
-			foreach($obj->moduleSrlList as $moduleSrl)
1429
+			foreach ($obj->moduleSrlList as $moduleSrl)
1430 1430
 			{
1431 1431
 				$oModuleController->insertModulePartConfig('comment', $moduleSrl, $commentConfig);
1432 1432
 			}
Please login to merge, or discard this patch.
Braces   +22 added lines, -44 removed lines patch added patch discarded remove patch
@@ -211,14 +211,12 @@  discard block
 block discarded – undo
211 211
 				if($logged_info->is_admin == 'Y')
212 212
 				{
213 213
 					$is_admin = TRUE;
214
-				}
215
-				else
214
+				} else
216 215
 				{
217 216
 					$is_admin = FALSE;
218 217
 				}
219 218
 			}
220
-		}
221
-		else
219
+		} else
222 220
 		{
223 221
 			$is_admin = FALSE;
224 222
 		}
@@ -226,14 +224,12 @@  discard block
 block discarded – undo
226 224
 		if(!$using_validation)
227 225
 		{
228 226
 			$obj->status = 1;
229
-		}
230
-		else
227
+		} else
231 228
 		{
232 229
 			if($is_admin)
233 230
 			{
234 231
 				$obj->status = 1;
235
-			}
236
-			else
232
+			} else
237 233
 			{
238 234
 				$obj->status = 0;
239 235
 			}
@@ -310,8 +306,7 @@  discard block
 block discarded – undo
310 306
 		if(!$obj->comment_srl)
311 307
 		{
312 308
 			$obj->comment_srl = getNextSequence();
313
-		}
314
-		elseif(!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) 
309
+		} elseif(!$is_admin && !$manual_inserted && !checkUserSequence($obj->comment_srl)) 
315 310
 		{
316 311
 			return new BaseObject(-1, 'msg_not_permitted');
317 312
 		}
@@ -369,8 +364,7 @@  discard block
 block discarded – undo
369 364
 			$list_args->head = $list_args->arrange = $obj->comment_srl;
370 365
 			$list_args->depth = 0;
371 366
 			// If parent comment exists, get information of the parent comment
372
-		}
373
-		else
367
+		} else
374 368
 		{
375 369
 			// get information of the parent comment posting
376 370
 			$parent_args = new stdClass();
@@ -393,8 +387,7 @@  discard block
 block discarded – undo
393 387
 			{
394 388
 				$list_args->arrange = $obj->comment_srl;
395 389
 				// if the depth of comments is greater than 2, execute update.
396
-			}
397
-			else
390
+			} else
398 391
 			{
399 392
 				// get the top listed comment among those in lower depth and same head with parent's.
400 393
 				$p_args = new stdClass();
@@ -407,8 +400,7 @@  discard block
 block discarded – undo
407 400
 				{
408 401
 					$list_args->arrange = $output->data->arrange;
409 402
 					$output = executeQuery('comment.updateCommentListArrange', $list_args);
410
-				}
411
-				else
403
+				} else
412 404
 				{
413 405
 					$list_args->arrange = $obj->comment_srl;
414 406
 				}
@@ -442,8 +434,7 @@  discard block
 block discarded – undo
442 434
 		if(!$using_validation)
443 435
 		{
444 436
 			$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
445
-		}
446
-		else
437
+		} else
447 438
 		{
448 439
 			if($is_admin)
449 440
 			{
@@ -511,8 +502,7 @@  discard block
 block discarded – undo
511 502
 		if(isset($obj->member_srl) && !is_null($obj->member_srl))
512 503
 		{
513 504
 			$member_info = $oMemberModel->getMemberInfoByMemberSrl($obj->member_srl);
514
-		}
515
-		else
505
+		} else
516 506
 		{
517 507
 			$member_info = new stdClass();
518 508
 			$member_info->is_admin = "N";
@@ -558,8 +548,7 @@  discard block
 block discarded – undo
558 548
 					<br /><a href=\"" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl) . "\">" . getFullUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'module', 'search_keyword', $obj->module_srl) . "</a>
559 549
 					";
560 550
 				$oMail->setContent($mail_content);
561
-			}
562
-			else
551
+			} else
563 552
 			{
564 553
 				$mail_content = "
565 554
 					Author: " . $member_info->nick_name . "
@@ -832,8 +821,7 @@  discard block
 block discarded – undo
832 821
 			if(!$deleteAllComment)
833 822
 			{
834 823
 				return new BaseObject(-1, 'fail_to_delete_have_children');
835
-			}
836
-			else
824
+			} else
837 825
 			{
838 826
 				foreach($childs as $val)
839 827
 				{
@@ -897,8 +885,7 @@  discard block
 block discarded – undo
897 885
 		{
898 886
 			$this->_deleteDeclaredComments($args);
899 887
 			$this->_deleteVotedComments($args);
900
-		} 
901
-		else 
888
+		} else 
902 889
 		{
903 890
 			$args = new stdClass();
904 891
 			$args->upload_target_srl = $comment_srl;
@@ -941,8 +928,7 @@  discard block
 block discarded – undo
941 928
 		{
942 929
 			$oDocument = new documentItem();
943 930
 			$oDocument->setAttribute($obj);
944
-		}
945
-		else
931
+		} else
946 932
 		{
947 933
 			$oDocument = $oDocumentModel->getDocument($document_srl);
948 934
 		}
@@ -1035,8 +1021,7 @@  discard block
 block discarded – undo
1035 1021
 		{
1036 1022
 			$failed_voted = 'failed_voted';
1037 1023
 			$success_message = 'success_voted';
1038
-		}
1039
-		else
1024
+		} else
1040 1025
 		{
1041 1026
 			$failed_voted = 'failed_blamed';
1042 1027
 			$success_message = 'success_blamed';
@@ -1079,8 +1064,7 @@  discard block
 block discarded – undo
1079 1064
 		if($member_srl)
1080 1065
 		{
1081 1066
 			$args->member_srl = $member_srl;
1082
-		}
1083
-		else
1067
+		} else
1084 1068
 		{
1085 1069
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1086 1070
 		}
@@ -1120,8 +1104,7 @@  discard block
 block discarded – undo
1120 1104
 		{
1121 1105
 			$args->blamed_count = $trigger_obj->after_point;
1122 1106
 			$output = executeQuery('comment.updateBlamedCount', $args);
1123
-		}
1124
-		else
1107
+		} else
1125 1108
 		{
1126 1109
 			$args->voted_count = $trigger_obj->after_point;
1127 1110
 			$output = executeQuery('comment.updateVotedCount', $args);
@@ -1149,8 +1132,7 @@  discard block
 block discarded – undo
1149 1132
 		if($trigger_obj->update_target === 'voted_count')
1150 1133
 		{
1151 1134
 			$output->add('voted_count', $trigger_obj->after_point);
1152
-		}
1153
-		else
1135
+		} else
1154 1136
 		{
1155 1137
 			$output->add('blamed_count', $trigger_obj->after_point);
1156 1138
 		}
@@ -1222,8 +1204,7 @@  discard block
 block discarded – undo
1222 1204
 		if($member_srl)
1223 1205
 		{
1224 1206
 			$args->member_srl = $member_srl;
1225
-		}
1226
-		else
1207
+		} else
1227 1208
 		{
1228 1209
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1229 1210
 		}
@@ -1245,8 +1226,7 @@  discard block
 block discarded – undo
1245 1226
 		if($output->data->declared_count > 0)
1246 1227
 		{
1247 1228
 			$output = executeQuery('comment.updateDeclaredComment', $args);
1248
-		}
1249
-		else
1229
+		} else
1250 1230
 		{
1251 1231
 			$output = executeQuery('comment.insertDeclaredComment', $args);
1252 1232
 		}
@@ -1313,8 +1293,7 @@  discard block
 block discarded – undo
1313 1293
 		if(preg_match('/^([0-9,]+)$/', $module_srl))
1314 1294
 		{
1315 1295
 			$module_srl = explode(',', $module_srl);
1316
-		}
1317
-		else
1296
+		} else
1318 1297
 		{
1319 1298
 			$module_srl = array($module_srl);
1320 1299
 		}
@@ -1404,8 +1383,7 @@  discard block
 block discarded – undo
1404 1383
 					$value->content = strip_tags($value->content);
1405 1384
 				}
1406 1385
 			}
1407
-		}
1408
-		else
1386
+		} else
1409 1387
 		{
1410 1388
 			global $lang;
1411 1389
 			$commentList = array();
Please login to merge, or discard this patch.