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 — master (#1805)
by
unknown
18:31
created
modules/comment/comment.controller.php 4 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -160,7 +160,6 @@  discard block
 block discarded – undo
160 160
 
161 161
 	/**
162 162
 	 * Check if module is using comment validation system
163
-	 * @param int $document_srl
164 163
 	 * @param int $module_srl
165 164
 	 * @return bool
166 165
 	 */
@@ -1151,7 +1150,7 @@  discard block
 block discarded – undo
1151 1150
 
1152 1151
 	/**
1153 1152
 	 * Report a blamed comment
1154
-	 * @param $comment_srl
1153
+	 * @param string $comment_srl
1155 1154
 	 * @return void
1156 1155
 	 */
1157 1156
 	function declaredComment($comment_srl)
@@ -1356,7 +1355,7 @@  discard block
 block discarded – undo
1356 1355
 	/**
1357 1356
 	 * Comment module config setting
1358 1357
 	 * @param int $srl
1359
-	 * @param object $comment_config
1358
+	 * @param stdClass $comment_config
1360 1359
 	 * @return Object
1361 1360
 	 */
1362 1361
 	function setCommentModuleConfig($srl, $comment_config)
@@ -1368,7 +1367,7 @@  discard block
 block discarded – undo
1368 1367
 
1369 1368
 	/**
1370 1369
 	 * Get comment all list
1371
-	 * @return void
1370
+	 * @return Object|null
1372 1371
 	 */
1373 1372
 	function procCommentGetList()
1374 1373
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -581,7 +581,7 @@
 block discarded – undo
581 581
 				//mail to author of thread - START
582 582
 				/**
583 583
 				 * @todo Removed code send email to document author.
584
-				*/
584
+				 */
585 585
 				/*
586 586
 				if($document_author_email != $obj->email_address && $logged_info->email_address != $document_author_email)
587 587
 				{
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object();
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 Object();
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 Object(-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 Object(-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 Object(-1, 'msg_invalid_document');
274 274
 			}
275
-			if($oDocument->isLocked())
275
+			if ($oDocument->isLocked())
276 276
 			{
277 277
 				return new Object(-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
-					$obj->homepage = 'http://'.$obj->homepage;
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 Object(-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 Object(-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())
325
+		if (Mobile::isFromMobilePhone())
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,14 +528,14 @@  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 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');
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 					<br />Comment:
550 550
 					<br />\"" . $obj->content . "\"
551 551
 					<br />Document:
552
-					<br />\"" . $oDocument->getContentText(). "\"
552
+					<br />\"" . $oDocument->getContentText() . "\"
553 553
 					<br />
554 554
 					<br />
555 555
 					Approve it: <a href=\"" . $url_approve . "\">" . $url_approve . "</a>
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 					<br />Comment:
569 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 Object(-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 Object(-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
-				$obj->homepage = 'http://'.$obj->homepage;
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())
734
+		if (Mobile::isFromMobilePhone())
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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 Object(-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 == $oComment->get('member_srl'))
1069
+			if ($member_srl && $member_srl == $oComment->get('member_srl'))
1070 1070
 			{
1071 1071
 				$_SESSION['voted_comment'][$comment_srl] = TRUE;
1072 1072
 				return new Object(-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 Object(-1, $failed_voted);
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		$oDB->begin();
1101 1101
 
1102 1102
 		// update the number of votes
1103
-		if($point < 0)
1103
+		if ($point < 0)
1104 1104
 		{
1105 1105
 			$args->blamed_count = $oComment->get('blamed_count') + $point;
1106 1106
 			$output = executeQuery('comment.updateBlamedCount', $args);
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 		$obj->before_point = ($point < 0) ? $oComment->get('blamed_count') : $oComment->get('voted_count');
1125 1125
 		$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
1126 1126
 		$trigger_output = ModuleHandler::triggerCall('comment.updateVotedCount', 'after', $obj);
1127
-		if(!$trigger_output->toBool())
1127
+		if (!$trigger_output->toBool())
1128 1128
 		{
1129 1129
 			$oDB->rollback();
1130 1130
 			return $trigger_output;
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 
1138 1138
 		// Return the result
1139 1139
 		$output = new Object(0, $success_message);
1140
-		if($point > 0)
1140
+		if ($point > 0)
1141 1141
 		{
1142 1142
 			$output->add('voted_count', $obj->after_point);
1143 1143
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	function declaredComment($comment_srl)
1158 1158
 	{
1159 1159
 		// Fail if session information already has a reported document
1160
-		if($_SESSION['declared_comment'][$comment_srl])
1160
+		if ($_SESSION['declared_comment'][$comment_srl])
1161 1161
 		{
1162 1162
 			return new Object(-1, 'failed_declared');
1163 1163
 		}
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 		$args = new stdClass();
1167 1167
 		$args->comment_srl = $comment_srl;
1168 1168
 		$output = executeQuery('comment.getDeclaredComment', $args);
1169
-		if(!$output->toBool())
1169
+		if (!$output->toBool())
1170 1170
 		{
1171 1171
 			return $output;
1172 1172
 		}
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 
1179 1179
 		// Call a trigger (before)
1180 1180
 		$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'before', $trigger_obj);
1181
-		if(!$trigger_output->toBool())
1181
+		if (!$trigger_output->toBool())
1182 1182
 		{
1183 1183
 			return $trigger_output;
1184 1184
 		}
@@ -1188,21 +1188,21 @@  discard block
 block discarded – undo
1188 1188
 		$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
1189 1189
 
1190 1190
 		// failed if both ip addresses between author's and the current user are same.
1191
-		if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1191
+		if ($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1192 1192
 		{
1193 1193
 			$_SESSION['declared_comment'][$comment_srl] = TRUE;
1194 1194
 			return new Object(-1, 'failed_declared');
1195 1195
 		}
1196 1196
 
1197 1197
 		// if the comment author is a member
1198
-		if($oComment->get('member_srl'))
1198
+		if ($oComment->get('member_srl'))
1199 1199
 		{
1200 1200
 			// create the member model object
1201 1201
 			$oMemberModel = getModel('member');
1202 1202
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1203 1203
 
1204 1204
 			// session registered if the author information matches to the current logged-in user's.
1205
-			if($member_srl && $member_srl == $oComment->get('member_srl'))
1205
+			if ($member_srl && $member_srl == $oComment->get('member_srl'))
1206 1206
 			{
1207 1207
 				$_SESSION['declared_comment'][$comment_srl] = TRUE;
1208 1208
 				return new Object(-1, 'failed_declared');
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
 		}
1211 1211
 
1212 1212
 		// If logged-in, use the member_srl. otherwise use the ipaddress.
1213
-		if($member_srl)
1213
+		if ($member_srl)
1214 1214
 		{
1215 1215
 			$args->member_srl = $member_srl;
1216 1216
 		}
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 		$log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args);
1223 1223
 
1224 1224
 		// session registered if log info contains report log.
1225
-		if($log_output->data->count)
1225
+		if ($log_output->data->count)
1226 1226
 		{
1227 1227
 			$_SESSION['declared_comment'][$comment_srl] = TRUE;
1228 1228
 			return new Object(-1, 'failed_declared');
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		$oDB->begin();
1234 1234
 
1235 1235
 		// execute insert
1236
-		if($output->data->declared_count > 0)
1236
+		if ($output->data->declared_count > 0)
1237 1237
 		{
1238 1238
 			$output = executeQuery('comment.updateDeclaredComment', $args);
1239 1239
 		}
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			$output = executeQuery('comment.insertDeclaredComment', $args);
1243 1243
 		}
1244 1244
 
1245
-		if(!$output->toBool())
1245
+		if (!$output->toBool())
1246 1246
 		{
1247 1247
 			$oDB->rollback();
1248 1248
 			return $output;
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 		// Call a trigger (after)
1255 1255
 		$trigger_obj->declared_count = $declared_count + 1;
1256 1256
 		$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'after', $trigger_obj);
1257
-		if(!$trigger_output->toBool())
1257
+		if (!$trigger_output->toBool())
1258 1258
 		{
1259 1259
 			$oDB->rollback();
1260 1260
 			return $trigger_output;
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 	function addCommentPopupMenu($url, $str, $icon = '', $target = 'self')
1280 1280
 	{
1281 1281
 		$comment_popup_menu_list = Context::get('comment_popup_menu_list');
1282
-		if(!is_array($comment_popup_menu_list))
1282
+		if (!is_array($comment_popup_menu_list))
1283 1283
 		{
1284 1284
 			$comment_popup_menu_list = array();
1285 1285
 		}
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 	function procCommentInsertModuleConfig()
1302 1302
 	{
1303 1303
 		$module_srl = Context::get('target_module_srl');
1304
-		if(preg_match('/^([0-9,]+)$/', $module_srl))
1304
+		if (preg_match('/^([0-9,]+)$/', $module_srl))
1305 1305
 		{
1306 1306
 			$module_srl = explode(',', $module_srl);
1307 1307
 		}
@@ -1312,33 +1312,33 @@  discard block
 block discarded – undo
1312 1312
 
1313 1313
 		$comment_config = new stdClass();
1314 1314
 		$comment_config->comment_count = (int) Context::get('comment_count');
1315
-		if(!$comment_config->comment_count)
1315
+		if (!$comment_config->comment_count)
1316 1316
 		{
1317 1317
 			$comment_config->comment_count = 50;
1318 1318
 		}
1319 1319
 
1320 1320
 		$comment_config->use_vote_up = Context::get('use_vote_up');
1321
-		if(!$comment_config->use_vote_up)
1321
+		if (!$comment_config->use_vote_up)
1322 1322
 		{
1323 1323
 			$comment_config->use_vote_up = 'Y';
1324 1324
 		}
1325 1325
 
1326 1326
 		$comment_config->use_vote_down = Context::get('use_vote_down');
1327
-		if(!$comment_config->use_vote_down)
1327
+		if (!$comment_config->use_vote_down)
1328 1328
 		{
1329 1329
 			$comment_config->use_vote_down = 'Y';
1330 1330
 		}
1331 1331
 
1332 1332
 		$comment_config->use_comment_validation = Context::get('use_comment_validation');
1333
-		if(!$comment_config->use_comment_validation)
1333
+		if (!$comment_config->use_comment_validation)
1334 1334
 		{
1335 1335
 			$comment_config->use_comment_validation = 'N';
1336 1336
 		}
1337 1337
 
1338
-		for($i = 0; $i < count($module_srl); $i++)
1338
+		for ($i = 0; $i < count($module_srl); $i++)
1339 1339
 		{
1340 1340
 			$srl = trim($module_srl[$i]);
1341
-			if(!$srl)
1341
+			if (!$srl)
1342 1342
 			{
1343 1343
 				continue;
1344 1344
 			}
@@ -1372,25 +1372,25 @@  discard block
 block discarded – undo
1372 1372
 	 */
1373 1373
 	function procCommentGetList()
1374 1374
 	{
1375
-		if(!Context::get('is_logged'))
1375
+		if (!Context::get('is_logged'))
1376 1376
 		{
1377 1377
 			return new Object(-1, 'msg_not_permitted');
1378 1378
 		}
1379 1379
 
1380 1380
 		$commentSrls = Context::get('comment_srls');
1381
-		if($commentSrls)
1381
+		if ($commentSrls)
1382 1382
 		{
1383 1383
 			$commentSrlList = explode(',', $commentSrls);
1384 1384
 		}
1385 1385
 
1386
-		if(count($commentSrlList) > 0)
1386
+		if (count($commentSrlList) > 0)
1387 1387
 		{
1388 1388
 			$oCommentModel = getModel('comment');
1389 1389
 			$commentList = $oCommentModel->getComments($commentSrlList);
1390 1390
 
1391
-			if(is_array($commentList))
1391
+			if (is_array($commentList))
1392 1392
 			{
1393
-				foreach($commentList as $value)
1393
+				foreach ($commentList as $value)
1394 1394
 				{
1395 1395
 					$value->content = strip_tags($value->content);
1396 1396
 				}
@@ -1415,9 +1415,9 @@  discard block
 block discarded – undo
1415 1415
 		$commentConfig = $oModuleModel->getModulePartConfig('comment', $obj->originModuleSrl);
1416 1416
 
1417 1417
 		$oModuleController = getController('module');
1418
-		if(is_array($obj->moduleSrlList))
1418
+		if (is_array($obj->moduleSrlList))
1419 1419
 		{
1420
-			foreach($obj->moduleSrlList as $moduleSrl)
1420
+			foreach ($obj->moduleSrlList as $moduleSrl)
1421 1421
 			{
1422 1422
 				$oModuleController->insertModulePartConfig('comment', $moduleSrl, $commentConfig);
1423 1423
 			}
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 Object(-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 Object(-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
 		}
@@ -1104,8 +1088,7 @@  discard block
 block discarded – undo
1104 1088
 		{
1105 1089
 			$args->blamed_count = $oComment->get('blamed_count') + $point;
1106 1090
 			$output = executeQuery('comment.updateBlamedCount', $args);
1107
-		}
1108
-		else
1091
+		} else
1109 1092
 		{
1110 1093
 			$args->voted_count = $oComment->get('voted_count') + $point;
1111 1094
 			$output = executeQuery('comment.updateVotedCount', $args);
@@ -1140,8 +1123,7 @@  discard block
 block discarded – undo
1140 1123
 		if($point > 0)
1141 1124
 		{
1142 1125
 			$output->add('voted_count', $obj->after_point);
1143
-		}
1144
-		else
1126
+		} else
1145 1127
 		{
1146 1128
 			$output->add('blamed_count', $obj->after_point);
1147 1129
 		}
@@ -1213,8 +1195,7 @@  discard block
 block discarded – undo
1213 1195
 		if($member_srl)
1214 1196
 		{
1215 1197
 			$args->member_srl = $member_srl;
1216
-		}
1217
-		else
1198
+		} else
1218 1199
 		{
1219 1200
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1220 1201
 		}
@@ -1236,8 +1217,7 @@  discard block
 block discarded – undo
1236 1217
 		if($output->data->declared_count > 0)
1237 1218
 		{
1238 1219
 			$output = executeQuery('comment.updateDeclaredComment', $args);
1239
-		}
1240
-		else
1220
+		} else
1241 1221
 		{
1242 1222
 			$output = executeQuery('comment.insertDeclaredComment', $args);
1243 1223
 		}
@@ -1304,8 +1284,7 @@  discard block
 block discarded – undo
1304 1284
 		if(preg_match('/^([0-9,]+)$/', $module_srl))
1305 1285
 		{
1306 1286
 			$module_srl = explode(',', $module_srl);
1307
-		}
1308
-		else
1287
+		} else
1309 1288
 		{
1310 1289
 			$module_srl = array($module_srl);
1311 1290
 		}
@@ -1395,8 +1374,7 @@  discard block
 block discarded – undo
1395 1374
 					$value->content = strip_tags($value->content);
1396 1375
 				}
1397 1376
 			}
1398
-		}
1399
-		else
1377
+		} else
1400 1378
 		{
1401 1379
 			global $lang;
1402 1380
 			$commentList = array();
Please login to merge, or discard this patch.
modules/comment/comment.view.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	/**
25 25
 	 * Add a form fot comment setting on the additional setting of module
26 26
 	 * @param string $obj
27
-	 * @return string
27
+	 * @return Object
28 28
 	 */
29 29
 	function triggerDispCommentAdditionSetup(&$obj)
30 30
 	{
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@
 block discarded – undo
31 31
 		$current_module_srl = Context::get('module_srl');
32 32
 		$current_module_srls = Context::get('module_srls');
33 33
 
34
-		if(!$current_module_srl && !$current_module_srls)
34
+		if (!$current_module_srl && !$current_module_srls)
35 35
 		{
36 36
 			// get information of the selected module
37 37
 			$current_module_info = Context::get('current_module_info');
38 38
 			$current_module_srl = $current_module_info->module_srl;
39
-			if(!$current_module_srl)
39
+			if (!$current_module_srl)
40 40
 			{
41 41
 				return new Object();
42 42
 			}
Please login to merge, or discard this patch.
modules/communication/communication.mobile.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 	/**
36 36
 	 * Display message box
37
-	 * @return void|Object (void : success, Object : fail)
37
+	 * @return ModuleObject|null (void : success, Object : fail)
38 38
 	 */
39 39
 	function dispCommunicationMessages()
40 40
 	{
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 	/**
132 132
 	 * Display message sending
133
-	 * @return void|Object (void : success, Object : fail)
133
+	 * @return ModuleObject|null (void : success, Object : fail)
134 134
 	 */
135 135
 	function dispCommunicationSendMessage()
136 136
 	{
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 		$oLayoutModel = getModel('layout');
27 27
 		$layout_info = $oLayoutModel->getLayout($this->communication_config->mlayout_srl);
28
-		if($layout_info)
28
+		if ($layout_info)
29 29
 		{
30 30
 			$this->module_info->mlayout_srl = $this->communication_config->mlayout_srl;
31 31
 			$this->setLayoutPath($layout_info->path);
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	function dispCommunicationMessages()
40 40
 	{
41 41
 		// Error appears if not logged-in
42
-		if(!Context::get('is_logged'))
42
+		if (!Context::get('is_logged'))
43 43
 		{
44 44
 			return $this->stop('msg_not_logged');
45 45
 		}
46 46
 
47 47
 		$logged_info = Context::get('logged_info');
48
-		if(!array_key_exists('dispCommunicationMessages', $logged_info->menu_list))
48
+		if (!array_key_exists('dispCommunicationMessages', $logged_info->menu_list))
49 49
 		{
50 50
 			return $this->stop('msg_invalid_request');
51 51
 		}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		// Set the variables
54 54
 		$message_srl = Context::get('message_srl');
55 55
 		$message_type = Context::get('message_type');
56
-		if(!in_array($message_type, array('R', 'S', 'T')))
56
+		if (!in_array($message_type, array('R', 'S', 'T')))
57 57
 		{
58 58
 			$message_type = 'R';
59 59
 			Context::set('message_type', $message_type);
@@ -61,37 +61,37 @@  discard block
 block discarded – undo
61 61
 		$oCommunicationModel = getModel('communication');
62 62
 
63 63
 		// extract contents if message_srl exists
64
-		if($message_srl)
64
+		if ($message_srl)
65 65
 		{
66 66
 			$templateFile = 'read_message';
67 67
 			$columnList = array('message_srl', 'sender_srl', 'receiver_srl', 'message_type', 'title', 'content', 'readed', 'regdate');
68 68
 			$message = $oCommunicationModel->getSelectedMessage($message_srl, $columnList);
69 69
 
70
-			switch($message->message_type)
70
+			switch ($message->message_type)
71 71
 			{
72 72
 				case 'R':
73
-					if($message->receiver_srl != $logged_info->member_srl)
73
+					if ($message->receiver_srl != $logged_info->member_srl)
74 74
 					{
75 75
 						return $this->stop('msg_invalid_request');
76 76
 					}
77 77
 					break;
78 78
 
79 79
 				case 'S':
80
-					if($message->sender_srl != $logged_info->member_srl)
80
+					if ($message->sender_srl != $logged_info->member_srl)
81 81
 					{
82 82
 						return $this->stop('msg_invalid_request');
83 83
 					}
84 84
 					break;
85 85
 
86 86
 				case 'T':
87
-					if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
87
+					if ($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
88 88
 					{
89 89
 						return $this->stop('msg_invalid_request');
90 90
 					}
91 91
 					break;
92 92
 			}
93 93
 
94
-			if($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl))
94
+			if ($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl))
95 95
 			{
96 96
 				stripEmbedTagForAdmin($message->content, $message->sender_srl);
97 97
 				Context::set('message', $message);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		$oMemberModel = getModel('member');
139 139
 
140 140
 		// Error appears if not logged-in
141
-		if(!Context::get('is_logged'))
141
+		if (!Context::get('is_logged'))
142 142
 		{
143 143
 			return $this->stop('msg_not_logged');
144 144
 		}
@@ -148,23 +148,23 @@  discard block
 block discarded – undo
148 148
 		// get receipient's information
149 149
 		// check inalid request
150 150
 		$receiver_srl = Context::get('receiver_srl');
151
-		if(!$receiver_srl)
151
+		if (!$receiver_srl)
152 152
 		{
153 153
 			return $this->stop('msg_invalid_request');
154 154
 		}
155 155
 
156 156
 		// check receiver and sender are same
157
-		if($logged_info->member_srl == $receiver_srl)
157
+		if ($logged_info->member_srl == $receiver_srl)
158 158
 		{
159 159
 			return $this->stop('msg_cannot_send_to_yourself');
160 160
 		}
161 161
 
162 162
 		// get message_srl of the original message if it is a reply
163 163
 		$message_srl = Context::get('message_srl');
164
-		if($message_srl)
164
+		if ($message_srl)
165 165
 		{
166 166
 			$source_message = $oCommunicationModel->getSelectedMessage($message_srl);
167
-			if($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl)
167
+			if ($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl)
168 168
 			{
169 169
 				$source_message->title = "[re] " . $source_message->title;
170 170
 				$source_message->content = "\r\n<br />\r\n<br /><div style=\"padding-left:5px; border-left:5px solid #DDDDDD;\">" . trim($source_message->content) . "</div>";
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		}
174 174
 
175 175
 		$receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
176
-		if(!$receiver_info)
176
+		if (!$receiver_info)
177 177
 		{
178 178
 			return $this->stop('msg_invalid_request');
179 179
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,7 @@
 block discarded – undo
96 96
 				stripEmbedTagForAdmin($message->content, $message->sender_srl);
97 97
 				Context::set('message', $message);
98 98
 			}
99
-		}
100
-		else
99
+		} else
101 100
 		{
102 101
 			$templateFile = 'messages';
103 102
 		}
Please login to merge, or discard this patch.
modules/communication/communication.model.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,6 @@
 block discarded – undo
101 101
 
102 102
 	/**
103 103
 	  * @brief check member's grant
104
-	  * @param object $member_info
105 104
 	  * @param array $arrGrant
106 105
 	  * @return boolean
107 106
 	  */
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 	/**
64
-	  * @brief get grant array for insert to database. table module_config's config field 
65
-	  * @param string $default
66
-	  * @param array $group
67
-	  * @return array
68
-	  */
64
+	 * @brief get grant array for insert to database. table module_config's config field 
65
+	 * @param string $default
66
+	 * @param array $group
67
+	 * @return array
68
+	 */
69 69
 	function getGrantArray($default, $group)
70 70
 	{
71 71
 		$grant = array();
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	/**
103
-	  * @brief check member's grant
104
-	  * @param object $member_info
105
-	  * @param array $arrGrant
106
-	  * @return boolean
107
-	  */
103
+	 * @brief check member's grant
104
+	 * @param object $member_info
105
+	 * @param array $arrGrant
106
+	 * @return boolean
107
+	 */
108 108
 	function checkGrant($arrGrant)
109 109
 	{
110 110
 		if(!$arrGrant)
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -27,32 +27,32 @@  discard block
 block discarded – undo
27 27
 		$oModuleModel = getModel('module');
28 28
 		$communication_config = $oModuleModel->getModuleConfig('communication');
29 29
 
30
-		if(!is_object($communication_config))
30
+		if (!is_object($communication_config))
31 31
 		{
32 32
 			$communication_config = new stdClass();
33 33
 		}
34 34
 
35
-		if(!$communication_config->skin)
35
+		if (!$communication_config->skin)
36 36
 		{
37 37
 			$communication_config->skin = 'default';
38 38
 		}
39 39
 
40
-		if(!$communication_config->colorset)
40
+		if (!$communication_config->colorset)
41 41
 		{
42 42
 			$communication_config->colorset = 'white';
43 43
 		}
44 44
 
45
-		if(!$communication_config->editor_skin)
45
+		if (!$communication_config->editor_skin)
46 46
 		{
47 47
 			$communication_config->editor_skin = 'ckeditor';
48 48
 		}
49 49
 
50
-		if(!$communication_config->mskin)
50
+		if (!$communication_config->mskin)
51 51
 		{
52 52
 			$communication_config->mskin = 'default';
53 53
 		}
54 54
 		
55
-		if(!$communication_config->grant_write)
55
+		if (!$communication_config->grant_write)
56 56
 		{
57 57
 			$communication_config->grant_write = array('default_grant'=>'member');
58 58
 		}
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	function getGrantArray($default, $group)
70 70
 	{
71 71
 		$grant = array();
72
-		if($default!="")
72
+		if ($default != "")
73 73
 		{
74
-			switch($default)
74
+			switch ($default)
75 75
 			{
76 76
 				case "-2":
77 77
 					$grant = array("default_grant"=>"site");
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 					break;
85 85
 			}
86 86
 		} 
87
-		else if(is_array($group)) 
87
+		else if (is_array($group)) 
88 88
 		{
89 89
 			$oMemberModel = getModel('member');
90 90
 			$group_list = $oMemberModel->getGroups($this->site_srl);
91 91
 
92 92
 			$group_grant = array();
93
-			foreach($group as $group_srl)
93
+			foreach ($group as $group_srl)
94 94
 			{
95 95
 				$group_grant[$group_srl] = $group_list[$group_srl]->title;
96 96
 			}
@@ -107,37 +107,37 @@  discard block
 block discarded – undo
107 107
 	  */
108 108
 	function checkGrant($arrGrant)
109 109
 	{
110
-		if(!$arrGrant)
110
+		if (!$arrGrant)
111 111
 			return false;
112 112
 
113 113
 		$logged_info = Context::get('logged_info');
114
-		if(!$logged_info)
114
+		if (!$logged_info)
115 115
 			return false;
116 116
 
117
-		if($logged_info->is_admin == "Y")
117
+		if ($logged_info->is_admin == "Y")
118 118
 			return true;
119 119
 
120
-		if($arrGrant['default_grant'])
120
+		if ($arrGrant['default_grant'])
121 121
 		{
122
-			if($arrGrant['default_grant'] == "member" && $logged_info)
122
+			if ($arrGrant['default_grant'] == "member" && $logged_info)
123 123
 				return true;
124 124
 
125
-			if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl)
125
+			if ($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl)
126 126
 				return true;
127 127
 
128
-			if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y")
128
+			if ($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y")
129 129
 				return true;
130 130
 		}
131 131
 
132
-		if($arrGrant['group_grant'])
132
+		if ($arrGrant['group_grant'])
133 133
 		{
134 134
 			$group_grant = $arrGrant['group_grant'];
135
-			if(!is_array($group_grant))
135
+			if (!is_array($group_grant))
136 136
 				return false;
137 137
 
138
-			foreach($logged_info->group_list as $group_srl=>$title)
138
+			foreach ($logged_info->group_list as $group_srl=>$title)
139 139
 			{
140
-				if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title)
140
+				if (isset($group_grant[$group_srl]) && $group_grant[$group_srl] == $title)
141 141
 					return true;
142 142
 			}
143 143
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		$output = executeQuery('communication.getMessage', $args, $columnList);
163 163
 
164 164
 		$message = $output->data;
165
-		if(!$message)
165
+		if (!$message)
166 166
 		{
167 167
 			return;
168 168
 		}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		// get recipient's information if it is a sent message
171 171
 		$oMemberModel = getModel('member');
172 172
 
173
-		if($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S')
173
+		if ($message->sender_srl == $logged_info->member_srl && $message->message_type == 'S')
174 174
 		{
175 175
 			$member_info = $oMemberModel->getMemberInfoByMemberSrl($message->receiver_srl);
176 176
 		}
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 			$member_info = $oMemberModel->getMemberInfoByMemberSrl($message->sender_srl);
181 181
 		}
182 182
 
183
-		if($member_info)
183
+		if ($member_info)
184 184
 		{
185
-			foreach($member_info as $key => $val)
185
+			foreach ($member_info as $key => $val)
186 186
 			{
187
-				if($key != 'regdate')
187
+				if ($key != 'regdate')
188 188
 				{
189 189
 					$message->{$key} = $val;
190 190
 				}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 		}
193 193
 
194 194
 		// change the status if is a received and not yet read message
195
-		if($message->message_type == 'R' && $message->readed != 'Y')
195
+		if ($message->message_type == 'R' && $message->readed != 'Y')
196 196
 		{
197 197
 			$oCommunicationController = getController('communication');
198 198
 			$oCommunicationController->setMessageReaded($message_srl);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		$args->readed = 'N';
216 216
 
217 217
 		$output = executeQuery('communication.getNewMessage', $args, $columnList);
218
-		if(!count($output->data))
218
+		if (!count($output->data))
219 219
 		{
220 220
 			return;
221 221
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		$logged_info = Context::get('logged_info');
240 240
 		$args = new stdClass();
241 241
 
242
-		switch($message_type)
242
+		switch ($message_type)
243 243
 		{
244 244
 			case 'R' :
245 245
 				$args->member_srl = $logged_info->member_srl;
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		$output = executeQueryArray('communication.getFriendGroups', $args);
345 345
 
346 346
 		$group_list = $output->data;
347
-		if(!$group_list)
347
+		if (!$group_list)
348 348
 		{
349 349
 			return;
350 350
 		}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 
368 368
 		$output = executeQuery('communication.isAddedFriend', $args);
369 369
 
370
-		if($output->data->count)
370
+		if ($output->data->count)
371 371
 		{
372 372
 			return TRUE;
373 373
 		}
Please login to merge, or discard this patch.
Braces   +25 added lines, -18 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
 					$grant = array("default_grant"=>"member");
84 84
 					break;
85 85
 			}
86
-		} 
87
-		else if(is_array($group)) 
86
+		} else if(is_array($group)) 
88 87
 		{
89 88
 			$oMemberModel = getModel('member');
90 89
 			$group_list = $oMemberModel->getGroups($this->site_srl);
@@ -107,38 +106,46 @@  discard block
 block discarded – undo
107 106
 	  */
108 107
 	function checkGrant($arrGrant)
109 108
 	{
110
-		if(!$arrGrant)
111
-			return false;
109
+		if(!$arrGrant) {
110
+					return false;
111
+		}
112 112
 
113 113
 		$logged_info = Context::get('logged_info');
114
-		if(!$logged_info)
115
-			return false;
114
+		if(!$logged_info) {
115
+					return false;
116
+		}
116 117
 
117
-		if($logged_info->is_admin == "Y")
118
-			return true;
118
+		if($logged_info->is_admin == "Y") {
119
+					return true;
120
+		}
119 121
 
120 122
 		if($arrGrant['default_grant'])
121 123
 		{
122
-			if($arrGrant['default_grant'] == "member" && $logged_info)
123
-				return true;
124
+			if($arrGrant['default_grant'] == "member" && $logged_info) {
125
+							return true;
126
+			}
124 127
 
125
-			if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl)
126
-				return true;
128
+			if($arrGrant['default_grant'] == "site" && $this->site_srl == $logged_info->site_srl) {
129
+							return true;
130
+			}
127 131
 
128
-			if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y")
129
-				return true;
132
+			if($arrGrant['default_grant'] == "manager" && $logged_info->is_admin == "Y") {
133
+							return true;
134
+			}
130 135
 		}
131 136
 
132 137
 		if($arrGrant['group_grant'])
133 138
 		{
134 139
 			$group_grant = $arrGrant['group_grant'];
135
-			if(!is_array($group_grant))
136
-				return false;
140
+			if(!is_array($group_grant)) {
141
+							return false;
142
+			}
137 143
 
138 144
 			foreach($logged_info->group_list as $group_srl=>$title)
139 145
 			{
140
-				if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title)
141
-					return true;
146
+				if(isset($group_grant[$group_srl])&&$group_grant[$group_srl]==$title) {
147
+									return true;
148
+				}
142 149
 			}
143 150
 
144 151
 		}
Please login to merge, or discard this patch.
modules/communication/communication.view.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 	/**
48 48
 	 * Display message box
49
-	 * @return void|Object (void : success, Object : fail)
49
+	 * @return ModuleObject|null (void : success, Object : fail)
50 50
 	 */
51 51
 	function dispCommunicationMessages()
52 52
 	{
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 	/**
133 133
 	 * display a new message
134
-	 * @return void|Object (void : success, Object : fail)
134
+	 * @return ModuleObject|null (void : success, Object : fail)
135 135
 	 */
136 136
 	function dispCommunicationNewMessage()
137 137
 	{
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 	/**
169 169
 	 * Display message sending
170
-	 * @return void|Object (void : success, Object : fail)
170
+	 * @return ModuleObject|null (void : success, Object : fail)
171 171
 	 */
172 172
 	function dispCommunicationSendMessage()
173 173
 	{
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 	/**
244 244
 	 * display a list of friends
245
-	 * @return void|Object (void : success, Object : fail)
245
+	 * @return ModuleObject|null (void : success, Object : fail)
246 246
 	 */
247 247
 	function dispCommunicationFriend()
248 248
 	{
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 	/**
300 300
 	 * display Add a friend
301
-	 * @return void|Object (void : success, Object : fail)
301
+	 * @return ModuleObject|null (void : success, Object : fail)
302 302
 	 */
303 303
 	function dispCommunicationAddFriend()
304 304
 	{
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 
341 341
 	/**
342 342
 	 * display add a group of friends
343
-	 * @return void|Object (void : success, Object : fail)
343
+	 * @return ModuleObject|null (void : success, Object : fail)
344 344
 	 */
345 345
 	function dispCommunicationAddFriendGroup()
346 346
 	{
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 		$config_parse = explode('|@|', $skin);
26 26
 
27
-		if(count($config_parse) > 1)
27
+		if (count($config_parse) > 1)
28 28
 		{
29 29
 			$tpl_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]);
30 30
 		}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 		$oLayoutModel = getModel('layout');
39 39
 		$layout_info = $oLayoutModel->getLayout($this->communication_config->layout_srl);
40
-		if($layout_info)
40
+		if ($layout_info)
41 41
 		{
42 42
 			$this->module_info->layout_srl = $this->communication_config->layout_srl;
43 43
 			$this->setLayoutPath($layout_info->path);
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	function dispCommunicationMessages()
52 52
 	{
53 53
 		// Error appears if not logged-in
54
-		if(!Context::get('is_logged'))
54
+		if (!Context::get('is_logged'))
55 55
 		{
56 56
 			return $this->stop('msg_not_logged');
57 57
 		}
58 58
 
59 59
 		$logged_info = Context::get('logged_info');
60 60
 
61
-		if(!array_key_exists('dispCommunicationMessages', $logged_info->menu_list))
61
+		if (!array_key_exists('dispCommunicationMessages', $logged_info->menu_list))
62 62
 		{
63 63
 			return $this->stop('msg_invalid_request');
64 64
 		}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$message_srl = Context::get('message_srl');
68 68
 		$message_type = Context::get('message_type');
69 69
 
70
-		if(!in_array($message_type, array('R', 'S', 'T')))
70
+		if (!in_array($message_type, array('R', 'S', 'T')))
71 71
 		{
72 72
 			$message_type = 'R';
73 73
 			Context::set('message_type', $message_type);
@@ -76,36 +76,36 @@  discard block
 block discarded – undo
76 76
 		$oCommunicationModel = getModel('communication');
77 77
 
78 78
 		// extract contents if message_srl exists
79
-		if($message_srl)
79
+		if ($message_srl)
80 80
 		{
81 81
 			$columnList = array('message_srl', 'sender_srl', 'receiver_srl', 'message_type', 'title', 'content', 'readed', 'regdate');
82 82
 			$message = $oCommunicationModel->getSelectedMessage($message_srl, $columnList);
83 83
 
84
-			switch($message->message_type)
84
+			switch ($message->message_type)
85 85
 			{
86 86
 				case 'R':
87
-					if($message->receiver_srl != $logged_info->member_srl)
87
+					if ($message->receiver_srl != $logged_info->member_srl)
88 88
 					{
89 89
 						return $this->stop('msg_invalid_request');
90 90
 					}
91 91
 					break;
92 92
 
93 93
 				case 'S':
94
-					if($message->sender_srl != $logged_info->member_srl)
94
+					if ($message->sender_srl != $logged_info->member_srl)
95 95
 					{
96 96
 						return $this->stop('msg_invalid_request');
97 97
 					}
98 98
 					break;
99 99
 
100 100
 				case 'T':
101
-					if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
101
+					if ($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
102 102
 					{
103 103
 						return $this->stop('msg_invalid_request');
104 104
 					}
105 105
 					break;
106 106
 			}
107 107
 
108
-			if($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl))
108
+			if ($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl))
109 109
 			{
110 110
 				stripEmbedTagForAdmin($message->content, $message->sender_srl);
111 111
 				Context::set('message', $message);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$this->setLayoutFile('popup_layout');
140 140
 
141 141
 		// Error appears if not logged-in
142
-		if(!Context::get('is_logged'))
142
+		if (!Context::get('is_logged'))
143 143
 		{
144 144
 			return $this->stop('msg_not_logged');
145 145
 		}
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		// get a new message
152 152
 		$columnList = array('message_srl', 'member_srl', 'nick_name', 'title', 'content', 'sender_srl');
153 153
 		$message = $oCommunicationModel->getNewMessage($columnList);
154
-		if($message)
154
+		if ($message)
155 155
 		{
156 156
 			stripEmbedTagForAdmin($message->content, $message->sender_srl);
157 157
 			Context::set('message', $message);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		$oMemberModel = getModel('member');
179 179
 
180 180
 		// Error appears if not logged-in
181
-		if(!Context::get('is_logged'))
181
+		if (!Context::get('is_logged'))
182 182
 		{
183 183
 			return $this->stop('msg_not_logged');
184 184
 		}
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 		// get receipient's information
189 189
 		// check inalid request
190 190
 		$receiver_srl = Context::get('receiver_srl');
191
-		if(!$receiver_srl)
191
+		if (!$receiver_srl)
192 192
 		{
193 193
 			return $this->stop('msg_invalid_request');
194 194
 		}
195 195
 
196 196
 		// check receiver and sender are same
197
-		if($logged_info->member_srl == $receiver_srl)
197
+		if ($logged_info->member_srl == $receiver_srl)
198 198
 		{
199 199
 			return $this->stop('msg_cannot_send_to_yourself');
200 200
 		}
201 201
 
202 202
 		// get message_srl of the original message if it is a reply
203 203
 		$message_srl = Context::get('message_srl');
204
-		if($message_srl)
204
+		if ($message_srl)
205 205
 		{
206 206
 			$source_message = $oCommunicationModel->getSelectedMessage($message_srl);
207
-			if($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl)
207
+			if ($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl)
208 208
 			{
209 209
 				$source_message->title = "[re] " . $source_message->title;
210 210
 				$source_message->content = "\r\n<br />\r\n<br /><div style=\"padding-left:5px; border-left:5px solid #DDDDDD;\">" . trim($source_message->content) . "</div>";
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		}
214 214
 
215 215
 		$receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
216
-		if(!$receiver_info)
216
+		if (!$receiver_info)
217 217
 		{
218 218
 			return $this->stop('msg_invalid_request');
219 219
 		}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	function dispCommunicationFriend()
248 248
 	{
249 249
 		// Error appears if not logged-in
250
-		if(!Context::get('is_logged'))
250
+		if (!Context::get('is_logged'))
251 251
 		{
252 252
 			return $this->stop('msg_not_logged');
253 253
 		}
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		$tmp_group_list = $oCommunicationModel->getFriendGroups();
259 259
 		$group_count = count($tmp_group_list);
260 260
 
261
-		for($i = 0; $i < $group_count; $i++)
261
+		for ($i = 0; $i < $group_count; $i++)
262 262
 		{
263 263
 			$friend_group_list[$tmp_group_list[$i]->friend_group_srl] = $tmp_group_list[$i];
264 264
 		}
@@ -272,13 +272,13 @@  discard block
 block discarded – undo
272 272
 		$output = $oCommunicationModel->getFriends($friend_group_srl, $columnList);
273 273
 		$friend_count = count($output->data);
274 274
 
275
-		if($friend_count)
275
+		if ($friend_count)
276 276
 		{
277
-			foreach($output->data as $key => $val)
277
+			foreach ($output->data as $key => $val)
278 278
 			{
279 279
 				$group_srl = $val->friend_group_srl;
280 280
 				$group_title = $friend_group_list[$group_srl]->title;
281
-				if(!$group_title)
281
+				if (!$group_title)
282 282
 				{
283 283
 					$group_title = Context::get('default_friend_group');
284 284
 				}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		$this->setLayoutFile("popup_layout");
307 307
 
308 308
 		// error appears if not logged-in
309
-		if(!Context::get('is_logged'))
309
+		if (!Context::get('is_logged'))
310 310
 		{
311 311
 			return $this->stop('msg_not_logged');
312 312
 		}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		$logged_info = Context::get('logged_info');
315 315
 		$target_srl = Context::get('target_srl');
316 316
 
317
-		if(!$target_srl)
317
+		if (!$target_srl)
318 318
 		{
319 319
 			return $this->stop('msg_invalid_request');
320 320
 		}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		$oCommunicationModel = getModel('communication');
325 325
 		$communication_info = $oMemberModel->getMemberInfoByMemberSrl($target_srl);
326 326
 
327
-		if($communication_info->member_srl != $target_srl)
327
+		if ($communication_info->member_srl != $target_srl)
328 328
 		{
329 329
 			return $this->stop('msg_invalid_request');
330 330
 		}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		$this->setLayoutFile("popup_layout");
349 349
 
350 350
 		// error apprears if not logged-in
351
-		if(!Context::get('is_logged'))
351
+		if (!Context::get('is_logged'))
352 352
 		{
353 353
 			return $this->stop('msg_not_logged');
354 354
 		}
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
 
358 358
 		// change to edit mode when getting the group_srl
359 359
 		$friend_group_srl = Context::get('friend_group_srl');
360
-		if($friend_group_srl)
360
+		if ($friend_group_srl)
361 361
 		{
362 362
 			$oCommunicationModel = getModel('communication');
363 363
 			$friend_group = $oCommunicationModel->getFriendGroupInfo($friend_group_srl);
364
-			if($friend_group->friend_group_srl == $friend_group_srl)
364
+			if ($friend_group->friend_group_srl == $friend_group_srl)
365 365
 			{
366 366
 				Context::set('friend_group', $friend_group);
367 367
 			}
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@
 block discarded – undo
27 27
 		if(count($config_parse) > 1)
28 28
 		{
29 29
 			$tpl_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]);
30
-		}
31
-		else
30
+		} else
32 31
 		{
33 32
 			$tpl_path = sprintf('%sskins/%s', $this->module_path, $skin);
34 33
 		}
Please login to merge, or discard this patch.
modules/document/document.admin.controller.php 4 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	/**
23 23
 	 * Remove the selected docs from admin page
24
-	 * @return void
24
+	 * @return ModuleObject|null
25 25
 	 */
26 26
 	function procDocumentAdminDeleteChecked()
27 27
 	{
@@ -519,6 +519,7 @@  discard block
 block discarded – undo
519 519
 
520 520
 	/**
521 521
 	 * Delete thumbnails with subdirectory
522
+	 * @param string $path
522 523
 	 * @return void
523 524
 	 */
524 525
 	function deleteThumbnailFile($path)
@@ -861,7 +862,7 @@  discard block
 block discarded – undo
861 862
 	/**
862 863
 	 * Restore document from trash module, called by trash module
863 864
 	 * This method is passived
864
-	 * @param object|array $originObject
865
+	 * @param string $originObject
865 866
 	 * @return object
866 867
 	 */
867 868
 	function restoreTrash($originObject)
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -721,10 +721,10 @@
 block discarded – undo
721 721
 	}
722 722
 
723 723
 	/**
724
-	  * @fn procDocumentAdminMoveToTrash
725
-	  * @brief move a document to trash.
726
-	  * @see documentModel::getDocumentMenu
727
-	  */
724
+	 * @fn procDocumentAdminMoveToTrash
725
+	 * @brief move a document to trash.
726
+	 * @see documentModel::getDocumentMenu
727
+	 */
728 728
 	function procDocumentAdminMoveToTrash()
729 729
 	{
730 730
 		$document_srl = Context::get('document_srl');
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		// error appears if no doc is selected
29 29
 		$cart = Context::get('cart');
30
-		if(!$cart) return $this->stop('msg_cart_is_null');
31
-		$document_srl_list= explode('|@|', $cart);
30
+		if (!$cart) return $this->stop('msg_cart_is_null');
31
+		$document_srl_list = explode('|@|', $cart);
32 32
 		$document_count = count($document_srl_list);
33
-		if(!$document_count) return $this->stop('msg_cart_is_null');
33
+		if (!$document_count) return $this->stop('msg_cart_is_null');
34 34
 		// Delete a doc
35 35
 		$oDocumentController = getController('document');
36
-		for($i=0;$i<$document_count;$i++)
36
+		for ($i = 0; $i < $document_count; $i++)
37 37
 		{
38 38
 			$document_srl = trim($document_srl_list[$i]);
39
-			if(!$document_srl) continue;
39
+			if (!$document_srl) continue;
40 40
 
41 41
 			$oDocumentController->deleteDocument($document_srl, true);
42 42
 		}
43 43
 
44
-		$this->setMessage(sprintf(Context::getLang('msg_checked_document_is_deleted'), $document_count) );
44
+		$this->setMessage(sprintf(Context::getLang('msg_checked_document_is_deleted'), $document_count));
45 45
 	}
46 46
 
47 47
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function moveDocumentModule($document_srl_list, $module_srl, $category_srl)
55 55
 	{
56
-		if(!count($document_srl_list)) return;
56
+		if (!count($document_srl_list)) return;
57 57
 
58 58
 		$oDocumentModel = getModel('document');
59 59
 		$oDocumentController = getController('document');
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
 		$oDB->begin();
63 63
 
64 64
 		$triggerObj = new stdClass();
65
-		$triggerObj->document_srls = implode(',',$document_srl_list);
65
+		$triggerObj->document_srls = implode(',', $document_srl_list);
66 66
 		$triggerObj->module_srl = $module_srl;
67 67
 		$triggerObj->category_srl = $category_srl;
68 68
 		// Call a trigger (before)
69 69
 		$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $triggerObj);
70
-		if(!$output->toBool())
70
+		if (!$output->toBool())
71 71
 		{
72 72
 			$oDB->rollback();
73 73
 			return $output;
74 74
 		}
75 75
 
76
-		for($i=count($document_srl_list)-1;$i>=0;$i--)
76
+		for ($i = count($document_srl_list) - 1; $i >= 0; $i--)
77 77
 		{
78 78
 			$document_srl = $document_srl_list[$i];
79 79
 			$oDocument = $oDocumentModel->getDocument($document_srl);
80
-			if(!$oDocument->isExists()) continue;
80
+			if (!$oDocument->isExists()) continue;
81 81
 
82 82
 			$source_category_srl = $oDocument->get('category_srl');
83 83
 
@@ -90,34 +90,34 @@  discard block
 block discarded – undo
90 90
 			$obj->content = $output_ori->data->content;
91 91
 
92 92
 			// Move the attached file if the target module is different
93
-			if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
93
+			if ($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
94 94
 			{
95 95
 				$oFileController = getController('file');
96 96
 
97 97
 				$files = $oDocument->getUploadedFiles();
98 98
 				$delete_file_srls = array();
99
-				if(is_array($files))
99
+				if (is_array($files))
100 100
 				{
101
-					foreach($files as $val)
101
+					foreach ($files as $val)
102 102
 					{
103 103
 						$file_info = array();
104 104
 						$file_info['tmp_name'] = $val->uploaded_filename;
105 105
 						$file_info['name'] = $val->source_filename;
106 106
 						$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, $val->download_count, true);
107
-						if($inserted_file && $inserted_file->toBool())
107
+						if ($inserted_file && $inserted_file->toBool())
108 108
 						{
109 109
 							// for image/video files
110
-							if($val->direct_download == 'Y')
110
+							if ($val->direct_download == 'Y')
111 111
 							{
112
-								$source_filename = substr($val->uploaded_filename,2);
113
-								$target_filename = substr($inserted_file->get('uploaded_filename'),2);
112
+								$source_filename = substr($val->uploaded_filename, 2);
113
+								$target_filename = substr($inserted_file->get('uploaded_filename'), 2);
114 114
 								$obj->content = str_replace($source_filename, $target_filename, $obj->content);
115 115
 								// For binary files
116 116
 							}
117 117
 							else
118 118
 							{
119
-								$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
120
-								$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
119
+								$obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $obj->content);
120
+								$obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $obj->content);
121 121
 							}
122 122
 						}
123 123
 						$delete_file_srls[] = $val->file_srl;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 				$oFileController->setFilesValid($obj->document_srl);
130 130
 			}
131 131
 
132
-			if($module_srl != $obj->module_srl)
132
+			if ($module_srl != $obj->module_srl)
133 133
 			{
134 134
 				$oDocumentController->deleteDocumentAliasByDocument($obj->document_srl);
135 135
 			}
@@ -137,48 +137,48 @@  discard block
 block discarded – undo
137 137
 			$obj->module_srl = $module_srl;
138 138
 			$obj->category_srl = $category_srl;
139 139
 			$output = executeQuery('document.updateDocumentModule', $obj);
140
-			if(!$output->toBool()) {
140
+			if (!$output->toBool()) {
141 141
 				$oDB->rollback();
142 142
 				return $output;
143 143
 			}
144 144
 
145 145
 			//Move a module of the extra vars
146 146
 			$output = executeQuery('document.moveDocumentExtraVars', $obj);
147
-			if(!$output->toBool()) {
147
+			if (!$output->toBool()) {
148 148
 				$oDB->rollback();
149 149
 				return $output;
150 150
 			}
151 151
 			// Set 0 if a new category doesn't exist after catergory change
152
-			if($source_category_srl != $category_srl)
152
+			if ($source_category_srl != $category_srl)
153 153
 			{
154
-				if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
155
-				if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
154
+				if ($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
155
+				if ($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
156 156
 			}
157 157
 		}
158 158
 
159 159
 		$args = new stdClass();
160
-		$args->document_srls = implode(',',$document_srl_list);
160
+		$args->document_srls = implode(',', $document_srl_list);
161 161
 		$args->module_srl = $module_srl;
162 162
 		// move the comment
163 163
 		$output = executeQuery('comment.updateCommentModule', $args);
164
-		if(!$output->toBool())
164
+		if (!$output->toBool())
165 165
 		{
166 166
 			$oDB->rollback();
167 167
 			return $output;
168 168
 		}
169 169
 
170 170
 		$output = executeQuery('comment.updateCommentListModule', $args);
171
-		if(!$output->toBool())
171
+		if (!$output->toBool())
172 172
 		{
173 173
 			$oDB->rollback();
174 174
 			return $output;
175 175
 		}
176 176
 		
177 177
 		// move the trackback
178
-		if(getClass('trackback'))
178
+		if (getClass('trackback'))
179 179
 		{
180 180
 			$output = executeQuery('trackback.updateTrackbackModule', $args);
181
-			if(!$output->toBool())
181
+			if (!$output->toBool())
182 182
 			{
183 183
 				$oDB->rollback();
184 184
 				return $output;
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 
188 188
 		// Tags
189 189
 		$output = executeQuery('tag.updateTagModule', $args);
190
-		if(!$output->toBool())
190
+		if (!$output->toBool())
191 191
 		{
192 192
 			$oDB->rollback();
193 193
 			return $output;
194 194
 		}
195 195
 		// Call a trigger (before)
196 196
 		$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $triggerObj);
197
-		if(!$output->toBool())
197
+		if (!$output->toBool())
198 198
 		{
199 199
 			$oDB->rollback();
200 200
 			return $output;
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		$oDB->commit();
204 204
 		//remove from cache
205 205
 		$oCacheHandler = CacheHandler::getInstance('object');
206
-		if($oCacheHandler->isSupport())
206
+		if ($oCacheHandler->isSupport())
207 207
 		{
208
-			foreach($document_srl_list as $document_srl)
208
+			foreach ($document_srl_list as $document_srl)
209 209
 			{
210
-				$cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
210
+				$cache_key_item = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
211 211
 				$oCacheHandler->delete($cache_key_item);
212 212
 			}
213 213
 		}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	function copyDocumentModule($document_srl_list, $module_srl, $category_srl)
225 225
 	{
226
-		if(count($document_srl_list) < 1) return;
226
+		if (count($document_srl_list) < 1) return;
227 227
 
228 228
 		$oDocumentModel = getModel('document');
229 229
 		$oDocumentController = getController('document');
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 		$oDB->begin();
235 235
 
236 236
 		$triggerObj = new stdClass();
237
-		$triggerObj->document_srls = implode(',',$document_srl_list);
237
+		$triggerObj->document_srls = implode(',', $document_srl_list);
238 238
 		$triggerObj->module_srl = $module_srl;
239 239
 		$triggerObj->category_srl = $category_srl;
240 240
 		// Call a trigger (before)
241 241
 		$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj);
242
-		if(!$output->toBool())
242
+		if (!$output->toBool())
243 243
 		{
244 244
 			$oDB->rollback();
245 245
 			return $output;
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 
248 248
 		$extraVarsList = $oDocumentModel->getDocumentExtraVarsFromDB($document_srl_list);
249 249
 		$extraVarsListByDocumentSrl = array();
250
-		if(is_array($extraVarsList->data))
250
+		if (is_array($extraVarsList->data))
251 251
 		{
252
-			foreach($extraVarsList->data as $value)
252
+			foreach ($extraVarsList->data as $value)
253 253
 			{
254
-				if(!isset($extraVarsListByDocumentSrl[$value->document_srl]))
254
+				if (!isset($extraVarsListByDocumentSrl[$value->document_srl]))
255 255
 				{
256 256
 					$extraVarsListByDocumentSrl[$value->document_srl] = array();
257 257
 				}
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
 			}
261 261
 		}
262 262
 
263
-		for($i=count($document_srl_list)-1;$i>=0;$i--)
263
+		for ($i = count($document_srl_list) - 1; $i >= 0; $i--)
264 264
 		{
265 265
 			$document_srl = $document_srl_list[$i];
266 266
 			$oDocument = $oDocumentModel->getDocument($document_srl);
267
-			if(!$oDocument->isExists()) continue;
267
+			if (!$oDocument->isExists()) continue;
268 268
 
269 269
 			$obj = $oDocument->getObjectVars();
270 270
 
271 271
 			$extraVars = $extraVarsListByDocumentSrl[$document_srl];
272
-			if($module_srl == $obj->module_srl)
272
+			if ($module_srl == $obj->module_srl)
273 273
 			{
274
-				if(is_array($extraVars))
274
+				if (is_array($extraVars))
275 275
 				{
276
-					foreach($extraVars as $extraItem)
276
+					foreach ($extraVars as $extraItem)
277 277
 					{
278
-						if($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value;
278
+						if ($extraItem->var_idx >= 0) $obj->{'extra_vars' . $extraItem->var_idx} = $extraItem->value;
279 279
 					}
280 280
 				}
281 281
 			}
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
 			$obj->trackback_count = 0;
288 288
 
289 289
 			// Pre-register the attachment
290
-			if($oDocument->hasUploadedFiles())
290
+			if ($oDocument->hasUploadedFiles())
291 291
 			{
292 292
 				$files = $oDocument->getUploadedFiles();
293
-				foreach($files as $val)
293
+				foreach ($files as $val)
294 294
 				{
295 295
 					$file_info = array();
296 296
 					$file_info['tmp_name'] = $val->uploaded_filename;
@@ -298,40 +298,40 @@  discard block
 block discarded – undo
298 298
 					$oFileController = getController('file');
299 299
 					$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
300 300
 					// if image/video files
301
-					if($val->direct_download == 'Y')
301
+					if ($val->direct_download == 'Y')
302 302
 					{
303
-						$source_filename = substr($val->uploaded_filename,2);
304
-						$target_filename = substr($inserted_file->get('uploaded_filename'),2);
303
+						$source_filename = substr($val->uploaded_filename, 2);
304
+						$target_filename = substr($inserted_file->get('uploaded_filename'), 2);
305 305
 						$obj->content = str_replace($source_filename, $target_filename, $obj->content);
306 306
 						// If binary file
307 307
 					}
308 308
 					else
309 309
 					{
310
-						$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
311
-						$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
310
+						$obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $obj->content);
311
+						$obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $obj->content);
312 312
 					}
313 313
 				}
314 314
 			}
315 315
 
316 316
 			// Write a post
317 317
 			$output = $oDocumentController->insertDocument($obj, true, true);
318
-			if(!$output->toBool())
318
+			if (!$output->toBool())
319 319
 			{
320 320
 				$oDB->rollback();
321 321
 				return $output;
322 322
 			}
323 323
 
324 324
 			// copy multi language contents
325
-			if(is_array($extraVars))
325
+			if (is_array($extraVars))
326 326
 			{
327
-				foreach($extraVars as $value)
327
+				foreach ($extraVars as $value)
328 328
 				{
329
-					if($value->idx >= 0 && $value->lang_code == Context::getLangType())
329
+					if ($value->idx >= 0 && $value->lang_code == Context::getLangType())
330 330
 					{
331 331
 						continue;
332 332
 					}
333 333
 
334
-					if( $value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0) )
334
+					if ($value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0))
335 335
 					{
336 336
 						$oDocumentController->insertDocumentExtraVar($value->module_srl, $obj->document_srl, $value->var_idx, $value->value, $value->eid, $value->lang_code);
337 337
 					}
@@ -339,26 +339,26 @@  discard block
 block discarded – undo
339 339
 			}
340 340
 
341 341
 			// Move the comments
342
-			if($oDocument->getCommentCount())
342
+			if ($oDocument->getCommentCount())
343 343
 			{
344 344
 				$oCommentModel = getModel('comment');
345 345
 				$comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999);
346 346
 				$comments = $comment_output->data;
347
-				if(count($comments) > 0)
347
+				if (count($comments) > 0)
348 348
 				{
349 349
 					$oCommentController = getController('comment');
350 350
 					$success_count = 0;
351 351
 					$p_comment_srl = array();
352
-					foreach($comments as $comment_obj)
352
+					foreach ($comments as $comment_obj)
353 353
 					{
354 354
 						$comment_srl = getNextSequence();
355 355
 						$p_comment_srl[$comment_obj->comment_srl] = $comment_srl;
356 356
 
357 357
 						// Pre-register the attachment
358
-						if($comment_obj->uploaded_count)
358
+						if ($comment_obj->uploaded_count)
359 359
 						{
360 360
 							$files = $oFileModel->getFiles($comment_obj->comment_srl, true);
361
-							foreach($files as $val)
361
+							foreach ($files as $val)
362 362
 							{
363 363
 								$file_info = array();
364 364
 								$file_info['tmp_name'] = $val->uploaded_filename;
@@ -366,17 +366,17 @@  discard block
 block discarded – undo
366 366
 								$oFileController = getController('file');
367 367
 								$inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true);
368 368
 								// if image/video files
369
-								if($val->direct_download == 'Y')
369
+								if ($val->direct_download == 'Y')
370 370
 								{
371
-									$source_filename = substr($val->uploaded_filename,2);
372
-									$target_filename = substr($inserted_file->get('uploaded_filename'),2);
371
+									$source_filename = substr($val->uploaded_filename, 2);
372
+									$target_filename = substr($inserted_file->get('uploaded_filename'), 2);
373 373
 									$comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content);
374 374
 									// If binary file
375 375
 								}
376 376
 								else
377 377
 								{
378
-									$comment_obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $comment_obj->content);
379
-									$comment_obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $comment_obj->content);
378
+									$comment_obj->content = str_replace('file_srl=' . $val->file_srl, 'file_srl=' . $inserted_file->get('file_srl'), $comment_obj->content);
379
+									$comment_obj->content = str_replace('sid=' . $val->sid, 'sid=' . $inserted_file->get('sid'), $comment_obj->content);
380 380
 								}
381 381
 							}
382 382
 						}
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 						$comment_obj->document_srl = $obj->document_srl;
386 386
 						$comment_obj->comment_srl = $comment_srl;
387 387
 
388
-						if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
388
+						if ($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
389 389
 
390 390
 						$output = $oCommentController->insertComment($comment_obj, true);
391
-						if($output->toBool()) $success_count ++;
391
+						if ($output->toBool()) $success_count++;
392 392
 					}
393 393
 					$oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
394 394
 				}
@@ -396,19 +396,19 @@  discard block
 block discarded – undo
396 396
 
397 397
 			// Move the trackbacks
398 398
 			$oTrackbackModel = getModel('trackback');
399
-			if($oTrackbackModel && $oDocument->getTrackbackCount())
399
+			if ($oTrackbackModel && $oDocument->getTrackbackCount())
400 400
 			{
401 401
 				$trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl);
402
-				if(count($trackbacks))
402
+				if (count($trackbacks))
403 403
 				{
404 404
 					$success_count = 0;
405
-					foreach($trackbacks as $trackback_obj)
405
+					foreach ($trackbacks as $trackback_obj)
406 406
 					{
407 407
 						$trackback_obj->trackback_srl = getNextSequence();
408 408
 						$trackback_obj->module_srl = $obj->module_srl;
409 409
 						$trackback_obj->document_srl = $obj->document_srl;
410 410
 						$output = executeQuery('trackback.insertTrackback', $trackback_obj);
411
-						if($output->toBool()) $success_count++;
411
+						if ($output->toBool()) $success_count++;
412 412
 					}
413 413
 					// Update the number of trackbacks
414 414
 					$oDocumentController->updateTrackbackCount($obj->document_srl, $success_count);
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		// Call a trigger (before)
422 422
 		$triggerObj->copied_srls = $copied_srls;
423 423
 		$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj);
424
-		if(!$output->toBool())
424
+		if (!$output->toBool())
425 425
 		{
426 426
 			$oDB->rollback();
427 427
 			return $output;
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 		$document_list = $oDocumentModel->getDocumentList($args);
449 449
 		$documents = $document_list->data;
450 450
 		$output = executeQuery('document.deleteModuleDocument', $args);
451
-		if(is_array($documents))
451
+		if (is_array($documents))
452 452
 		{
453 453
 			foreach ($documents as $oDocument)
454 454
 			{
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 		}
458 458
 		//remove from cache
459 459
 		$oCacheHandler = CacheHandler::getInstance('object');
460
-		if($oCacheHandler->isSupport())
460
+		if ($oCacheHandler->isSupport())
461 461
 		{
462
-			if(is_array($document_srl_list))
462
+			if (is_array($document_srl_list))
463 463
 			{
464
-				foreach($document_srl_list as $document_srl)
464
+				foreach ($document_srl_list as $document_srl)
465 465
 				{
466
-					$cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
466
+					$cache_key_item = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
467 467
 					$oCacheHandler->delete($cache_key_item);
468 468
 				}
469 469
 			}
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 		$config = Context::gets('thumbnail_type');
482 482
 		// Insert by creating the module Controller object
483 483
 		$oModuleController = getController('module');
484
-		$output = $oModuleController->insertModuleConfig('document',$config);
484
+		$output = $oModuleController->insertModuleConfig('document', $config);
485 485
 
486 486
 		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispDocumentAdminConfig');
487 487
 		return $this->setRedirectUrl($returnUrl, $output);
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 	{
496 496
 		$document_srl = trim(Context::get('document_srl'));
497 497
 
498
-		if($document_srl)
498
+		if ($document_srl)
499 499
 		{
500 500
 			$args->document_srl = $document_srl;
501 501
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
502
-			if(!$output->toBool()) return $output;
502
+			if (!$output->toBool()) return $output;
503 503
 		}
504 504
 	}
505 505
 
@@ -524,13 +524,13 @@  discard block
 block discarded – undo
524 524
 	function deleteThumbnailFile($path)
525 525
 	{
526 526
 		$directory = dir($path);
527
-		while($entry = $directory->read()) {
527
+		while ($entry = $directory->read()) {
528 528
 			if ($entry != "." && $entry != "..") {
529
-				if (is_dir($path."/".$entry)) {
530
-					$this->deleteThumbnailFile($path."/".$entry);
529
+				if (is_dir($path . "/" . $entry)) {
530
+					$this->deleteThumbnailFile($path . "/" . $entry);
531 531
 				} else {
532
-					if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue;
533
-					FileHandler::removeFile($path.'/'.$entry);
532
+					if (!preg_match('/^thumbnail_([^\.]*)\.jpg$/i', $entry)) continue;
533
+					FileHandler::removeFile($path . '/' . $entry);
534 534
 				}
535 535
 			}
536 536
 		}
@@ -554,13 +554,13 @@  discard block
 block discarded – undo
554 554
 		$eid = Context::get('eid');
555 555
 		$obj = new stdClass();
556 556
 
557
-		if(!$module_srl || !$name || !$eid) return new Object(-1,'msg_invalid_request');
557
+		if (!$module_srl || !$name || !$eid) return new Object(-1, 'msg_invalid_request');
558 558
 		// set the max value if idx is not specified
559
-		if(!$var_idx)
559
+		if (!$var_idx)
560 560
 		{
561 561
 			$obj->module_srl = $module_srl;
562 562
 			$output = executeQuery('document.getDocumentMaxExtraKeyIdx', $obj);
563
-			$var_idx = $output->data->var_idx+1;
563
+			$var_idx = $output->data->var_idx + 1;
564 564
 		}
565 565
 
566 566
 		// Check if the module name already exists
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		$obj->var_idx = $var_idx;
569 569
 		$obj->eid = $eid;
570 570
 		$output = executeQuery('document.isExistsExtraKey', $obj);
571
-		if(!$output->toBool() || $output->data->count)
571
+		if (!$output->toBool() || $output->data->count)
572 572
 		{
573 573
 			return new Object(-1, 'msg_extra_name_exists');
574 574
 		}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 		// insert or update
577 577
 		$oDocumentController = getController('document');
578 578
 		$output = $oDocumentController->insertDocumentExtraKey($module_srl, $var_idx, $name, $type, $is_required, $search, $default, $desc, $eid);
579
-		if(!$output->toBool()) return $output;
579
+		if (!$output->toBool()) return $output;
580 580
 
581 581
 		$this->setMessage('success_registed');
582 582
 
@@ -592,11 +592,11 @@  discard block
 block discarded – undo
592 592
 	{
593 593
 		$module_srl = Context::get('module_srl');
594 594
 		$var_idx = Context::get('var_idx');
595
-		if(!$module_srl || !$var_idx) return new Object(-1,'msg_invalid_request');
595
+		if (!$module_srl || !$var_idx) return new Object(-1, 'msg_invalid_request');
596 596
 
597 597
 		$oDocumentController = getController('document');
598 598
 		$output = $oDocumentController->deleteDocumentExtraKeys($module_srl, $var_idx);
599
-		if(!$output->toBool()) return $output;
599
+		if (!$output->toBool()) return $output;
600 600
 
601 601
 		$this->setMessage('success_deleted');
602 602
 	}
@@ -611,19 +611,19 @@  discard block
 block discarded – undo
611 611
 		$module_srl = Context::get('module_srl');
612 612
 		$var_idx = Context::get('var_idx');
613 613
 
614
-		if(!$type || !$module_srl || !$var_idx) return new Object(-1,'msg_invalid_request');
614
+		if (!$type || !$module_srl || !$var_idx) return new Object(-1, 'msg_invalid_request');
615 615
 
616 616
 		$oModuleModel = getModel('module');
617 617
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
618
-		if(!$module_info->module_srl) return new Object(-1,'msg_invalid_request');
618
+		if (!$module_info->module_srl) return new Object(-1, 'msg_invalid_request');
619 619
 
620 620
 		$oDocumentModel = getModel('document');
621 621
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
622
-		if(!$extra_keys[$var_idx]) return new Object(-1,'msg_invalid_request');
622
+		if (!$extra_keys[$var_idx]) return new Object(-1, 'msg_invalid_request');
623 623
 
624
-		if($type == 'up') $new_idx = $var_idx-1;
625
-		else $new_idx = $var_idx+1;
626
-		if($new_idx<1) return new Object(-1,'msg_invalid_request');
624
+		if ($type == 'up') $new_idx = $var_idx - 1;
625
+		else $new_idx = $var_idx + 1;
626
+		if ($new_idx < 1) return new Object(-1, 'msg_invalid_request');
627 627
 
628 628
 		$args = new stdClass();
629 629
 		$args->module_srl = $module_srl;
@@ -634,16 +634,16 @@  discard block
 block discarded – undo
634 634
 		unset($args);
635 635
 
636 636
 		// update immediately if there is no idx to change
637
-		if(!$extra_keys[$new_idx])
637
+		if (!$extra_keys[$new_idx])
638 638
 		{
639 639
 			$args = new stdClass();
640 640
 			$args->module_srl = $module_srl;
641 641
 			$args->var_idx = $var_idx;
642 642
 			$args->new_idx = $new_idx;
643 643
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
644
-			if(!$output->toBool()) return $output;
644
+			if (!$output->toBool()) return $output;
645 645
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
646
-			if(!$output->toBool()) return $output;
646
+			if (!$output->toBool()) return $output;
647 647
 			// replace if exists
648 648
 		}
649 649
 		else
@@ -653,29 +653,29 @@  discard block
 block discarded – undo
653 653
 			$args->var_idx = $new_idx;
654 654
 			$args->new_idx = -10000;
655 655
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
656
-			if(!$output->toBool()) return $output;
656
+			if (!$output->toBool()) return $output;
657 657
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
658
-			if(!$output->toBool()) return $output;
658
+			if (!$output->toBool()) return $output;
659 659
 
660 660
 			$args->var_idx = $var_idx;
661 661
 			$args->new_idx = $new_idx;
662 662
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
663
-			if(!$output->toBool()) return $output;
663
+			if (!$output->toBool()) return $output;
664 664
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
665
-			if(!$output->toBool()) return $output;
665
+			if (!$output->toBool()) return $output;
666 666
 
667 667
 			$args->var_idx = -10000;
668 668
 			$args->new_idx = $var_idx;
669 669
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
670
-			if(!$output->toBool()) return $output;
670
+			if (!$output->toBool()) return $output;
671 671
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
672
-			if(!$output->toBool()) return $output;
672
+			if (!$output->toBool()) return $output;
673 673
 		}
674 674
 
675 675
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
676
-		if($oCacheHandler->isSupport())
676
+		if ($oCacheHandler->isSupport())
677 677
 		{
678
-			$object_key = 'module_document_extra_keys:'.$module_srl;
678
+			$object_key = 'module_document_extra_keys:' . $module_srl;
679 679
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
680 680
 			$oCacheHandler->delete($cache_key);
681 681
 		}
@@ -687,9 +687,9 @@  discard block
 block discarded – undo
687 687
 	 */
688 688
 	function procDocumentAdminInsertAlias()
689 689
 	{
690
-		$args = Context::gets('module_srl','document_srl', 'alias_title');
690
+		$args = Context::gets('module_srl', 'document_srl', 'alias_title');
691 691
 		$alias_srl = Context::get('alias_srl');
692
-		if(!$alias_srl)
692
+		if (!$alias_srl)
693 693
 		{
694 694
 			$args->alias_srl = getNextSequence();
695 695
 			$query = "document.insertAlias";
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		$oDocumentModel = getModel('document');
733 733
 		$oDocumentController = getController('document');
734 734
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
735
-		if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
735
+		if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
736 736
 	
737 737
 		$oModuleModel = getModel('module');
738 738
 		$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
@@ -744,31 +744,31 @@  discard block
 block discarded – undo
744 744
 		$oDocumentController->moveDocumentToTrash($args);
745 745
 
746 746
 		$returnUrl = Context::get('success_return_url');
747
-		if(!$returnUrl)	
747
+		if (!$returnUrl)	
748 748
 		{
749 749
 			$arrUrl = parse_url(Context::get('cur_url'));
750 750
 			$query = "";
751 751
 
752
-			if($arrUrl['query'])
752
+			if ($arrUrl['query'])
753 753
 			{
754 754
 				parse_str($arrUrl['query'], $arrQuery);
755 755
 
756 756
 				// set query
757
-				if(isset($arrQuery['document_srl']))
757
+				if (isset($arrQuery['document_srl']))
758 758
 					unset($arrQuery['document_srl']);
759 759
 
760 760
 				$searchArgs = new stdClass;
761
-				foreach($arrQuery as $key=>$val)
761
+				foreach ($arrQuery as $key=>$val)
762 762
 				{
763 763
 					$searchArgs->{$key} = $val;
764 764
 				}
765 765
 
766
-				if(!isset($searchArgs->sort_index))
766
+				if (!isset($searchArgs->sort_index))
767 767
 					$searchArgs->sort_index = $module_info->order_target;
768 768
 
769
-				foreach($module_info as $key=>$val)
769
+				foreach ($module_info as $key=>$val)
770 770
 				{
771
-					if(!isset($searchArgs->{$key}))
771
+					if (!isset($searchArgs->{$key}))
772 772
 						$searchArgs->{$key} = $val;
773 773
 				}
774 774
 
@@ -776,16 +776,16 @@  discard block
 block discarded – undo
776 776
 				$output = $oDocumentModel->getDocumentList($searchArgs, $module_info->except_notice, TRUE, array('document_srl'));
777 777
 
778 778
 				$cur_page = 1;
779
-				if(isset($arrQuery['page'])) {
780
-					$cur_page = (int)$arrQuery['page'];
779
+				if (isset($arrQuery['page'])) {
780
+					$cur_page = (int) $arrQuery['page'];
781 781
 				}
782 782
 
783 783
 
784
-				if($cur_page>1 && count($output->data) == 0)
784
+				if ($cur_page > 1 && count($output->data) == 0)
785 785
 					$arrQuery['page'] = $cur_page - 1;
786 786
 
787 787
 				$query = "?";
788
-				foreach($arrQuery as $key=>$val)
788
+				foreach ($arrQuery as $key=>$val)
789 789
 					$query .= sprintf("%s=%s&", $key, $val);
790 790
 				$query = substr($query, 0, -1);
791 791
 			}
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 	 */
867 867
 	function restoreTrash($originObject)
868 868
 	{
869
-		if(is_array($originObject)) $originObject = (object)$originObject;
869
+		if (is_array($originObject)) $originObject = (object) $originObject;
870 870
 
871 871
 		$oDocumentController = getController('document');
872 872
 		$oDocumentModel = getModel('document');
@@ -876,12 +876,12 @@  discard block
 block discarded – undo
876 876
 
877 877
 		//DB restore
878 878
 		$output = $oDocumentController->insertDocument($originObject, false, true, false);
879
-		if(!$output->toBool()) return new Object(-1, $output->getMessage());
879
+		if (!$output->toBool()) return new Object(-1, $output->getMessage());
880 880
 
881 881
 		//FILE restore
882 882
 		$oDocument = $oDocumentModel->getDocument($originObject->document_srl);
883 883
 		// If the post was not temorarily saved, set the attachment's status to be valid
884
-		if($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl)
884
+		if ($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl)
885 885
 		{
886 886
 			$args = new stdClass();
887 887
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 		}
891 891
 
892 892
 		// call a trigger (after)
893
-		if($output->toBool())
893
+		if ($output->toBool())
894 894
 		{
895 895
 			$trigger_output = ModuleHandler::triggerCall('document.restoreTrash', 'after', $originObject);
896
-			if(!$trigger_output->toBool())
896
+			if (!$trigger_output->toBool())
897 897
 			{
898 898
 				$oDB->rollback();
899 899
 				return $trigger_output;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 	function emptyTrash($originObject)
915 915
 	{
916 916
 		$originObject = unserialize($originObject);
917
-		if(is_array($originObject)) $originObject = (object) $originObject;
917
+		if (is_array($originObject)) $originObject = (object) $originObject;
918 918
 
919 919
 		$oDocument = new documentItem();
920 920
 		$oDocument->setAttribute($originObject);
Please login to merge, or discard this patch.
Braces   +136 added lines, -59 removed lines patch added patch discarded remove patch
@@ -27,16 +27,22 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		// error appears if no doc is selected
29 29
 		$cart = Context::get('cart');
30
-		if(!$cart) return $this->stop('msg_cart_is_null');
30
+		if(!$cart) {
31
+			return $this->stop('msg_cart_is_null');
32
+		}
31 33
 		$document_srl_list= explode('|@|', $cart);
32 34
 		$document_count = count($document_srl_list);
33
-		if(!$document_count) return $this->stop('msg_cart_is_null');
35
+		if(!$document_count) {
36
+			return $this->stop('msg_cart_is_null');
37
+		}
34 38
 		// Delete a doc
35 39
 		$oDocumentController = getController('document');
36 40
 		for($i=0;$i<$document_count;$i++)
37 41
 		{
38 42
 			$document_srl = trim($document_srl_list[$i]);
39
-			if(!$document_srl) continue;
43
+			if(!$document_srl) {
44
+				continue;
45
+			}
40 46
 
41 47
 			$oDocumentController->deleteDocument($document_srl, true);
42 48
 		}
@@ -53,7 +59,9 @@  discard block
 block discarded – undo
53 59
 	 */
54 60
 	function moveDocumentModule($document_srl_list, $module_srl, $category_srl)
55 61
 	{
56
-		if(!count($document_srl_list)) return;
62
+		if(!count($document_srl_list)) {
63
+			return;
64
+		}
57 65
 
58 66
 		$oDocumentModel = getModel('document');
59 67
 		$oDocumentController = getController('document');
@@ -77,7 +85,9 @@  discard block
 block discarded – undo
77 85
 		{
78 86
 			$document_srl = $document_srl_list[$i];
79 87
 			$oDocument = $oDocumentModel->getDocument($document_srl);
80
-			if(!$oDocument->isExists()) continue;
88
+			if(!$oDocument->isExists()) {
89
+				continue;
90
+			}
81 91
 
82 92
 			$source_category_srl = $oDocument->get('category_srl');
83 93
 
@@ -113,8 +123,7 @@  discard block
 block discarded – undo
113 123
 								$target_filename = substr($inserted_file->get('uploaded_filename'),2);
114 124
 								$obj->content = str_replace($source_filename, $target_filename, $obj->content);
115 125
 								// For binary files
116
-							}
117
-							else
126
+							} else
118 127
 							{
119 128
 								$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
120 129
 								$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
@@ -151,8 +160,12 @@  discard block
 block discarded – undo
151 160
 			// Set 0 if a new category doesn't exist after catergory change
152 161
 			if($source_category_srl != $category_srl)
153 162
 			{
154
-				if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
155
-				if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
163
+				if($source_category_srl) {
164
+					$oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
165
+				}
166
+				if($category_srl) {
167
+					$oDocumentController->updateCategoryCount($module_srl, $category_srl);
168
+				}
156 169
 			}
157 170
 		}
158 171
 
@@ -223,7 +236,9 @@  discard block
 block discarded – undo
223 236
 	 */
224 237
 	function copyDocumentModule($document_srl_list, $module_srl, $category_srl)
225 238
 	{
226
-		if(count($document_srl_list) < 1) return;
239
+		if(count($document_srl_list) < 1) {
240
+			return;
241
+		}
227 242
 
228 243
 		$oDocumentModel = getModel('document');
229 244
 		$oDocumentController = getController('document');
@@ -264,7 +279,9 @@  discard block
 block discarded – undo
264 279
 		{
265 280
 			$document_srl = $document_srl_list[$i];
266 281
 			$oDocument = $oDocumentModel->getDocument($document_srl);
267
-			if(!$oDocument->isExists()) continue;
282
+			if(!$oDocument->isExists()) {
283
+				continue;
284
+			}
268 285
 
269 286
 			$obj = $oDocument->getObjectVars();
270 287
 
@@ -275,7 +292,9 @@  discard block
 block discarded – undo
275 292
 				{
276 293
 					foreach($extraVars as $extraItem)
277 294
 					{
278
-						if($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value;
295
+						if($extraItem->var_idx >= 0) {
296
+							$obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value;
297
+						}
279 298
 					}
280 299
 				}
281 300
 			}
@@ -304,8 +323,7 @@  discard block
 block discarded – undo
304 323
 						$target_filename = substr($inserted_file->get('uploaded_filename'),2);
305 324
 						$obj->content = str_replace($source_filename, $target_filename, $obj->content);
306 325
 						// If binary file
307
-					}
308
-					else
326
+					} else
309 327
 					{
310 328
 						$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
311 329
 						$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
@@ -372,8 +390,7 @@  discard block
 block discarded – undo
372 390
 									$target_filename = substr($inserted_file->get('uploaded_filename'),2);
373 391
 									$comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content);
374 392
 									// If binary file
375
-								}
376
-								else
393
+								} else
377 394
 								{
378 395
 									$comment_obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $comment_obj->content);
379 396
 									$comment_obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $comment_obj->content);
@@ -385,10 +402,14 @@  discard block
 block discarded – undo
385 402
 						$comment_obj->document_srl = $obj->document_srl;
386 403
 						$comment_obj->comment_srl = $comment_srl;
387 404
 
388
-						if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
405
+						if($comment_obj->parent_srl) {
406
+							$comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
407
+						}
389 408
 
390 409
 						$output = $oCommentController->insertComment($comment_obj, true);
391
-						if($output->toBool()) $success_count ++;
410
+						if($output->toBool()) {
411
+							$success_count ++;
412
+						}
392 413
 					}
393 414
 					$oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
394 415
 				}
@@ -408,7 +429,9 @@  discard block
 block discarded – undo
408 429
 						$trackback_obj->module_srl = $obj->module_srl;
409 430
 						$trackback_obj->document_srl = $obj->document_srl;
410 431
 						$output = executeQuery('trackback.insertTrackback', $trackback_obj);
411
-						if($output->toBool()) $success_count++;
432
+						if($output->toBool()) {
433
+							$success_count++;
434
+						}
412 435
 					}
413 436
 					// Update the number of trackbacks
414 437
 					$oDocumentController->updateTrackbackCount($obj->document_srl, $success_count);
@@ -499,7 +522,9 @@  discard block
 block discarded – undo
499 522
 		{
500 523
 			$args->document_srl = $document_srl;
501 524
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
502
-			if(!$output->toBool()) return $output;
525
+			if(!$output->toBool()) {
526
+				return $output;
527
+			}
503 528
 		}
504 529
 	}
505 530
 
@@ -529,7 +554,9 @@  discard block
 block discarded – undo
529 554
 				if (is_dir($path."/".$entry)) {
530 555
 					$this->deleteThumbnailFile($path."/".$entry);
531 556
 				} else {
532
-					if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) continue;
557
+					if(!preg_match('/^thumbnail_([^\.]*)\.jpg$/i',$entry)) {
558
+						continue;
559
+					}
533 560
 					FileHandler::removeFile($path.'/'.$entry);
534 561
 				}
535 562
 			}
@@ -554,7 +581,9 @@  discard block
 block discarded – undo
554 581
 		$eid = Context::get('eid');
555 582
 		$obj = new stdClass();
556 583
 
557
-		if(!$module_srl || !$name || !$eid) return new Object(-1,'msg_invalid_request');
584
+		if(!$module_srl || !$name || !$eid) {
585
+			return new Object(-1,'msg_invalid_request');
586
+		}
558 587
 		// set the max value if idx is not specified
559 588
 		if(!$var_idx)
560 589
 		{
@@ -576,7 +605,9 @@  discard block
 block discarded – undo
576 605
 		// insert or update
577 606
 		$oDocumentController = getController('document');
578 607
 		$output = $oDocumentController->insertDocumentExtraKey($module_srl, $var_idx, $name, $type, $is_required, $search, $default, $desc, $eid);
579
-		if(!$output->toBool()) return $output;
608
+		if(!$output->toBool()) {
609
+			return $output;
610
+		}
580 611
 
581 612
 		$this->setMessage('success_registed');
582 613
 
@@ -592,11 +623,15 @@  discard block
 block discarded – undo
592 623
 	{
593 624
 		$module_srl = Context::get('module_srl');
594 625
 		$var_idx = Context::get('var_idx');
595
-		if(!$module_srl || !$var_idx) return new Object(-1,'msg_invalid_request');
626
+		if(!$module_srl || !$var_idx) {
627
+			return new Object(-1,'msg_invalid_request');
628
+		}
596 629
 
597 630
 		$oDocumentController = getController('document');
598 631
 		$output = $oDocumentController->deleteDocumentExtraKeys($module_srl, $var_idx);
599
-		if(!$output->toBool()) return $output;
632
+		if(!$output->toBool()) {
633
+			return $output;
634
+		}
600 635
 
601 636
 		$this->setMessage('success_deleted');
602 637
 	}
@@ -611,26 +646,41 @@  discard block
 block discarded – undo
611 646
 		$module_srl = Context::get('module_srl');
612 647
 		$var_idx = Context::get('var_idx');
613 648
 
614
-		if(!$type || !$module_srl || !$var_idx) return new Object(-1,'msg_invalid_request');
649
+		if(!$type || !$module_srl || !$var_idx) {
650
+			return new Object(-1,'msg_invalid_request');
651
+		}
615 652
 
616 653
 		$oModuleModel = getModel('module');
617 654
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
618
-		if(!$module_info->module_srl) return new Object(-1,'msg_invalid_request');
655
+		if(!$module_info->module_srl) {
656
+			return new Object(-1,'msg_invalid_request');
657
+		}
619 658
 
620 659
 		$oDocumentModel = getModel('document');
621 660
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
622
-		if(!$extra_keys[$var_idx]) return new Object(-1,'msg_invalid_request');
661
+		if(!$extra_keys[$var_idx]) {
662
+			return new Object(-1,'msg_invalid_request');
663
+		}
623 664
 
624
-		if($type == 'up') $new_idx = $var_idx-1;
625
-		else $new_idx = $var_idx+1;
626
-		if($new_idx<1) return new Object(-1,'msg_invalid_request');
665
+		if($type == 'up') {
666
+			$new_idx = $var_idx-1;
667
+		} else {
668
+			$new_idx = $var_idx+1;
669
+		}
670
+		if($new_idx<1) {
671
+			return new Object(-1,'msg_invalid_request');
672
+		}
627 673
 
628 674
 		$args = new stdClass();
629 675
 		$args->module_srl = $module_srl;
630 676
 		$args->var_idx = $new_idx;
631 677
 		$output = executeQuery('document.getDocumentExtraKeys', $args);
632
-		if (!$output->toBool()) return $output;
633
-		if (!$output->data) return new Object(-1, 'msg_invalid_request');
678
+		if (!$output->toBool()) {
679
+			return $output;
680
+		}
681
+		if (!$output->data) {
682
+			return new Object(-1, 'msg_invalid_request');
683
+		}
634 684
 		unset($args);
635 685
 
636 686
 		// update immediately if there is no idx to change
@@ -641,35 +691,50 @@  discard block
 block discarded – undo
641 691
 			$args->var_idx = $var_idx;
642 692
 			$args->new_idx = $new_idx;
643 693
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
644
-			if(!$output->toBool()) return $output;
694
+			if(!$output->toBool()) {
695
+				return $output;
696
+			}
645 697
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
646
-			if(!$output->toBool()) return $output;
698
+			if(!$output->toBool()) {
699
+				return $output;
700
+			}
647 701
 			// replace if exists
648
-		}
649
-		else
702
+		} else
650 703
 		{
651 704
 			$args = new stdClass();
652 705
 			$args->module_srl = $module_srl;
653 706
 			$args->var_idx = $new_idx;
654 707
 			$args->new_idx = -10000;
655 708
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
656
-			if(!$output->toBool()) return $output;
709
+			if(!$output->toBool()) {
710
+				return $output;
711
+			}
657 712
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
658
-			if(!$output->toBool()) return $output;
713
+			if(!$output->toBool()) {
714
+				return $output;
715
+			}
659 716
 
660 717
 			$args->var_idx = $var_idx;
661 718
 			$args->new_idx = $new_idx;
662 719
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
663
-			if(!$output->toBool()) return $output;
720
+			if(!$output->toBool()) {
721
+				return $output;
722
+			}
664 723
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
665
-			if(!$output->toBool()) return $output;
724
+			if(!$output->toBool()) {
725
+				return $output;
726
+			}
666 727
 
667 728
 			$args->var_idx = -10000;
668 729
 			$args->new_idx = $var_idx;
669 730
 			$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
670
-			if(!$output->toBool()) return $output;
731
+			if(!$output->toBool()) {
732
+				return $output;
733
+			}
671 734
 			$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
672
-			if(!$output->toBool()) return $output;
735
+			if(!$output->toBool()) {
736
+				return $output;
737
+			}
673 738
 		}
674 739
 
675 740
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
@@ -693,8 +758,7 @@  discard block
 block discarded – undo
693 758
 		{
694 759
 			$args->alias_srl = getNextSequence();
695 760
 			$query = "document.insertAlias";
696
-		}
697
-		else
761
+		} else
698 762
 		{
699 763
 			$args->alias_srl = $alias_srl;
700 764
 			$query = "document.updateAlias";
@@ -732,7 +796,9 @@  discard block
 block discarded – undo
732 796
 		$oDocumentModel = getModel('document');
733 797
 		$oDocumentController = getController('document');
734 798
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
735
-		if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
799
+		if(!$oDocument->isGranted()) {
800
+			return $this->stop('msg_not_permitted');
801
+		}
736 802
 	
737 803
 		$oModuleModel = getModel('module');
738 804
 		$module_info = $oModuleModel->getModuleInfoByDocumentSrl($document_srl);
@@ -754,8 +820,9 @@  discard block
 block discarded – undo
754 820
 				parse_str($arrUrl['query'], $arrQuery);
755 821
 
756 822
 				// set query
757
-				if(isset($arrQuery['document_srl']))
758
-					unset($arrQuery['document_srl']);
823
+				if(isset($arrQuery['document_srl'])) {
824
+									unset($arrQuery['document_srl']);
825
+				}
759 826
 
760 827
 				$searchArgs = new stdClass;
761 828
 				foreach($arrQuery as $key=>$val)
@@ -763,13 +830,15 @@  discard block
 block discarded – undo
763 830
 					$searchArgs->{$key} = $val;
764 831
 				}
765 832
 
766
-				if(!isset($searchArgs->sort_index))
767
-					$searchArgs->sort_index = $module_info->order_target;
833
+				if(!isset($searchArgs->sort_index)) {
834
+									$searchArgs->sort_index = $module_info->order_target;
835
+				}
768 836
 
769 837
 				foreach($module_info as $key=>$val)
770 838
 				{
771
-					if(!isset($searchArgs->{$key}))
772
-						$searchArgs->{$key} = $val;
839
+					if(!isset($searchArgs->{$key})) {
840
+											$searchArgs->{$key} = $val;
841
+					}
773 842
 				}
774 843
 
775 844
 				$oDocumentModel = getModel('document');
@@ -781,12 +850,14 @@  discard block
 block discarded – undo
781 850
 				}
782 851
 
783 852
 
784
-				if($cur_page>1 && count($output->data) == 0)
785
-					$arrQuery['page'] = $cur_page - 1;
853
+				if($cur_page>1 && count($output->data) == 0) {
854
+									$arrQuery['page'] = $cur_page - 1;
855
+				}
786 856
 
787 857
 				$query = "?";
788
-				foreach($arrQuery as $key=>$val)
789
-					$query .= sprintf("%s=%s&", $key, $val);
858
+				foreach($arrQuery as $key=>$val) {
859
+									$query .= sprintf("%s=%s&", $key, $val);
860
+				}
790 861
 				$query = substr($query, 0, -1);
791 862
 			}
792 863
 			$returnUrl = $arrUrl['path'] . $query;
@@ -866,7 +937,9 @@  discard block
 block discarded – undo
866 937
 	 */
867 938
 	function restoreTrash($originObject)
868 939
 	{
869
-		if(is_array($originObject)) $originObject = (object)$originObject;
940
+		if(is_array($originObject)) {
941
+			$originObject = (object)$originObject;
942
+		}
870 943
 
871 944
 		$oDocumentController = getController('document');
872 945
 		$oDocumentModel = getModel('document');
@@ -876,7 +949,9 @@  discard block
 block discarded – undo
876 949
 
877 950
 		//DB restore
878 951
 		$output = $oDocumentController->insertDocument($originObject, false, true, false);
879
-		if(!$output->toBool()) return new Object(-1, $output->getMessage());
952
+		if(!$output->toBool()) {
953
+			return new Object(-1, $output->getMessage());
954
+		}
880 955
 
881 956
 		//FILE restore
882 957
 		$oDocument = $oDocumentModel->getDocument($originObject->document_srl);
@@ -914,7 +989,9 @@  discard block
 block discarded – undo
914 989
 	function emptyTrash($originObject)
915 990
 	{
916 991
 		$originObject = unserialize($originObject);
917
-		if(is_array($originObject)) $originObject = (object) $originObject;
992
+		if(is_array($originObject)) {
993
+			$originObject = (object) $originObject;
994
+		}
918 995
 
919 996
 		$oDocument = new documentItem();
920 997
 		$oDocument->setAttribute($originObject);
Please login to merge, or discard this patch.
modules/document/document.class.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -351,6 +351,7 @@
 block discarded – undo
351 351
 
352 352
 	/**
353 353
 	 * Return status by key
354
+	 * @param string $key
354 355
 	 * @return string
355 356
 	 */
356 357
 	function getConfigStatus($key)
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3
-require_once(_XE_PATH_.'modules/document/document.item.php');
3
+require_once(_XE_PATH_ . 'modules/document/document.item.php');
4 4
 
5 5
 /**
6 6
  * document class
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * Search option to use in admin page
18 18
 	 * @var array
19 19
 	 */
20
-	var $search_option = array('title','content','title_content','user_name',); // /< Search options
20
+	var $search_option = array('title', 'content', 'title_content', 'user_name',); // /< Search options
21 21
 	/**
22 22
 	 * Status list
23 23
 	 * @var array
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 		$oModuleController = getController('module');
35 35
 
36 36
 		$oDB = &DB::getInstance();
37
-		$oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order"));
38
-		$oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order"));
39
-		$oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count"));
40
-		$oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
41
-		$oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice"));
42
-		$oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
43
-		$oDB->addIndex("documents","idx_module_blamed_count", array("module_srl","blamed_count"));
44
-		$oDB->addIndex("document_aliases", "idx_module_title", array("module_srl","alias_title"), true);
45
-		$oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true);
37
+		$oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order"));
38
+		$oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order"));
39
+		$oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count"));
40
+		$oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count"));
41
+		$oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice"));
42
+		$oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl"));
43
+		$oDB->addIndex("documents", "idx_module_blamed_count", array("module_srl", "blamed_count"));
44
+		$oDB->addIndex("document_aliases", "idx_module_title", array("module_srl", "alias_title"), true);
45
+		$oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true);
46 46
 		// 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
47 47
 		$oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after');
48 48
 
@@ -61,68 +61,68 @@  discard block
 block discarded – undo
61 61
 		$oModuleModel = getModel('module');
62 62
 
63 63
 		// 2007. 7. 25: Add a column(notify_message) for notification
64
-		if(!$oDB->isColumnExists("documents","notify_message")) return true;
64
+		if (!$oDB->isColumnExists("documents", "notify_message")) return true;
65 65
 
66 66
 		// 2007. 8. 23: create a clustered index in the document table
67
-		if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true;
68
-		if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true;
69
-		if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true;
70
-		if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true;
67
+		if (!$oDB->isIndexExists("documents", "idx_module_list_order")) return true;
68
+		if (!$oDB->isIndexExists("documents", "idx_module_update_order")) return true;
69
+		if (!$oDB->isIndexExists("documents", "idx_module_readed_count")) return true;
70
+		if (!$oDB->isIndexExists("documents", "idx_module_voted_count")) return true;
71 71
 		// 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
72
-		if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true;
72
+		if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true;
73 73
 		// 2007. 10. 25 add parent_srl, expand to the document category
74
-		if(!$oDB->isColumnExists("document_categories","parent_srl")) return true;
75
-		if(!$oDB->isColumnExists("document_categories","expand")) return true;
76
-		if(!$oDB->isColumnExists("document_categories","group_srls")) return true;
74
+		if (!$oDB->isColumnExists("document_categories", "parent_srl")) return true;
75
+		if (!$oDB->isColumnExists("document_categories", "expand")) return true;
76
+		if (!$oDB->isColumnExists("document_categories", "group_srls")) return true;
77 77
 		// 2007. 11. 20 create a composite index on the columns(module_srl + is_notice)
78
-		if(!$oDB->isIndexExists("documents","idx_module_notice")) return true;
78
+		if (!$oDB->isIndexExists("documents", "idx_module_notice")) return true;
79 79
 		// 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
80
-		if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true;
80
+		if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) return true;
81 81
 
82 82
 		// 2007. 12. 03: Add if the colume(extra_vars) doesn't exist
83
-		if(!$oDB->isColumnExists("documents","extra_vars")) return true;
83
+		if (!$oDB->isColumnExists("documents", "extra_vars")) return true;
84 84
 		// 2008. 04. 23 Add a column(blamed_count)
85
-		if(!$oDB->isColumnExists("documents", "blamed_count")) return true;
86
-		if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true;
87
-		if(!$oDB->isColumnExists("document_voted_log", "point")) return true;
85
+		if (!$oDB->isColumnExists("documents", "blamed_count")) return true;
86
+		if (!$oDB->isIndexExists("documents", "idx_module_blamed_count")) return true;
87
+		if (!$oDB->isColumnExists("document_voted_log", "point")) return true;
88 88
 		// 2008-12-15 Add a column(color)
89
-		if(!$oDB->isColumnExists("document_categories", "color")) return true;
89
+		if (!$oDB->isColumnExists("document_categories", "color")) return true;
90 90
 
91 91
 		/**
92 92
 		 * 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table
93 93
 		 */
94
-		if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true;
94
+		if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) return true;
95 95
 
96
-		if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true;
96
+		if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true;
97 97
 		// 2009. 03. 09 Add a column(lang_code) to the documnets table
98
-		if(!$oDB->isColumnExists("documents","lang_code")) return true;
98
+		if (!$oDB->isColumnExists("documents", "lang_code")) return true;
99 99
 		// 2009. 03. 11 check the index in the document_extra_vars table
100
-		if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true;
100
+		if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true;
101 101
 
102 102
 		// 2009. 03. 19: Add a column(eid) if not exist in the table
103
-		if(!$oDB->isColumnExists("document_extra_keys","eid")) return true;
104
-		if(!$oDB->isColumnExists("document_extra_vars","eid")) return true;
103
+		if (!$oDB->isColumnExists("document_extra_keys", "eid")) return true;
104
+		if (!$oDB->isColumnExists("document_extra_vars", "eid")) return true;
105 105
 
106 106
 		// 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
107
-		if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true;
107
+		if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true;
108 108
 
109 109
 		//2011. 04. 07 adding description column to document categories
110
-		if(!$oDB->isColumnExists("document_categories","description")) return true;
110
+		if (!$oDB->isColumnExists("document_categories", "description")) return true;
111 111
 
112 112
 		//2011. 05. 23 adding status column to document
113
-		if(!$oDB->isColumnExists('documents', 'status')) return true;
113
+		if (!$oDB->isColumnExists('documents', 'status')) return true;
114 114
 
115 115
 		//2011. 06. 07 check comment status update
116
-		if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true;
116
+		if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true;
117 117
 
118 118
 		// 2011. 10. 25 status index check
119
-		if(!$oDB->isIndexExists("documents", "idx_module_status")) return true;
119
+		if (!$oDB->isIndexExists("documents", "idx_module_status")) return true;
120 120
 
121 121
 		// 2012. 02. 27 Add a trigger to copy extra keys when the module is copied 
122
-		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true;
122
+		if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true;
123 123
 
124 124
 		// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied 
125
-		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true;
125
+		if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true;
126 126
 
127 127
 		return false;
128 128
 	}
@@ -138,134 +138,134 @@  discard block
 block discarded – undo
138 138
 		$oModuleController = getController('module');
139 139
 
140 140
 		// 2007. 7. 25: Add a column(notify_message) for notification
141
-		if(!$oDB->isColumnExists("documents","notify_message"))
141
+		if (!$oDB->isColumnExists("documents", "notify_message"))
142 142
 		{
143
-			$oDB->addColumn('documents',"notify_message","char",1);
143
+			$oDB->addColumn('documents', "notify_message", "char", 1);
144 144
 		}
145 145
 
146 146
 		// 2007. 8. 23: create a clustered index in the document table
147
-		if(!$oDB->isIndexExists("documents","idx_module_list_order"))
147
+		if (!$oDB->isIndexExists("documents", "idx_module_list_order"))
148 148
 		{
149
-			$oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order"));
149
+			$oDB->addIndex("documents", "idx_module_list_order", array("module_srl", "list_order"));
150 150
 		}
151 151
 
152
-		if(!$oDB->isIndexExists("documents","idx_module_update_order"))
152
+		if (!$oDB->isIndexExists("documents", "idx_module_update_order"))
153 153
 		{
154
-			$oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order"));
154
+			$oDB->addIndex("documents", "idx_module_update_order", array("module_srl", "update_order"));
155 155
 		}
156 156
 
157
-		if(!$oDB->isIndexExists("documents","idx_module_readed_count"))
157
+		if (!$oDB->isIndexExists("documents", "idx_module_readed_count"))
158 158
 		{
159
-			$oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count"));
159
+			$oDB->addIndex("documents", "idx_module_readed_count", array("module_srl", "readed_count"));
160 160
 		}
161 161
 
162
-		if(!$oDB->isIndexExists("documents","idx_module_voted_count"))
162
+		if (!$oDB->isIndexExists("documents", "idx_module_voted_count"))
163 163
 		{
164
-			$oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
164
+			$oDB->addIndex("documents", "idx_module_voted_count", array("module_srl", "voted_count"));
165 165
 		}
166 166
 		// 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
167
-		if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'))
167
+		if (!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'))
168 168
 			$oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after');
169 169
 		// 2007. 10. 25 add columns(parent_srl, expand) 
170
-		if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0);
171
-		if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N");
172
-		if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text");
170
+		if (!$oDB->isColumnExists("document_categories", "parent_srl")) $oDB->addColumn('document_categories', "parent_srl", "number", 12, 0);
171
+		if (!$oDB->isColumnExists("document_categories", "expand")) $oDB->addColumn('document_categories', "expand", "char", 1, "N");
172
+		if (!$oDB->isColumnExists("document_categories", "group_srls")) $oDB->addColumn('document_categories', "group_srls", "text");
173 173
 		// 2007. 11. 20 create a composite index on the columns(module_srl + is_notice)
174
-		if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice"));
174
+		if (!$oDB->isIndexExists("documents", "idx_module_notice")) $oDB->addIndex("documents", "idx_module_notice", array("module_srl", "is_notice"));
175 175
 
176 176
 		// 2007. 12. 03: Add if the colume(extra_vars) doesn't exist
177
-		if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text');
177
+		if (!$oDB->isColumnExists("documents", "extra_vars")) $oDB->addColumn('documents', 'extra_vars', 'text');
178 178
 
179 179
 		// 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
180
-		if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
180
+		if (!$oDB->isIndexExists("documents", "idx_module_document_srl")) $oDB->addIndex("documents", "idx_module_document_srl", array("module_srl", "document_srl"));
181 181
 		// 2008. 04. 23 Add a column(blamed count)
182
-		if(!$oDB->isColumnExists("documents", "blamed_count"))
182
+		if (!$oDB->isColumnExists("documents", "blamed_count"))
183 183
 		{
184 184
 			$oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true);
185 185
 			$oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count'));
186 186
 		}
187 187
 
188
-		if(!$oDB->isIndexExists("documents","idx_module_blamed_count"))
188
+		if (!$oDB->isIndexExists("documents", "idx_module_blamed_count"))
189 189
 		{
190 190
 			$oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count'));
191 191
 		}
192 192
 
193
-		if(!$oDB->isColumnExists("document_voted_log", "point"))
193
+		if (!$oDB->isColumnExists("document_voted_log", "point"))
194 194
 			$oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true);
195 195
 
196 196
 
197
-		if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7);
197
+		if (!$oDB->isColumnExists("document_categories", "color")) $oDB->addColumn('document_categories', "color", "char", 7);
198 198
 
199 199
 		// 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table
200
-		if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10);
200
+		if (!$oDB->isColumnExists("document_extra_vars", "lang_code")) $oDB->addColumn('document_extra_vars', "lang_code", "varchar", 10);
201 201
 
202 202
 		// 2009. 01. 29 Added a trigger for additional setup
203
-		if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'))
203
+		if (!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'))
204 204
 			$oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before');
205 205
 		// 2009. 03. 09 Add a column(lang_code) to the documnets table
206
-		if(!$oDB->isColumnExists("documents","lang_code"))
206
+		if (!$oDB->isColumnExists("documents", "lang_code"))
207 207
 		{
208 208
 			$db_info = Context::getDBInfo();
209
-			$oDB->addColumn('documents',"lang_code","varchar",10, $db_info->lang_code);
209
+			$oDB->addColumn('documents', "lang_code", "varchar", 10, $db_info->lang_code);
210 210
 			$obj->lang_code = $db_info->lang_type;
211 211
 			executeQuery('document.updateDocumentsLangCode', $obj);
212 212
 		}
213 213
 		// 2009. 03. 11 Check the index in the document_extra_vars table
214
-		if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars"))
214
+		if (!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars"))
215 215
 		{
216
-			$oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true);
216
+			$oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl", "document_srl", "var_idx", "lang_code"), true);
217 217
 		}
218 218
 
219
-		if($oDB->isIndexExists("document_extra_vars", "unique_module_vars"))
219
+		if ($oDB->isIndexExists("document_extra_vars", "unique_module_vars"))
220 220
 		{
221 221
 			$oDB->dropIndex("document_extra_vars", "unique_module_vars", true);
222 222
 		}
223 223
 
224 224
 		// 2009. 03. 19: Add a column(eid)
225 225
 		// 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column
226
-		if(!$oDB->isColumnExists("document_extra_keys","eid"))
226
+		if (!$oDB->isColumnExists("document_extra_keys", "eid"))
227 227
 		{
228
-			$oDB->addColumn("document_extra_keys","eid","varchar",40);
228
+			$oDB->addColumn("document_extra_keys", "eid", "varchar", 40);
229 229
 
230 230
 			$output = executeQuery('document.getGroupsExtraKeys', $obj);
231
-			if($output->toBool() && $output->data && count($output->data)) {
232
-				foreach($output->data as $extra_keys) {
231
+			if ($output->toBool() && $output->data && count($output->data)) {
232
+				foreach ($output->data as $extra_keys) {
233 233
 					$args->module_srl = $extra_keys->module_srl;
234 234
 					$args->var_idx = $extra_keys->idx;
235
-					$args->new_eid = "extra_vars".$extra_keys->idx;
235
+					$args->new_eid = "extra_vars" . $extra_keys->idx;
236 236
 					$output = executeQuery('document.updateDocumentExtraKeyEid', $args);
237 237
 				}
238 238
 			}
239 239
 		}
240 240
 
241
-		if(!$oDB->isColumnExists("document_extra_vars","eid"))
241
+		if (!$oDB->isColumnExists("document_extra_vars", "eid"))
242 242
 		{
243
-			$oDB->addColumn("document_extra_vars","eid","varchar",40);
243
+			$oDB->addColumn("document_extra_vars", "eid", "varchar", 40);
244 244
 			$obj->var_idx = '-1,-2';
245 245
 			$output = executeQuery('document.getGroupsExtraVars', $obj);
246
-			if($output->toBool() && $output->data && count($output->data))
246
+			if ($output->toBool() && $output->data && count($output->data))
247 247
 			{
248
-				foreach($output->data as $extra_vars)
248
+				foreach ($output->data as $extra_vars)
249 249
 				{
250 250
 					$args->module_srl = $extra_vars->module_srl;
251 251
 					$args->var_idx = $extra_vars->idx;
252
-					$args->new_eid = "extra_vars".$extra_vars->idx;
252
+					$args->new_eid = "extra_vars" . $extra_vars->idx;
253 253
 					$output = executeQuery('document.updateDocumentExtraVarEid', $args);
254 254
 				}
255 255
 			}
256 256
 		}
257 257
 
258 258
 		// 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
259
-		if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order"))
259
+		if (!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order"))
260 260
 		{
261
-			$oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false);
261
+			$oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl", "module_srl", "var_idx"), false);
262 262
 		}
263 263
 
264 264
 		//2011. 04. 07 adding description column to document categories
265
-		if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0);
265
+		if (!$oDB->isColumnExists("document_categories", "description")) $oDB->addColumn('document_categories', "description", "varchar", 200, 0);
266 266
 
267 267
 		//2011. 05. 23 adding status column to document
268
-		if(!$oDB->isColumnExists('documents', 'status'))
268
+		if (!$oDB->isColumnExists('documents', 'status'))
269 269
 		{
270 270
 			$oDB->addColumn('documents', 'status', 'varchar', 20, 'PUBLIC');
271 271
 			$args->is_secret = 'Y';
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		// 2011. 09. 08 drop column document is_secret
276
-		if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret'))
276
+		if ($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret'))
277 277
 			$oDB->dropColumn('documents', 'is_secret');
278 278
 
279 279
 		//2011. 06. 07 merge column, allow_comment and lock_comment
280
-		if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment'))
280
+		if ($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment'))
281 281
 		{
282 282
 			$oDB->addColumn('documents', 'comment_status', 'varchar', 20, 'ALLOW');
283 283
 
@@ -299,28 +299,28 @@  discard block
 block discarded – undo
299 299
 			$output = executeQuery('document.updateDocumentCommentStatus', $args);
300 300
 		}
301 301
 
302
-		if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status'))
302
+		if ($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status'))
303 303
 			$oDB->dropColumn('documents', 'allow_comment');
304 304
 
305
-		if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status'))
305
+		if ($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status'))
306 306
 			$oDB->dropColumn('documents', 'lock_comment');
307 307
 
308
-		if(!$oDB->isIndexExists("documents", "idx_module_status"))
309
-			$oDB->addIndex("documents", "idx_module_status", array("module_srl","status"));
308
+		if (!$oDB->isIndexExists("documents", "idx_module_status"))
309
+			$oDB->addIndex("documents", "idx_module_status", array("module_srl", "status"));
310 310
 
311 311
 		// 2012. 02. 27 Add a trigger to copy extra keys when the module is copied 
312
-		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'))
312
+		if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'))
313 313
 		{
314 314
 			$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after');
315 315
 		}
316 316
 
317 317
 		// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied 
318
-		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'))
318
+		if (!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after'))
319 319
 		{
320 320
 			$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after');
321 321
 		}
322 322
 
323
-		return new Object(0,'success_updated');
323
+		return new Object(0, 'success_updated');
324 324
 	}
325 325
 
326 326
 	/**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 */
356 356
 	function getConfigStatus($key)
357 357
 	{
358
-		if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key];
358
+		if (array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key];
359 359
 		else $this->getDefaultStatus();
360 360
 	}
361 361
 }
Please login to merge, or discard this patch.
Braces   +140 added lines, -54 removed lines patch added patch discarded remove patch
@@ -61,68 +61,126 @@  discard block
 block discarded – undo
61 61
 		$oModuleModel = getModel('module');
62 62
 
63 63
 		// 2007. 7. 25: Add a column(notify_message) for notification
64
-		if(!$oDB->isColumnExists("documents","notify_message")) return true;
64
+		if(!$oDB->isColumnExists("documents","notify_message")) {
65
+			return true;
66
+		}
65 67
 
66 68
 		// 2007. 8. 23: create a clustered index in the document table
67
-		if(!$oDB->isIndexExists("documents","idx_module_list_order")) return true;
68
-		if(!$oDB->isIndexExists("documents","idx_module_update_order")) return true;
69
-		if(!$oDB->isIndexExists("documents","idx_module_readed_count")) return true;
70
-		if(!$oDB->isIndexExists("documents","idx_module_voted_count")) return true;
69
+		if(!$oDB->isIndexExists("documents","idx_module_list_order")) {
70
+			return true;
71
+		}
72
+		if(!$oDB->isIndexExists("documents","idx_module_update_order")) {
73
+			return true;
74
+		}
75
+		if(!$oDB->isIndexExists("documents","idx_module_readed_count")) {
76
+			return true;
77
+		}
78
+		if(!$oDB->isIndexExists("documents","idx_module_voted_count")) {
79
+			return true;
80
+		}
71 81
 		// 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
72
-		if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) return true;
82
+		if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) {
83
+			return true;
84
+		}
73 85
 		// 2007. 10. 25 add parent_srl, expand to the document category
74
-		if(!$oDB->isColumnExists("document_categories","parent_srl")) return true;
75
-		if(!$oDB->isColumnExists("document_categories","expand")) return true;
76
-		if(!$oDB->isColumnExists("document_categories","group_srls")) return true;
86
+		if(!$oDB->isColumnExists("document_categories","parent_srl")) {
87
+			return true;
88
+		}
89
+		if(!$oDB->isColumnExists("document_categories","expand")) {
90
+			return true;
91
+		}
92
+		if(!$oDB->isColumnExists("document_categories","group_srls")) {
93
+			return true;
94
+		}
77 95
 		// 2007. 11. 20 create a composite index on the columns(module_srl + is_notice)
78
-		if(!$oDB->isIndexExists("documents","idx_module_notice")) return true;
96
+		if(!$oDB->isIndexExists("documents","idx_module_notice")) {
97
+			return true;
98
+		}
79 99
 		// 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
80
-		if(!$oDB->isIndexExists("documents","idx_module_document_srl")) return true;
100
+		if(!$oDB->isIndexExists("documents","idx_module_document_srl")) {
101
+			return true;
102
+		}
81 103
 
82 104
 		// 2007. 12. 03: Add if the colume(extra_vars) doesn't exist
83
-		if(!$oDB->isColumnExists("documents","extra_vars")) return true;
105
+		if(!$oDB->isColumnExists("documents","extra_vars")) {
106
+			return true;
107
+		}
84 108
 		// 2008. 04. 23 Add a column(blamed_count)
85
-		if(!$oDB->isColumnExists("documents", "blamed_count")) return true;
86
-		if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) return true;
87
-		if(!$oDB->isColumnExists("document_voted_log", "point")) return true;
109
+		if(!$oDB->isColumnExists("documents", "blamed_count")) {
110
+			return true;
111
+		}
112
+		if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) {
113
+			return true;
114
+		}
115
+		if(!$oDB->isColumnExists("document_voted_log", "point")) {
116
+			return true;
117
+		}
88 118
 		// 2008-12-15 Add a column(color)
89
-		if(!$oDB->isColumnExists("document_categories", "color")) return true;
119
+		if(!$oDB->isColumnExists("document_categories", "color")) {
120
+			return true;
121
+		}
90 122
 
91 123
 		/**
92 124
 		 * 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table
93 125
 		 */
94
-		if(!$oDB->isColumnExists("document_extra_vars","lang_code")) return true;
126
+		if(!$oDB->isColumnExists("document_extra_vars","lang_code")) {
127
+			return true;
128
+		}
95 129
 
96
-		if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) return true;
130
+		if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) {
131
+			return true;
132
+		}
97 133
 		// 2009. 03. 09 Add a column(lang_code) to the documnets table
98
-		if(!$oDB->isColumnExists("documents","lang_code")) return true;
134
+		if(!$oDB->isColumnExists("documents","lang_code")) {
135
+			return true;
136
+		}
99 137
 		// 2009. 03. 11 check the index in the document_extra_vars table
100
-		if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true;
138
+		if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) {
139
+			return true;
140
+		}
101 141
 
102 142
 		// 2009. 03. 19: Add a column(eid) if not exist in the table
103
-		if(!$oDB->isColumnExists("document_extra_keys","eid")) return true;
104
-		if(!$oDB->isColumnExists("document_extra_vars","eid")) return true;
143
+		if(!$oDB->isColumnExists("document_extra_keys","eid")) {
144
+			return true;
145
+		}
146
+		if(!$oDB->isColumnExists("document_extra_vars","eid")) {
147
+			return true;
148
+		}
105 149
 
106 150
 		// 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
107
-		if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true;
151
+		if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) {
152
+			return true;
153
+		}
108 154
 
109 155
 		//2011. 04. 07 adding description column to document categories
110
-		if(!$oDB->isColumnExists("document_categories","description")) return true;
156
+		if(!$oDB->isColumnExists("document_categories","description")) {
157
+			return true;
158
+		}
111 159
 
112 160
 		//2011. 05. 23 adding status column to document
113
-		if(!$oDB->isColumnExists('documents', 'status')) return true;
161
+		if(!$oDB->isColumnExists('documents', 'status')) {
162
+			return true;
163
+		}
114 164
 
115 165
 		//2011. 06. 07 check comment status update
116
-		if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) return true;
166
+		if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment')) {
167
+			return true;
168
+		}
117 169
 
118 170
 		// 2011. 10. 25 status index check
119
-		if(!$oDB->isIndexExists("documents", "idx_module_status")) return true;
171
+		if(!$oDB->isIndexExists("documents", "idx_module_status")) {
172
+			return true;
173
+		}
120 174
 
121 175
 		// 2012. 02. 27 Add a trigger to copy extra keys when the module is copied 
122
-		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) return true;
176
+		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after')) {
177
+			return true;
178
+		}
123 179
 
124 180
 		// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied 
125
-		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) return true;
181
+		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModule', 'after')) {
182
+			return true;
183
+		}
126 184
 
127 185
 		return false;
128 186
 	}
@@ -164,20 +222,33 @@  discard block
 block discarded – undo
164 222
 			$oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
165 223
 		}
166 224
 		// 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
167
-		if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after'))
168
-			$oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after');
225
+		if(!$oModuleModel->getTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after')) {
226
+					$oModuleController->insertTrigger('module.deleteModule', 'document', 'controller', 'triggerDeleteModuleDocuments', 'after');
227
+		}
169 228
 		// 2007. 10. 25 add columns(parent_srl, expand) 
170
-		if(!$oDB->isColumnExists("document_categories","parent_srl")) $oDB->addColumn('document_categories',"parent_srl","number",12,0);
171
-		if(!$oDB->isColumnExists("document_categories","expand")) $oDB->addColumn('document_categories',"expand","char",1,"N");
172
-		if(!$oDB->isColumnExists("document_categories","group_srls")) $oDB->addColumn('document_categories',"group_srls","text");
229
+		if(!$oDB->isColumnExists("document_categories","parent_srl")) {
230
+			$oDB->addColumn('document_categories',"parent_srl","number",12,0);
231
+		}
232
+		if(!$oDB->isColumnExists("document_categories","expand")) {
233
+			$oDB->addColumn('document_categories',"expand","char",1,"N");
234
+		}
235
+		if(!$oDB->isColumnExists("document_categories","group_srls")) {
236
+			$oDB->addColumn('document_categories',"group_srls","text");
237
+		}
173 238
 		// 2007. 11. 20 create a composite index on the columns(module_srl + is_notice)
174
-		if(!$oDB->isIndexExists("documents","idx_module_notice")) $oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice"));
239
+		if(!$oDB->isIndexExists("documents","idx_module_notice")) {
240
+			$oDB->addIndex("documents","idx_module_notice", array("module_srl","is_notice"));
241
+		}
175 242
 
176 243
 		// 2007. 12. 03: Add if the colume(extra_vars) doesn't exist
177
-		if(!$oDB->isColumnExists("documents","extra_vars")) $oDB->addColumn('documents','extra_vars','text');
244
+		if(!$oDB->isColumnExists("documents","extra_vars")) {
245
+			$oDB->addColumn('documents','extra_vars','text');
246
+		}
178 247
 
179 248
 		// 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
180
-		if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
249
+		if(!$oDB->isIndexExists("documents","idx_module_document_srl")) {
250
+			$oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
251
+		}
181 252
 		// 2008. 04. 23 Add a column(blamed count)
182 253
 		if(!$oDB->isColumnExists("documents", "blamed_count"))
183 254
 		{
@@ -190,18 +261,24 @@  discard block
 block discarded – undo
190 261
 			$oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count'));
191 262
 		}
192 263
 
193
-		if(!$oDB->isColumnExists("document_voted_log", "point"))
194
-			$oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true);
264
+		if(!$oDB->isColumnExists("document_voted_log", "point")) {
265
+					$oDB->addColumn('document_voted_log', 'point', 'number', 11, 0, true);
266
+		}
195 267
 
196 268
 
197
-		if(!$oDB->isColumnExists("document_categories","color")) $oDB->addColumn('document_categories',"color","char",7);
269
+		if(!$oDB->isColumnExists("document_categories","color")) {
270
+			$oDB->addColumn('document_categories',"color","char",7);
271
+		}
198 272
 
199 273
 		// 2009. 01. 29: Add a column(lang_code) if not exist in the document_extra_vars table
200
-		if(!$oDB->isColumnExists("document_extra_vars","lang_code")) $oDB->addColumn('document_extra_vars',"lang_code","varchar",10);
274
+		if(!$oDB->isColumnExists("document_extra_vars","lang_code")) {
275
+			$oDB->addColumn('document_extra_vars',"lang_code","varchar",10);
276
+		}
201 277
 
202 278
 		// 2009. 01. 29 Added a trigger for additional setup
203
-		if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'))
204
-			$oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before');
279
+		if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before')) {
280
+					$oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before');
281
+		}
205 282
 		// 2009. 03. 09 Add a column(lang_code) to the documnets table
206 283
 		if(!$oDB->isColumnExists("documents","lang_code"))
207 284
 		{
@@ -262,7 +339,9 @@  discard block
 block discarded – undo
262 339
 		}
263 340
 
264 341
 		//2011. 04. 07 adding description column to document categories
265
-		if(!$oDB->isColumnExists("document_categories","description")) $oDB->addColumn('document_categories',"description","varchar",200,0);
342
+		if(!$oDB->isColumnExists("document_categories","description")) {
343
+			$oDB->addColumn('document_categories',"description","varchar",200,0);
344
+		}
266 345
 
267 346
 		//2011. 05. 23 adding status column to document
268 347
 		if(!$oDB->isColumnExists('documents', 'status'))
@@ -273,8 +352,9 @@  discard block
 block discarded – undo
273 352
 		}
274 353
 
275 354
 		// 2011. 09. 08 drop column document is_secret
276
-		if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret'))
277
-			$oDB->dropColumn('documents', 'is_secret');
355
+		if($oDB->isColumnExists('documents', 'status') && $oDB->isColumnExists('documents', 'is_secret')) {
356
+					$oDB->dropColumn('documents', 'is_secret');
357
+		}
278 358
 
279 359
 		//2011. 06. 07 merge column, allow_comment and lock_comment
280 360
 		if($oDB->isColumnExists('documents', 'allow_comment') || $oDB->isColumnExists('documents', 'lock_comment'))
@@ -299,14 +379,17 @@  discard block
 block discarded – undo
299 379
 			$output = executeQuery('document.updateDocumentCommentStatus', $args);
300 380
 		}
301 381
 
302
-		if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status'))
303
-			$oDB->dropColumn('documents', 'allow_comment');
382
+		if($oDB->isColumnExists('documents', 'allow_comment') && $oDB->isColumnExists('documents', 'comment_status')) {
383
+					$oDB->dropColumn('documents', 'allow_comment');
384
+		}
304 385
 
305
-		if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status'))
306
-			$oDB->dropColumn('documents', 'lock_comment');
386
+		if($oDB->isColumnExists('documents', 'lock_comment') && $oDB->isColumnExists('documents', 'comment_status')) {
387
+					$oDB->dropColumn('documents', 'lock_comment');
388
+		}
307 389
 
308
-		if(!$oDB->isIndexExists("documents", "idx_module_status"))
309
-			$oDB->addIndex("documents", "idx_module_status", array("module_srl","status"));
390
+		if(!$oDB->isIndexExists("documents", "idx_module_status")) {
391
+					$oDB->addIndex("documents", "idx_module_status", array("module_srl","status"));
392
+		}
310 393
 
311 394
 		// 2012. 02. 27 Add a trigger to copy extra keys when the module is copied 
312 395
 		if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'document', 'controller', 'triggerCopyModuleExtraKeys', 'after'))
@@ -355,8 +438,11 @@  discard block
 block discarded – undo
355 438
 	 */
356 439
 	function getConfigStatus($key)
357 440
 	{
358
-		if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key];
359
-		else $this->getDefaultStatus();
441
+		if(array_key_exists(strtolower($key), $this->statusList)) {
442
+			return $this->statusList[$key];
443
+		} else {
444
+			$this->getDefaultStatus();
445
+		}
360 446
 	}
361 447
 }
362 448
 /* End of file document.class.php */
Please login to merge, or discard this patch.
modules/document/document.controller.php 4 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 
713 713
 	/**
714 714
 	 * Move the doc into the trash
715
-	 * @param object $obj
715
+	 * @param stdClass $obj
716 716
 	 * @return object
717 717
 	 */
718 718
 	function moveDocumentToTrash($obj)
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 	 * @param mixed $value
1018 1018
 	 * @param int $eid
1019 1019
 	 * @param string $lang_code
1020
-	 * @return Object|void
1020
+	 * @return Object|null
1021 1021
 	 */
1022 1022
 	function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
1023 1023
 	{
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 	 * Occasionally the xml file is not generated after menu is configued on the admin page \n
1808 1808
 	 * The administrator can manually update the file in this case \n
1809 1809
 	 * Although the issue is not currently reproduced, it is unnecessay to remove.
1810
-	 * @return void
1810
+	 * @return Object|null
1811 1811
 	 */
1812 1812
 	function procDocumentMakeXmlFile()
1813 1813
 	{
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 
2140 2140
 	/**
2141 2141
 	 * Saved in the session when an administrator selects a post
2142
-	 * @return void|Object
2142
+	 * @return Object|null
2143 2143
 	 */
2144 2144
 	function procDocumentAddCart()
2145 2145
 	{
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
 
2213 2213
 	/**
2214 2214
 	 * Move/ Delete the document in the seession
2215
-	 * @return void|Object
2215
+	 * @return Object|null
2216 2216
 	 */
2217 2217
 	function procDocumentManageCheckedDocument()
2218 2218
 	{
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 
2375 2375
 	/**
2376 2376
 	 * Document temporary save
2377
-	 * @return void|Object
2377
+	 * @return Object|null
2378 2378
 	 */
2379 2379
 	function procDocumentTempSave()
2380 2380
 	{
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 
2441 2441
 	/**
2442 2442
 	 * Return Document List for exec_xml
2443
-	 * @return void|Object
2443
+	 * @return Object|null
2444 2444
 	 */
2445 2445
 	function procDocumentGetList()
2446 2446
 	{
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 /**
4
- * documentController class
5
- * document the module's controller class
6
- *
7
- * @author NAVER ([email protected])
8
- * @package /modules/document
9
- * @version 0.1
10
- */
4
+	 * documentController class
5
+	 * document the module's controller class
6
+	 *
7
+	 * @author NAVER ([email protected])
8
+	 * @package /modules/document
9
+	 * @version 0.1
10
+	 */
11 11
 class documentController extends document
12 12
 {
13 13
 	/**
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		if(!$obj->email_address) $obj->email_address = '';
220 220
 		if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
221 221
 
222
-                // can modify regdate only manager
223
-                $grant = Context::get('grant');
222
+				// can modify regdate only manager
223
+				$grant = Context::get('grant');
224 224
 		if(!$grant->manager)
225 225
 		{
226 226
 			unset($obj->regdate);
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
423 423
 		
424 424
 		// can modify regdate only manager
425
-                $grant = Context::get('grant');
425
+				$grant = Context::get('grant');
426 426
 		if(!$grant->manager)
427 427
 		{
428 428
 			unset($obj->regdate);
Please login to merge, or discard this patch.
Spacing   +404 added lines, -404 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 Object(-1, 'msg_invalid_request');
27
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
28 28
 
29 29
 		$document_srl = Context::get('target_srl');
30
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
30
+		if (!$document_srl) return new Object(-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 Object(-1, 'msg_invalid_request');
35
+		if (!$module_srl) return new Object(-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 Object(-1, 'msg_invalid_request');
38
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
39
+		if ($document_config->use_vote_up == 'N') return new Object(-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 Object(-1, 'msg_invalid_request');
72
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
73 73
 
74 74
 		$document_srl = Context::get('target_srl');
75
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
75
+		if (!$document_srl) return new Object(-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 Object(-1, 'msg_invalid_request');
80
+		if (!$module_srl) return new Object(-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 Object(-1, 'msg_invalid_request');
83
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
84
+		if ($document_config->use_vote_down == 'N') return new Object(-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 Object(-1, 'msg_invalid_request');
98
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
99 99
 
100 100
 		$document_srl = Context::get('target_srl');
101
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
101
+		if (!$document_srl) return new Object(-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 Object();
155
+		if (!$module_srl) return new Object();
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 Object(-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
-				$obj->homepage = 'http://'.$obj->homepage;
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 Object(-1, 'msg_not_permitted');
240
+		if (!$obj->document_srl) $obj->document_srl = getNextSequence();
241
+		elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new Object(-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 Object(-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);
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())
284
+		if (Mobile::isFromMobilePhone())
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 Object(-1,'msg_invalid_request');
295
+		if (!$logged_info->member_srl && !$obj->nick_name) return new Object(-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
-					$tmp = $obj->{'extra_vars'.$idx};
316
-					if(is_array($tmp))
315
+					$tmp = $obj->{'extra_vars' . $idx};
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
 	}
@@ -360,41 +360,41 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	function updateDocument($source_obj, $obj, $manual_updated = FALSE)
362 362
 	{
363
-		if(!$manual_updated && !checkCSRF())
363
+		if (!$manual_updated && !checkCSRF())
364 364
 		{
365 365
 			return new Object(-1, 'msg_invalid_request');
366 366
 		}
367 367
 
368
-		if(!$source_obj->document_srl || !$obj->document_srl) return new Object(-1,'msg_invalied_request');
369
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
370
-		if(!$obj->status) $obj->status = 'PUBLIC';
368
+		if (!$source_obj->document_srl || !$obj->document_srl) return new Object(-1, 'msg_invalied_request');
369
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
370
+		if (!$obj->status) $obj->status = 'PUBLIC';
371 371
 
372 372
 		// Call a trigger (before)
373 373
 		$output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
374
-		if(!$output->toBool()) return $output;
374
+		if (!$output->toBool()) return $output;
375 375
 
376 376
 		// begin transaction
377 377
 		$oDB = &DB::getInstance();
378 378
 		$oDB->begin();
379 379
 
380 380
 		$oModuleModel = getModel('module');
381
-		if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
381
+		if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
382 382
 		$module_srl = $obj->module_srl;
383 383
 		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
384
-		if(!$document_config)
384
+		if (!$document_config)
385 385
 		{
386 386
 			$document_config = new stdClass();
387 387
 		}
388
-		if(!isset($document_config->use_history)) $document_config->use_history = 'N';
388
+		if (!isset($document_config->use_history)) $document_config->use_history = 'N';
389 389
 		$bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace';
390 390
 
391
-		if($bUseHistory)
391
+		if ($bUseHistory)
392 392
 		{
393 393
 			$args = new stdClass;
394 394
 			$args->history_srl = getNextSequence();
395 395
 			$args->document_srl = $obj->document_srl;
396 396
 			$args->module_srl = $module_srl;
397
-			if($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
397
+			if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
398 398
 			$args->nick_name = $source_obj->get('nick_name');
399 399
 			$args->member_srl = $source_obj->get('member_srl');
400 400
 			$args->regdate = $source_obj->get('last_update');
@@ -406,30 +406,30 @@  discard block
 block discarded – undo
406 406
 			$obj->ipaddress = $source_obj->get('ipaddress');
407 407
 		}
408 408
 		// List variables
409
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
410
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
411
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
412
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
413
-		if($obj->homepage)
409
+		if ($obj->comment_status) $obj->commentStatus = $obj->comment_status;
410
+		if (!$obj->commentStatus) $obj->commentStatus = 'DENY';
411
+		if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
412
+		if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N';
413
+		if ($obj->homepage)
414 414
 		{
415 415
 			$obj->homepage = removeHackTag($obj->homepage);
416
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
416
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
417 417
 			{
418
-				$obj->homepage = 'http://'.$obj->homepage;
418
+				$obj->homepage = 'http://' . $obj->homepage;
419 419
 			}
420 420
 		}
421 421
 		
422
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
422
+		if ($obj->notify_message != 'Y') $obj->notify_message = 'N';
423 423
 		
424 424
 		// can modify regdate only manager
425 425
                 $grant = Context::get('grant');
426
-		if(!$grant->manager)
426
+		if (!$grant->manager)
427 427
 		{
428 428
 			unset($obj->regdate);
429 429
 		}
430 430
 		
431 431
 		// Serialize the $extra_vars
432
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
432
+		if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
433 433
 		// Remove the columns for automatic saving
434 434
 		unset($obj->_saved_doc_srl);
435 435
 		unset($obj->_saved_doc_title);
@@ -438,23 +438,23 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$oDocumentModel = getModel('document');
440 440
 		// Set the category_srl to 0 if the changed category is not exsiting.
441
-		if($source_obj->get('category_srl')!=$obj->category_srl)
441
+		if ($source_obj->get('category_srl') != $obj->category_srl)
442 442
 		{
443 443
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
444
-			if(!$category_list[$obj->category_srl]) $obj->category_srl = 0;
444
+			if (!$category_list[$obj->category_srl]) $obj->category_srl = 0;
445 445
 		}
446 446
 		// Change the update order
447 447
 		$obj->update_order = getNextSequence() * -1;
448 448
 		// Hash the password if it exists
449
-		if($obj->password)
449
+		if ($obj->password)
450 450
 		{
451 451
 			$obj->password = getModel('member')->hashPassword($obj->password);
452 452
 		}
453 453
 		// If an author is identical to the modifier or history is used, use the logged-in user's information.
454
-		if(Context::get('is_logged'))
454
+		if (Context::get('is_logged'))
455 455
 		{
456 456
 			$logged_info = Context::get('logged_info');
457
-			if($source_obj->get('member_srl')==$logged_info->member_srl)
457
+			if ($source_obj->get('member_srl') == $logged_info->member_srl)
458 458
 			{
459 459
 				$obj->member_srl = $logged_info->member_srl;
460 460
 				$obj->user_name = htmlspecialchars_decode($logged_info->user_name);
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 			}
465 465
 		}
466 466
 		// For the document written by logged-in user however no nick_name exists
467
-		if($source_obj->get('member_srl')&& !$obj->nick_name)
467
+		if ($source_obj->get('member_srl') && !$obj->nick_name)
468 468
 		{
469 469
 			$obj->member_srl = $source_obj->get('member_srl');
470 470
 			$obj->user_name = $source_obj->get('user_name');
@@ -474,24 +474,24 @@  discard block
 block discarded – undo
474 474
 		}
475 475
 		// If the tile is empty, extract string from the contents.
476 476
 		settype($obj->title, "string");
477
-		if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
477
+		if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...');
478 478
 		// If no tile extracted from the contents, leave it untitled.
479
-		if($obj->title == '') $obj->title = 'Untitled';
479
+		if ($obj->title == '') $obj->title = 'Untitled';
480 480
 		// Remove XE's own tags from the contents.
481 481
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
482
-		if(Mobile::isFromMobilePhone())
482
+		if (Mobile::isFromMobilePhone())
483 483
 		{
484
-			if($obj->use_html != 'Y')
484
+			if ($obj->use_html != 'Y')
485 485
 			{
486 486
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
487 487
 			}
488 488
 			$obj->content = nl2br($obj->content);
489 489
 		}
490 490
 		// Change not extra vars but language code of the original document if document's lang_code is different from author's setting.
491
-		if($source_obj->get('lang_code') != Context::getLangType())
491
+		if ($source_obj->get('lang_code') != Context::getLangType())
492 492
 		{
493 493
 			// Change not extra vars but language code of the original document if document's lang_code doesn't exist.
494
-			if(!$source_obj->get('lang_code'))
494
+			if (!$source_obj->get('lang_code'))
495 495
 			{
496 496
 				$lang_code_args->document_srl = $source_obj->get('document_srl');
497 497
 				$lang_code_args->lang_code = Context::getLangType();
@@ -511,59 +511,59 @@  discard block
 block discarded – undo
511 511
 			}
512 512
 		}
513 513
 		// Remove iframe and script if not a top adminisrator in the session.
514
-		if($logged_info->is_admin != 'Y')
514
+		if ($logged_info->is_admin != 'Y')
515 515
 		{
516 516
 			$obj->content = removeHackTag($obj->content);
517 517
 		}
518 518
 		// if temporary document, regdate is now setting
519
-		if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
519
+		if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
520 520
 
521 521
 		// Insert data into the DB
522 522
 		$output = executeQuery('document.updateDocument', $obj);
523
-		if(!$output->toBool())
523
+		if (!$output->toBool())
524 524
 		{
525 525
 			$oDB->rollback();
526 526
 			return $output;
527 527
 		}
528 528
 		// Remove all extra variables
529
-		if(Context::get('act')!='procFileDelete')
529
+		if (Context::get('act') != 'procFileDelete')
530 530
 		{
531 531
 			$this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType());
532 532
 			// Insert extra variables if the document successfully inserted.
533 533
 			$extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
534
-			if(count($extra_keys))
534
+			if (count($extra_keys))
535 535
 			{
536
-				foreach($extra_keys as $idx => $extra_item)
536
+				foreach ($extra_keys as $idx => $extra_item)
537 537
 				{
538 538
 					$value = NULL;
539
-					if(isset($obj->{'extra_vars'.$idx}))
539
+					if (isset($obj->{'extra_vars' . $idx}))
540 540
 					{
541
-						$tmp = $obj->{'extra_vars'.$idx};
542
-						if(is_array($tmp))
541
+						$tmp = $obj->{'extra_vars' . $idx};
542
+						if (is_array($tmp))
543 543
 							$value = implode('|@|', $tmp);
544 544
 						else
545 545
 							$value = trim($tmp);
546 546
 					}
547
-					else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
548
-					if($value == NULL) continue;
547
+					else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
548
+					if ($value == NULL) continue;
549 549
 					$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
550 550
 				}
551 551
 			}
552 552
 			// Inert extra vars for multi-language support of title and contents.
553
-			if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
554
-			if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
553
+			if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_' . Context::getLangType());
554
+			if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_' . Context::getLangType());
555 555
 		}
556 556
 		// Update the category if the category_srl exists.
557
-		if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
557
+		if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
558 558
 		{
559
-			if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
560
-			if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
559
+			if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
560
+			if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
561 561
 		}
562 562
 		// Call a trigger (after)
563
-		if($output->toBool())
563
+		if ($output->toBool())
564 564
 		{
565 565
 			$trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
566
-			if(!$trigger_output->toBool())
566
+			if (!$trigger_output->toBool())
567 567
 			{
568 568
 				$oDB->rollback();
569 569
 				return $trigger_output;
@@ -573,15 +573,15 @@  discard block
 block discarded – undo
573 573
 		// commit
574 574
 		$oDB->commit();
575 575
 		// Remove the thumbnail file
576
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
576
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
577 577
 
578
-		$output->add('document_srl',$obj->document_srl);
578
+		$output->add('document_srl', $obj->document_srl);
579 579
 		//remove from cache
580 580
 		$oCacheHandler = CacheHandler::getInstance('object');
581
-		if($oCacheHandler->isSupport())
581
+		if ($oCacheHandler->isSupport())
582 582
 		{
583 583
 			//remove document item from cache
584
-			$cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl;
584
+			$cache_key = 'document_item:' . getNumberingPath($obj->document_srl) . $obj->document_srl;
585 585
 			$oCacheHandler->delete($cache_key);
586 586
 		}
587 587
 
@@ -602,33 +602,33 @@  discard block
 block discarded – undo
602 602
 		$trigger_obj = new stdClass();
603 603
 		$trigger_obj->document_srl = $document_srl;
604 604
 		$output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
605
-		if(!$output->toBool()) return $output;
605
+		if (!$output->toBool()) return $output;
606 606
 
607 607
 		// begin transaction
608 608
 		$oDB = &DB::getInstance();
609 609
 		$oDB->begin();
610 610
 
611
-		if(!$isEmptyTrash)
611
+		if (!$isEmptyTrash)
612 612
 		{
613 613
 			// get model object of the document
614 614
 			$oDocumentModel = getModel('document');
615 615
 			// Check if the documnet exists
616 616
 			$oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
617 617
 		}
618
-		else if($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists');
618
+		else if ($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists');
619 619
 
620
-		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
620
+		if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
621 621
 		// Check if a permossion is granted
622
-		if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
622
+		if (!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
623 623
 
624 624
 		//if empty trash, document already deleted, therefore document not delete
625 625
 		$args = new stdClass();
626 626
 		$args->document_srl = $document_srl;
627
-		if(!$isEmptyTrash)
627
+		if (!$isEmptyTrash)
628 628
 		{
629 629
 			// Delete the document
630 630
 			$output = executeQuery('document.deleteDocument', $args);
631
-			if(!$output->toBool())
631
+			if (!$output->toBool())
632 632
 			{
633 633
 				$oDB->rollback();
634 634
 				return $output;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 
640 640
 		$this->deleteDocumentHistory(null, $document_srl, null);
641 641
 		// Update category information if the category_srl exists.
642
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
642
+		if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
643 643
 		// Delete a declared list
644 644
 		executeQuery('document.deleteDeclared', $args);
645 645
 		// Delete extra variable
@@ -647,11 +647,11 @@  discard block
 block discarded – undo
647 647
 
648 648
 		//this
649 649
 		// Call a trigger (after)
650
-		if($output->toBool())
650
+		if ($output->toBool())
651 651
 		{
652 652
 			$trigger_obj = $oDocument->getObjectVars();
653 653
 			$trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj);
654
-			if(!$trigger_output->toBool())
654
+			if (!$trigger_output->toBool())
655 655
 			{
656 656
 				$oDB->rollback();
657 657
 				return $trigger_output;
@@ -663,16 +663,16 @@  discard block
 block discarded – undo
663 663
 		$this->_deleteDocumentVotedLog($args);
664 664
 
665 665
 		// Remove the thumbnail file
666
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3)));
666
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3)));
667 667
 
668 668
 		// commit
669 669
 		$oDB->commit();
670 670
 
671 671
 		//remove from cache
672 672
 		$oCacheHandler = CacheHandler::getInstance('object');
673
-		if($oCacheHandler->isSupport())
673
+		if ($oCacheHandler->isSupport())
674 674
 		{
675
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
675
+			$cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
676 676
 			$oCacheHandler->delete($cache_key);
677 677
 		}
678 678
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	{
720 720
 		$trash_args = new stdClass();
721 721
 		// Get trash_srl if a given trash_srl doesn't exist
722
-		if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
722
+		if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
723 723
 		else $trash_args->trash_srl = $obj->trash_srl;
724 724
 		// Get its module_srl which the document belongs to
725 725
 		$oDocumentModel = getModel('document');
@@ -728,12 +728,12 @@  discard block
 block discarded – undo
728 728
 		$trash_args->module_srl = $oDocument->get('module_srl');
729 729
 		$obj->module_srl = $oDocument->get('module_srl');
730 730
 		// Cannot throw data from the trash to the trash
731
-		if($trash_args->module_srl == 0) return false;
731
+		if ($trash_args->module_srl == 0) return false;
732 732
 		// Data setting
733 733
 		$trash_args->document_srl = $obj->document_srl;
734 734
 		$trash_args->description = $obj->description;
735 735
 		// Insert member's information only if the member is logged-in and not manually registered.
736
-		if(Context::get('is_logged')&&!$manual_inserted)
736
+		if (Context::get('is_logged') && !$manual_inserted)
737 737
 		{
738 738
 			$logged_info = Context::get('logged_info');
739 739
 			$trash_args->member_srl = $logged_info->member_srl;
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 		  }*/
760 760
 
761 761
 		// new trash module
762
-		require_once(_XE_PATH_.'modules/trash/model/TrashVO.php');
762
+		require_once(_XE_PATH_ . 'modules/trash/model/TrashVO.php');
763 763
 		$oTrashVO = new TrashVO();
764 764
 		$oTrashVO->setTrashSrl(getNextSequence());
765 765
 		$oTrashVO->setTitle($oDocument->variables['title']);
@@ -769,14 +769,14 @@  discard block
 block discarded – undo
769 769
 
770 770
 		$oTrashAdminController = getAdminController('trash');
771 771
 		$output = $oTrashAdminController->insertTrash($oTrashVO);
772
-		if(!$output->toBool())
772
+		if (!$output->toBool())
773 773
 		{
774 774
 			$oDB->rollback();
775 775
 			return $output;
776 776
 		}
777 777
 
778 778
 		$output = executeQuery('document.deleteDocument', $trash_args);
779
-		if(!$output->toBool())
779
+		if (!$output->toBool())
780 780
 		{
781 781
 			$oDB->rollback();
782 782
 			return $output;
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
 		  }*/
790 790
 
791 791
 		// update category
792
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
792
+		if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
793 793
 
794 794
 		// remove thumbnails
795
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
795
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
796 796
 		// Set the attachment to be invalid state
797
-		if($oDocument->hasUploadedFiles())
797
+		if ($oDocument->hasUploadedFiles())
798 798
 		{
799 799
 			$args = new stdClass();
800 800
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -802,10 +802,10 @@  discard block
 block discarded – undo
802 802
 			executeQuery('file.updateFileValid', $args);
803 803
 		}
804 804
 		// Call a trigger (after)
805
-		if($output->toBool())
805
+		if ($output->toBool())
806 806
 		{
807 807
 			$trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
808
-			if(!$trigger_output->toBool())
808
+			if (!$trigger_output->toBool())
809 809
 			{
810 810
 				$oDB->rollback();
811 811
 				return $trigger_output;
@@ -817,9 +817,9 @@  discard block
 block discarded – undo
817 817
 
818 818
 		// Clear cache
819 819
 		$oCacheHandler = CacheHandler::getInstance('object');
820
-		if($oCacheHandler->isSupport())
820
+		if ($oCacheHandler->isSupport())
821 821
 		{
822
-			$cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl;
822
+			$cache_key = 'document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl;
823 823
 			$oCacheHandler->delete($cache_key);
824 824
 		}
825 825
 
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 	function updateReadedCount(&$oDocument)
835 835
 	{
836 836
 		// Pass if Crawler access
837
-		if(isCrawler()) return false;
837
+		if (isCrawler()) return false;
838 838
 		
839 839
 		$document_srl = $oDocument->document_srl;
840 840
 		$member_srl = $oDocument->get('member_srl');
@@ -842,19 +842,19 @@  discard block
 block discarded – undo
842 842
 
843 843
 		// Call a trigger when the read count is updated (before)
844 844
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument);
845
-		if(!$trigger_output->toBool()) return $trigger_output;
845
+		if (!$trigger_output->toBool()) return $trigger_output;
846 846
 
847 847
 		// Pass if read count is increaded on the session information
848
-		if($_SESSION['readed_document'][$document_srl]) return false;
848
+		if ($_SESSION['readed_document'][$document_srl]) return false;
849 849
 
850 850
 		// Pass if the author's IP address is as same as visitor's.
851
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
851
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
852 852
 		{
853 853
 			$_SESSION['readed_document'][$document_srl] = true;
854 854
 			return false;
855 855
 		}
856 856
 		// Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user.
857
-		if($member_srl && $logged_info->member_srl == $member_srl)
857
+		if ($member_srl && $logged_info->member_srl == $member_srl)
858 858
 		{
859 859
 			$_SESSION['readed_document'][$document_srl] = true;
860 860
 			return false;
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 
871 871
 		// Call a trigger when the read count is updated (after)
872 872
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument);
873
-		if(!$trigger_output->toBool())
873
+		if (!$trigger_output->toBool())
874 874
 		{
875 875
 			$oDB->rollback();
876 876
 			return $trigger_output;
@@ -879,15 +879,15 @@  discard block
 block discarded – undo
879 879
 		$oDB->commit();
880 880
 
881 881
 		$oCacheHandler = CacheHandler::getInstance('object');
882
-		if($oCacheHandler->isSupport())
882
+		if ($oCacheHandler->isSupport())
883 883
 		{
884 884
 			//remove document item from cache
885
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
885
+			$cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
886 886
 			$oCacheHandler->delete($cache_key);
887 887
 		}
888 888
 
889 889
 		// Register session
890
-		if(!$_SESSION['banned_document'][$document_srl]) 
890
+		if (!$_SESSION['banned_document'][$document_srl]) 
891 891
 		{
892 892
 			$_SESSION['readed_document'][$document_srl] = true;
893 893
 		}
@@ -910,21 +910,21 @@  discard block
 block discarded – undo
910 910
 	 */
911 911
 	function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid)
912 912
 	{
913
-		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1,'msg_invalid_request');
913
+		if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1, 'msg_invalid_request');
914 914
 
915 915
 		$obj = new stdClass();
916 916
 		$obj->module_srl = $module_srl;
917 917
 		$obj->var_idx = $var_idx;
918 918
 		$obj->var_name = $var_name;
919 919
 		$obj->var_type = $var_type;
920
-		$obj->var_is_required = $var_is_required=='Y'?'Y':'N';
921
-		$obj->var_search = $var_search=='Y'?'Y':'N';
920
+		$obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N';
921
+		$obj->var_search = $var_search == 'Y' ? 'Y' : 'N';
922 922
 		$obj->var_default = $var_default;
923 923
 		$obj->var_desc = $var_desc;
924 924
 		$obj->eid = $eid;
925 925
 
926 926
 		$output = executeQuery('document.getDocumentExtraKeys', $obj);
927
-		if(!$output->data)
927
+		if (!$output->data)
928 928
 		{
929 929
 			$output = executeQuery('document.insertDocumentExtraKey', $obj);
930 930
 		}
@@ -936,9 +936,9 @@  discard block
 block discarded – undo
936 936
 		}
937 937
 
938 938
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
939
-		if($oCacheHandler->isSupport())
939
+		if ($oCacheHandler->isSupport())
940 940
 		{
941
-			$object_key = 'module_document_extra_keys:'.$module_srl;
941
+			$object_key = 'module_document_extra_keys:' . $module_srl;
942 942
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
943 943
 			$oCacheHandler->delete($cache_key);
944 944
 		}
@@ -954,42 +954,42 @@  discard block
 block discarded – undo
954 954
 	 */
955 955
 	function deleteDocumentExtraKeys($module_srl, $var_idx = null)
956 956
 	{
957
-		if(!$module_srl) return new Object(-1,'msg_invalid_request');
957
+		if (!$module_srl) return new Object(-1, 'msg_invalid_request');
958 958
 		$obj = new stdClass();
959 959
 		$obj->module_srl = $module_srl;
960
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
960
+		if (!is_null($var_idx)) $obj->var_idx = $var_idx;
961 961
 
962 962
 		$oDB = DB::getInstance();
963 963
 		$oDB->begin();
964 964
 
965 965
 		$output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj);
966
-		if(!$output->toBool())
966
+		if (!$output->toBool())
967 967
 		{
968 968
 			$oDB->rollback();
969 969
 			return $output;
970 970
 		}
971 971
 
972
-		if($var_idx != NULL)
972
+		if ($var_idx != NULL)
973 973
 		{
974 974
 			$output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj);
975
-			if(!$output->toBool())
975
+			if (!$output->toBool())
976 976
 			{
977 977
 				$oDB->rollback();
978 978
 				return $output;
979 979
 			}
980 980
 		}
981 981
 
982
-		$output =  executeQuery('document.deleteDocumentExtraVars', $obj);
983
-		if(!$output->toBool())
982
+		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
983
+		if (!$output->toBool())
984 984
 		{
985 985
 			$oDB->rollback();
986 986
 			return $output;
987 987
 		}
988 988
 
989
-		if($var_idx != NULL)
989
+		if ($var_idx != NULL)
990 990
 		{
991 991
 			$output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj);
992
-			if(!$output->toBool())
992
+			if (!$output->toBool())
993 993
 			{
994 994
 				$oDB->rollback();
995 995
 				return $output;
@@ -999,9 +999,9 @@  discard block
 block discarded – undo
999 999
 		$oDB->commit();
1000 1000
 
1001 1001
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
1002
-		if($oCacheHandler->isSupport())
1002
+		if ($oCacheHandler->isSupport())
1003 1003
 		{
1004
-			$object_key = 'module_document_extra_keys:'.$module_srl;
1004
+			$object_key = 'module_document_extra_keys:' . $module_srl;
1005 1005
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
1006 1006
 			$oCacheHandler->delete($cache_key);
1007 1007
 		}
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 	 */
1022 1022
 	function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
1023 1023
 	{
1024
-		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1,'msg_invalid_request');
1025
-		if(!$lang_code) $lang_code = Context::getLangType();
1024
+		if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1, 'msg_invalid_request');
1025
+		if (!$lang_code) $lang_code = Context::getLangType();
1026 1026
 
1027 1027
 		$obj = new stdClass;
1028 1028
 		$obj->module_srl = $module_srl;
@@ -1048,10 +1048,10 @@  discard block
 block discarded – undo
1048 1048
 	{
1049 1049
 		$obj = new stdClass();
1050 1050
 		$obj->module_srl = $module_srl;
1051
-		if(!is_null($document_srl)) $obj->document_srl = $document_srl;
1052
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1053
-		if(!is_null($lang_code)) $obj->lang_code = $lang_code;
1054
-		if(!is_null($eid)) $obj->eid = $eid;
1051
+		if (!is_null($document_srl)) $obj->document_srl = $document_srl;
1052
+		if (!is_null($var_idx)) $obj->var_idx = $var_idx;
1053
+		if (!is_null($lang_code)) $obj->lang_code = $lang_code;
1054
+		if (!is_null($eid)) $obj->eid = $eid;
1055 1055
 		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
1056 1056
 		return $output;
1057 1057
 	}
@@ -1065,10 +1065,10 @@  discard block
 block discarded – undo
1065 1065
 	 */
1066 1066
 	function updateVotedCount($document_srl, $point = 1)
1067 1067
 	{
1068
-		if($point > 0) $failed_voted = 'failed_voted';
1068
+		if ($point > 0) $failed_voted = 'failed_voted';
1069 1069
 		else $failed_voted = 'failed_blamed';
1070 1070
 		// Return fail if session already has information about votes
1071
-		if($_SESSION['voted_document'][$document_srl])
1071
+		if ($_SESSION['voted_document'][$document_srl])
1072 1072
 		{
1073 1073
 			return new Object(-1, $failed_voted);
1074 1074
 		}
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 		$oDocumentModel = getModel('document');
1077 1077
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1078 1078
 		// Pass if the author's IP address is as same as visitor's.
1079
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1079
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1080 1080
 		{
1081 1081
 			$_SESSION['voted_document'][$document_srl] = true;
1082 1082
 			return new Object(-1, $failed_voted);
@@ -1087,10 +1087,10 @@  discard block
 block discarded – undo
1087 1087
 		$member_srl = $oMemberModel->getLoggedMemberSrl();
1088 1088
 
1089 1089
 		// Check if document's author is a member.
1090
-		if($oDocument->get('member_srl'))
1090
+		if ($oDocument->get('member_srl'))
1091 1091
 		{
1092 1092
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1093
-			if($member_srl && $member_srl == $oDocument->get('member_srl'))
1093
+			if ($member_srl && $member_srl == $oDocument->get('member_srl'))
1094 1094
 			{
1095 1095
 				$_SESSION['voted_document'][$document_srl] = true;
1096 1096
 				return new Object(-1, $failed_voted);
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 		// Use member_srl for logged-in members and IP address for non-members.
1101 1101
 		$args = new stdClass;
1102
-		if($member_srl)
1102
+		if ($member_srl)
1103 1103
 		{
1104 1104
 			$args->member_srl = $member_srl;
1105 1105
 		}
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 		$args->document_srl = $document_srl;
1111 1111
 		$output = executeQuery('document.getDocumentVotedLogInfo', $args);
1112 1112
 		// Pass after registering a session if log information has vote-up logs
1113
-		if($output->data->count)
1113
+		if ($output->data->count)
1114 1114
 		{
1115 1115
 			$_SESSION['voted_document'][$document_srl] = true;
1116 1116
 			return new Object(-1, $failed_voted);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		$oDB->begin();
1122 1122
 
1123 1123
 		// Update the voted count
1124
-		if($point < 0)
1124
+		if ($point < 0)
1125 1125
 		{
1126 1126
 			$args->blamed_count = $oDocument->get('blamed_count') + $point;
1127 1127
 			$output = executeQuery('document.updateBlamedCount', $args);
@@ -1131,11 +1131,11 @@  discard block
 block discarded – undo
1131 1131
 			$args->voted_count = $oDocument->get('voted_count') + $point;
1132 1132
 			$output = executeQuery('document.updateVotedCount', $args);
1133 1133
 		}
1134
-		if(!$output->toBool()) return $output;
1134
+		if (!$output->toBool()) return $output;
1135 1135
 		// Leave logs
1136 1136
 		$args->point = $point;
1137 1137
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1138
-		if(!$output->toBool()) return $output;
1138
+		if (!$output->toBool()) return $output;
1139 1139
 
1140 1140
 		$obj = new stdClass;
1141 1141
 		$obj->member_srl = $oDocument->get('member_srl');
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 		$obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count');
1147 1147
 		$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
1148 1148
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj);
1149
-		if(!$trigger_output->toBool())
1149
+		if (!$trigger_output->toBool())
1150 1150
 		{
1151 1151
 			$oDB->rollback();
1152 1152
 			return $trigger_output;
@@ -1155,10 +1155,10 @@  discard block
 block discarded – undo
1155 1155
 		$oDB->commit();
1156 1156
 
1157 1157
 		$oCacheHandler = CacheHandler::getInstance('object');
1158
-		if($oCacheHandler->isSupport())
1158
+		if ($oCacheHandler->isSupport())
1159 1159
 		{
1160 1160
 			//remove document item from cache
1161
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1161
+			$cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
1162 1162
 			$oCacheHandler->delete($cache_key);
1163 1163
 		}
1164 1164
 
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 
1168 1168
 		// Return result
1169 1169
 		$output = new Object();
1170
-		if($point > 0)
1170
+		if ($point > 0)
1171 1171
 		{
1172 1172
 			$output->setMessage('success_voted');
1173 1173
 			$output->add('voted_count', $obj->after_point);
@@ -1189,13 +1189,13 @@  discard block
 block discarded – undo
1189 1189
 	function declaredDocument($document_srl)
1190 1190
 	{
1191 1191
 		// Fail if session information already has a reported document
1192
-		if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
1192
+		if ($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
1193 1193
 
1194 1194
 		// Check if previously reported
1195 1195
 		$args = new stdClass();
1196 1196
 		$args->document_srl = $document_srl;
1197 1197
 		$output = executeQuery('document.getDeclaredDocument', $args);
1198
-		if(!$output->toBool()) return $output;
1198
+		if (!$output->toBool()) return $output;
1199 1199
 
1200 1200
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1201 1201
 
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 
1206 1206
 		// Call a trigger (before)
1207 1207
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj);
1208
-		if(!$trigger_output->toBool())
1208
+		if (!$trigger_output->toBool())
1209 1209
 		{
1210 1210
 			return $trigger_output;
1211 1211
 		}
@@ -1215,19 +1215,19 @@  discard block
 block discarded – undo
1215 1215
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1216 1216
 
1217 1217
 		// Pass if the author's IP address is as same as visitor's.
1218
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1218
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1219 1219
 			$_SESSION['declared_document'][$document_srl] = true;
1220 1220
 			return new Object(-1, 'failed_declared');
1221 1221
 		}
1222 1222
 
1223 1223
 		// Check if document's author is a member.
1224
-		if($oDocument->get('member_srl'))
1224
+		if ($oDocument->get('member_srl'))
1225 1225
 		{
1226 1226
 			// Create a member model object
1227 1227
 			$oMemberModel = getModel('member');
1228 1228
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1229 1229
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1230
-			if($member_srl && $member_srl == $oDocument->get('member_srl'))
1230
+			if ($member_srl && $member_srl == $oDocument->get('member_srl'))
1231 1231
 			{
1232 1232
 				$_SESSION['declared_document'][$document_srl] = true;
1233 1233
 				return new Object(-1, 'failed_declared');
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 
1237 1237
 		// Use member_srl for logged-in members and IP address for non-members.
1238 1238
 		$args = new stdClass;
1239
-		if($member_srl)
1239
+		if ($member_srl)
1240 1240
 		{
1241 1241
 			$args->member_srl = $member_srl;
1242 1242
 		}
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 		$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
1250 1250
 
1251 1251
 		// Pass after registering a sesson if reported/declared documents are in the logs.
1252
-		if($output->data->count)
1252
+		if ($output->data->count)
1253 1253
 		{
1254 1254
 			$_SESSION['declared_document'][$document_srl] = true;
1255 1255
 			return new Object(-1, 'failed_declared');
@@ -1260,23 +1260,23 @@  discard block
 block discarded – undo
1260 1260
 		$oDB->begin();
1261 1261
 
1262 1262
 		// Add the declared document
1263
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1263
+		if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1264 1264
 		else $output = executeQuery('document.insertDeclaredDocument', $args);
1265
-		if(!$output->toBool()) return $output;
1265
+		if (!$output->toBool()) return $output;
1266 1266
 		// Leave logs
1267 1267
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1268
-		if(!$output->toBool())
1268
+		if (!$output->toBool())
1269 1269
 		{
1270 1270
 			$oDB->rollback();
1271 1271
 			return $output;
1272 1272
 		}
1273 1273
 
1274
-		$this->add('declared_count', $declared_count+1);
1274
+		$this->add('declared_count', $declared_count + 1);
1275 1275
 
1276 1276
 		// Call a trigger (after)
1277 1277
 		$trigger_obj->declared_count = $declared_count + 1;
1278 1278
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj);
1279
-		if(!$trigger_output->toBool())
1279
+		if (!$trigger_output->toBool())
1280 1280
 		{
1281 1281
 			$oDB->rollback();
1282 1282
 			return $trigger_output;
@@ -1306,16 +1306,16 @@  discard block
 block discarded – undo
1306 1306
 		$args->document_srl = $document_srl;
1307 1307
 		$args->comment_count = $comment_count;
1308 1308
 
1309
-		if($comment_inserted)
1309
+		if ($comment_inserted)
1310 1310
 		{
1311
-			$args->update_order = -1*getNextSequence();
1311
+			$args->update_order = -1 * getNextSequence();
1312 1312
 			$args->last_updater = $last_updater;
1313 1313
 
1314 1314
 			$oCacheHandler = CacheHandler::getInstance('object');
1315
-			if($oCacheHandler->isSupport())
1315
+			if ($oCacheHandler->isSupport())
1316 1316
 			{
1317 1317
 				//remove document item from cache
1318
-				$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1318
+				$cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
1319 1319
 				$oCacheHandler->delete($cache_key);
1320 1320
 			}
1321 1321
 		}
@@ -1336,10 +1336,10 @@  discard block
 block discarded – undo
1336 1336
 		$args->trackback_count = $trackback_count;
1337 1337
 
1338 1338
 		$oCacheHandler = CacheHandler::getInstance('object');
1339
-		if($oCacheHandler->isSupport())
1339
+		if ($oCacheHandler->isSupport())
1340 1340
 		{
1341 1341
 			//remove document item from cache
1342
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1342
+			$cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
1343 1343
 			$oCacheHandler->delete($cache_key);
1344 1344
 		}
1345 1345
 
@@ -1354,14 +1354,14 @@  discard block
 block discarded – undo
1354 1354
 	function insertCategory($obj)
1355 1355
 	{
1356 1356
 		// Sort the order to display if a child category is added
1357
-		if($obj->parent_srl)
1357
+		if ($obj->parent_srl)
1358 1358
 		{
1359 1359
 			// Get its parent category
1360 1360
 			$oDocumentModel = getModel('document');
1361 1361
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1362 1362
 			$obj->list_order = $parent_category->list_order;
1363
-			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1364
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1363
+			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1);
1364
+			if (!$obj->category_srl) $obj->category_srl = getNextSequence();
1365 1365
 		}
1366 1366
 		else
1367 1367
 		{
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
 		}
1370 1370
 
1371 1371
 		$output = executeQuery('document.insertCategory', $obj);
1372
-		if($output->toBool())
1372
+		if ($output->toBool())
1373 1373
 		{
1374 1374
 			$output->add('category_srl', $obj->category_srl);
1375 1375
 			$this->makeCategoryFile($obj->module_srl);
@@ -1403,13 +1403,13 @@  discard block
 block discarded – undo
1403 1403
 	{
1404 1404
 		// Create a document model object
1405 1405
 		$oDocumentModel = getModel('document');
1406
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1406
+		if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl);
1407 1407
 
1408 1408
 		$args = new stdClass;
1409 1409
 		$args->category_srl = $category_srl;
1410 1410
 		$args->document_count = $document_count;
1411 1411
 		$output = executeQuery('document.updateCategoryCount', $args);
1412
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1412
+		if ($output->toBool()) $this->makeCategoryFile($module_srl);
1413 1413
 
1414 1414
 		return $output;
1415 1415
 	}
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 	function updateCategory($obj)
1423 1423
 	{
1424 1424
 		$output = executeQuery('document.updateCategory', $obj);
1425
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1425
+		if ($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1426 1426
 		return $output;
1427 1427
 	}
1428 1428
 
@@ -1439,32 +1439,32 @@  discard block
 block discarded – undo
1439 1439
 		$category_info = $oDocumentModel->getCategory($category_srl);
1440 1440
 		// Display an error that the category cannot be deleted if it has a child
1441 1441
 		$output = executeQuery('document.getChildCategoryCount', $args);
1442
-		if(!$output->toBool()) return $output;
1443
-		if($output->data->count>0) return new Object(-1, 'msg_cannot_delete_for_child');
1442
+		if (!$output->toBool()) return $output;
1443
+		if ($output->data->count > 0) return new Object(-1, 'msg_cannot_delete_for_child');
1444 1444
 		// Delete a category information
1445 1445
 		$output = executeQuery('document.deleteCategory', $args);
1446
-		if(!$output->toBool()) return $output;
1446
+		if (!$output->toBool()) return $output;
1447 1447
 
1448 1448
 		$this->makeCategoryFile($category_info->module_srl);
1449 1449
 		// remvove cache
1450 1450
 		$oCacheHandler = CacheHandler::getInstance('object');
1451
-		if($oCacheHandler->isSupport())
1451
+		if ($oCacheHandler->isSupport())
1452 1452
 		{
1453 1453
 			$page = 0;
1454
-			while(true) {
1454
+			while (true) {
1455 1455
 				$args = new stdClass();
1456 1456
 				$args->category_srl = $category_srl;
1457 1457
 				$args->list_count = 100;
1458 1458
 				$args->page = ++$page;
1459 1459
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1460 1460
 
1461
-				if($output->data == array())
1461
+				if ($output->data == array())
1462 1462
 					break;
1463 1463
 
1464
-				foreach($output->data as $val)
1464
+				foreach ($output->data as $val)
1465 1465
 				{
1466 1466
 					//remove document item from cache
1467
-					$cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl;
1467
+					$cache_key = 'document_item:' . getNumberingPath($val->document_srl) . $val->document_srl;
1468 1468
 					$oCacheHandler->delete($cache_key);
1469 1469
 				}
1470 1470
 			}
@@ -1511,18 +1511,18 @@  discard block
 block discarded – undo
1511 1511
 		// Seek a full list of categories
1512 1512
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1513 1513
 		$category_srl_list = array_keys($category_list);
1514
-		if(count($category_srl_list)<2) return new Object();
1514
+		if (count($category_srl_list) < 2) return new Object();
1515 1515
 
1516 1516
 		$prev_category = NULL;
1517
-		foreach($category_list as $key => $val)
1517
+		foreach ($category_list as $key => $val)
1518 1518
 		{
1519
-			if($key==$category_srl) break;
1519
+			if ($key == $category_srl) break;
1520 1520
 			$prev_category = $val;
1521 1521
 		}
1522 1522
 		// Return if the previous category doesn't exist
1523
-		if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved'));
1523
+		if (!$prev_category) return new Object(-1, Context::getLang('msg_category_not_moved'));
1524 1524
 		// Return if the selected category is the top level
1525
-		if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved'));
1525
+		if ($category_srl_list[0] == $category_srl) return new Object(-1, Context::getLang('msg_category_not_moved'));
1526 1526
 		// Information of the selected category
1527 1527
 		$cur_args = new stdClass;
1528 1528
 		$cur_args->category_srl = $category_srl;
@@ -1558,15 +1558,15 @@  discard block
 block discarded – undo
1558 1558
 		// Seek a full list of categories
1559 1559
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1560 1560
 		$category_srl_list = array_keys($category_list);
1561
-		if(count($category_srl_list)<2) return new Object();
1561
+		if (count($category_srl_list) < 2) return new Object();
1562 1562
 
1563
-		for($i=0;$i<count($category_srl_list);$i++)
1563
+		for ($i = 0; $i < count($category_srl_list); $i++)
1564 1564
 		{
1565
-			if($category_srl_list[$i]==$category_srl) break;
1565
+			if ($category_srl_list[$i] == $category_srl) break;
1566 1566
 		}
1567 1567
 
1568
-		$next_category_srl = $category_srl_list[$i+1];
1569
-		if(!$category_list[$next_category_srl]) return new Object(-1,Context::getLang('msg_category_not_moved'));
1568
+		$next_category_srl = $category_srl_list[$i + 1];
1569
+		if (!$category_list[$next_category_srl]) return new Object(-1, Context::getLang('msg_category_not_moved'));
1570 1570
 		$next_category = $category_list[$next_category_srl];
1571 1571
 		// Information of the selected category
1572 1572
 		$cur_args = new stdClass;
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 	{
1594 1594
 		$oDocumentModel = getModel('document');
1595 1595
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1596
-		if(!count($extra_keys)) return;
1596
+		if (!count($extra_keys)) return;
1597 1597
 
1598 1598
 		$js_code = array();
1599 1599
 		$js_code[] = '<script>//<![CDATA[';
@@ -1603,16 +1603,16 @@  discard block
 block discarded – undo
1603 1603
 
1604 1604
 		$logged_info = Context::get('logged_info');
1605 1605
 
1606
-		foreach($extra_keys as $idx => $val)
1606
+		foreach ($extra_keys as $idx => $val)
1607 1607
 		{
1608 1608
 			$idx = $val->idx;
1609
-			if($val->type == 'kr_zip')
1609
+			if ($val->type == 'kr_zip')
1610 1610
 			{
1611 1611
 				$idx .= '[]';
1612 1612
 			}
1613 1613
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1614 1614
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1615
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1615
+			if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1616 1616
 		}
1617 1617
 
1618 1618
 		$js_code[] = '})(jQuery);';
@@ -1630,12 +1630,12 @@  discard block
 block discarded – undo
1630 1630
 	function procDocumentInsertCategory($args = null)
1631 1631
 	{
1632 1632
 		// List variables
1633
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1633
+		if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid');
1634 1634
 		$args->title = $args->category_title;
1635 1635
 		$args->description = $args->category_description;
1636 1636
 		$args->color = $args->category_color;
1637 1637
 
1638
-		if(!$args->module_srl && $args->mid)
1638
+		if (!$args->module_srl && $args->mid)
1639 1639
 		{
1640 1640
 			$mid = $args->mid;
1641 1641
 			unset($args->mid);
@@ -1646,28 +1646,28 @@  discard block
 block discarded – undo
1646 1646
 		$columnList = array('module_srl', 'module');
1647 1647
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1648 1648
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1649
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1649
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1650 1650
 
1651
-		if($args->expand !="Y") $args->expand = "N";
1652
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1651
+		if ($args->expand != "Y") $args->expand = "N";
1652
+		if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls);
1653 1653
 		else $args->group_srls = implode(',', $args->group_srls);
1654
-		$args->parent_srl = (int)$args->parent_srl;
1654
+		$args->parent_srl = (int) $args->parent_srl;
1655 1655
 
1656 1656
 		$oDocumentModel = getModel('document');
1657 1657
 
1658 1658
 		$oDB = &DB::getInstance();
1659 1659
 		$oDB->begin();
1660 1660
 		// Check if already exists
1661
-		if($args->category_srl)
1661
+		if ($args->category_srl)
1662 1662
 		{
1663 1663
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1664
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1664
+			if ($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1665 1665
 		}
1666 1666
 		// Update if exists
1667
-		if($args->category_srl)
1667
+		if ($args->category_srl)
1668 1668
 		{
1669 1669
 			$output = $this->updateCategory($args);
1670
-			if(!$output->toBool())
1670
+			if (!$output->toBool())
1671 1671
 			{
1672 1672
 				$oDB->rollback();
1673 1673
 				return $output;
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 		else
1678 1678
 		{
1679 1679
 			$output = $this->insertCategory($args);
1680
-			if(!$output->toBool())
1680
+			if (!$output->toBool())
1681 1681
 			{
1682 1682
 				$oDB->rollback();
1683 1683
 				return $output;
@@ -1716,11 +1716,11 @@  discard block
 block discarded – undo
1716 1716
 		$columnList = array('module_srl', 'module');
1717 1717
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1718 1718
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1719
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1719
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1720 1720
 
1721 1721
 		// First child of the parent_category_srl
1722 1722
 		$source_args = new stdClass;
1723
-		if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1723
+		if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1724 1724
 		{
1725 1725
 			$parent_category = $oDocumentModel->getCategory($parent_category_srl);
1726 1726
 
@@ -1729,30 +1729,30 @@  discard block
 block discarded – undo
1729 1729
 			$args->parent_srl = $parent_category_srl;
1730 1730
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1731 1731
 
1732
-			if(!$output->toBool()) return $output;
1733
-			$args->list_order = (int)$output->data->list_order;
1734
-			if(!$args->list_order) $args->list_order = 0;
1732
+			if (!$output->toBool()) return $output;
1733
+			$args->list_order = (int) $output->data->list_order;
1734
+			if (!$args->list_order) $args->list_order = 0;
1735 1735
 			$args->list_order--;
1736 1736
 
1737 1737
 			$source_args->category_srl = $source_category_srl;
1738 1738
 			$source_args->parent_srl = $parent_category_srl;
1739 1739
 			$source_args->list_order = $args->list_order;
1740 1740
 			$output = $this->updateCategory($source_args);
1741
-			if(!$output->toBool()) return $output;
1741
+			if (!$output->toBool()) return $output;
1742 1742
 			// Sibling of the $target_category_srl
1743 1743
 		}
1744
-		else if($target_category_srl > 0)
1744
+		else if ($target_category_srl > 0)
1745 1745
 		{
1746 1746
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1747 1747
 			// Move all siblings of the $target_category down
1748
-			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1749
-			if(!$output->toBool()) return $output;
1748
+			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1);
1749
+			if (!$output->toBool()) return $output;
1750 1750
 
1751 1751
 			$source_args->category_srl = $source_category_srl;
1752 1752
 			$source_args->parent_srl = $target_category->parent_srl;
1753
-			$source_args->list_order = $target_category->list_order+1;
1753
+			$source_args->list_order = $target_category->list_order + 1;
1754 1754
 			$output = $this->updateCategory($source_args);
1755
-			if(!$output->toBool()) return $output;
1755
+			if (!$output->toBool()) return $output;
1756 1756
 		}
1757 1757
 		// Re-generate the xml file
1758 1758
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
 	function procDocumentDeleteCategory()
1769 1769
 	{
1770 1770
 		// List variables
1771
-		$args = Context::gets('module_srl','category_srl');
1771
+		$args = Context::gets('module_srl', 'category_srl');
1772 1772
 
1773 1773
 		$oDB = &DB::getInstance();
1774 1774
 		$oDB->begin();
@@ -1777,17 +1777,17 @@  discard block
 block discarded – undo
1777 1777
 		$columnList = array('module_srl', 'module');
1778 1778
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1779 1779
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1780
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1780
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1781 1781
 
1782 1782
 		$oDocumentModel = getModel('document');
1783 1783
 		// Get original information
1784 1784
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1785
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1785
+		if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1786 1786
 		// Display an error that the category cannot be deleted if it has a child node
1787
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
1787
+		if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
1788 1788
 		// Remove from the DB
1789 1789
 		$output = $this->deleteCategory($args->category_srl);
1790
-		if(!$output->toBool())
1790
+		if (!$output->toBool())
1791 1791
 		{
1792 1792
 			$oDB->rollback();
1793 1793
 			return $output;
@@ -1818,11 +1818,11 @@  discard block
 block discarded – undo
1818 1818
 		$columnList = array('module_srl', 'module');
1819 1819
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1820 1820
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1821
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1821
+		if (!$grant->manager) return new Object(-1, 'msg_not_permitted');
1822 1822
 
1823 1823
 		$xml_file = $this->makeCategoryFile($module_srl);
1824 1824
 		// Set return value
1825
-		$this->add('xml_file',$xml_file);
1825
+		$this->add('xml_file', $xml_file);
1826 1826
 	}
1827 1827
 
1828 1828
 	/**
@@ -1833,14 +1833,14 @@  discard block
 block discarded – undo
1833 1833
 	function makeCategoryFile($module_srl)
1834 1834
 	{
1835 1835
 		// Return if there is no information you need for creating a cache file
1836
-		if(!$module_srl) return false;
1836
+		if (!$module_srl) return false;
1837 1837
 		// Get module information (to obtain mid)
1838 1838
 		$oModuleModel = getModel('module');
1839 1839
 		$columnList = array('module_srl', 'mid', 'site_srl');
1840 1840
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1841 1841
 		$mid = $module_info->mid;
1842 1842
 
1843
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1843
+		if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1844 1844
 		// Cache file's name
1845 1845
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1846 1846
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1852,17 +1852,17 @@  discard block
 block discarded – undo
1852 1852
 
1853 1853
 		$category_list = $output->data;
1854 1854
 
1855
-		if(!is_array($category_list)) $category_list = array($category_list);
1855
+		if (!is_array($category_list)) $category_list = array($category_list);
1856 1856
 
1857 1857
 		$category_count = count($category_list);
1858
-		for($i=0;$i<$category_count;$i++)
1858
+		for ($i = 0; $i < $category_count; $i++)
1859 1859
 		{
1860 1860
 			$category_srl = $category_list[$i]->category_srl;
1861
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1861
+			if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1862 1862
 			$list[$category_srl] = $category_list[$i];
1863 1863
 		}
1864 1864
 		// Create the xml file without node data if no data is obtained
1865
-		if(!$list)
1865
+		if (!$list)
1866 1866
 		{
1867 1867
 			$xml_buff = "<root />";
1868 1868
 			FileHandler::writeFile($xml_file, $xml_buff);
@@ -1870,47 +1870,47 @@  discard block
 block discarded – undo
1870 1870
 			return $xml_file;
1871 1871
 		}
1872 1872
 		// Change to an array if only a single data is obtained
1873
-		if(!is_array($list)) $list = array($list);
1873
+		if (!is_array($list)) $list = array($list);
1874 1874
 		// Create a tree for loop
1875
-		foreach($list as $category_srl => $node)
1875
+		foreach ($list as $category_srl => $node)
1876 1876
 		{
1877 1877
 			$node->mid = $mid;
1878
-			$parent_srl = (int)$node->parent_srl;
1878
+			$parent_srl = (int) $node->parent_srl;
1879 1879
 			$tree[$parent_srl][$category_srl] = $node;
1880 1880
 		}
1881 1881
 		// A common header to set permissions and groups of the cache file
1882 1882
 		$header_script =
1883
-			'$lang_type = Context::getLangType(); '.
1884
-			'$is_logged = Context::get(\'is_logged\'); '.
1885
-			'$logged_info = Context::get(\'logged_info\'); '.
1886
-			'if($is_logged) {'.
1887
-			'if($logged_info->is_admin=="Y") $is_admin = true; '.
1888
-			'else $is_admin = false; '.
1889
-			'$group_srls = array_keys($logged_info->group_list); '.
1890
-			'} else { '.
1891
-			'$is_admin = false; '.
1892
-			'$group_srsl = array(); '.
1893
-			'} '."\n";
1883
+			'$lang_type = Context::getLangType(); ' .
1884
+			'$is_logged = Context::get(\'is_logged\'); ' .
1885
+			'$logged_info = Context::get(\'logged_info\'); ' .
1886
+			'if($is_logged) {' .
1887
+			'if($logged_info->is_admin=="Y") $is_admin = true; ' .
1888
+			'else $is_admin = false; ' .
1889
+			'$group_srls = array_keys($logged_info->group_list); ' .
1890
+			'} else { ' .
1891
+			'$is_admin = false; ' .
1892
+			'$group_srsl = array(); ' .
1893
+			'} ' . "\n";
1894 1894
 
1895 1895
 		// Create the xml cache file (a separate session is needed for xml cache)
1896 1896
 		$xml_header_buff = '';
1897 1897
 		$xml_body_buff = $this->getXmlTree($tree[0], $tree, $module_info->site_srl, $xml_header_buff);
1898 1898
 		$xml_buff = sprintf(
1899
-			'<?php '.
1900
-			'define(\'__XE__\', true); '.
1901
-			'require_once(\''.FileHandler::getRealPath('./config/config.inc.php').'\'); '.
1902
-			'$oContext = &Context::getInstance(); '.
1903
-			'$oContext->init(); '.
1904
-			'header("Content-Type: text/xml; charset=UTF-8"); '.
1905
-			'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); '.
1906
-			'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); '.
1907
-			'header("Cache-Control: no-store, no-cache, must-revalidate"); '.
1908
-			'header("Cache-Control: post-check=0, pre-check=0", false); '.
1909
-			'header("Pragma: no-cache"); '.
1910
-			'%s'.
1911
-			'%s '.
1912
-			'$oContext->close();'.
1913
-			'?>'.
1899
+			'<?php ' .
1900
+			'define(\'__XE__\', true); ' .
1901
+			'require_once(\'' . FileHandler::getRealPath('./config/config.inc.php') . '\'); ' .
1902
+			'$oContext = &Context::getInstance(); ' .
1903
+			'$oContext->init(); ' .
1904
+			'header("Content-Type: text/xml; charset=UTF-8"); ' .
1905
+			'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); ' .
1906
+			'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); ' .
1907
+			'header("Cache-Control: no-store, no-cache, must-revalidate"); ' .
1908
+			'header("Cache-Control: post-check=0, pre-check=0", false); ' .
1909
+			'header("Pragma: no-cache"); ' .
1910
+			'%s' .
1911
+			'%s ' .
1912
+			'$oContext->close();' .
1913
+			'?>' .
1914 1914
 			'<root>%s</root>',
1915 1915
 			$header_script,
1916 1916
 			$xml_header_buff,
@@ -1921,11 +1921,11 @@  discard block
 block discarded – undo
1921 1921
 		$php_header_buff .= '$_descriptions = array();';
1922 1922
 		$php_output = $this->getPhpCacheCode($tree[0], $tree, $module_info->site_srl, $php_header_buff);
1923 1923
 		$php_buff = sprintf(
1924
-			'<?php '.
1925
-			'if(!defined("__XE__")) exit(); '.
1926
-			'%s'.
1927
-			'%s'.
1928
-			'$menu = new stdClass;'.
1924
+			'<?php ' .
1925
+			'if(!defined("__XE__")) exit(); ' .
1926
+			'%s' .
1927
+			'%s' .
1928
+			'$menu = new stdClass;' .
1929 1929
 			'$menu->list = array(%s); ',
1930 1930
 			$header_script,
1931 1931
 			$php_header_buff,
@@ -1949,13 +1949,13 @@  discard block
 block discarded – undo
1949 1949
 	 */
1950 1950
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1951 1951
 	{
1952
-		if(!$source_node) return;
1952
+		if (!$source_node) return;
1953 1953
 
1954
-		foreach($source_node as $category_srl => $node)
1954
+		foreach ($source_node as $category_srl => $node)
1955 1955
 		{
1956 1956
 			$child_buff = "";
1957 1957
 			// Get data of the child nodes
1958
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1958
+			if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1959 1959
 			// List variables
1960 1960
 			$expand = $node->expand;
1961 1961
 			$group_srls = $node->group_srls;
@@ -1965,27 +1965,27 @@  discard block
 block discarded – undo
1965 1965
 			$color = $node->color;
1966 1966
 			$description = $node->description;
1967 1967
 			// If node->group_srls value exists
1968
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1968
+			if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls);
1969 1969
 			else $group_check_code = "true";
1970 1970
 
1971 1971
 			$title = $node->title;
1972 1972
 			$oModuleAdminModel = getAdminModel('module');
1973 1973
 
1974 1974
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
1975
-			if(count($langs))
1975
+			if (count($langs))
1976 1976
 			{
1977
-				foreach($langs as $key => $val)
1977
+				foreach ($langs as $key => $val)
1978 1978
 				{
1979
-					$xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1979
+					$xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1980 1980
 				}
1981 1981
 			}
1982 1982
 
1983 1983
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
1984
-			if(count($langx))
1984
+			if (count($langx))
1985 1985
 			{
1986
-				foreach($langx as $key => $val)
1986
+				foreach ($langx as $key => $val)
1987 1987
 				{
1988
-					$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1988
+					$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)));
1989 1989
 				}
1990 1990
 			}
1991 1991
 
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 				$category_srl,
1999 1999
 				$group_check_code,
2000 2000
 				$category_srl,
2001
-				getUrl('','mid',$node->mid,'category',$category_srl),
2001
+				getUrl('', 'mid', $node->mid, 'category', $category_srl),
2002 2002
 				$expand,
2003 2003
 				htmlspecialchars($color, ENT_COMPAT | ENT_HTML401, 'UTF-8', false),
2004 2004
 				$group_check_code,
@@ -2006,8 +2006,8 @@  discard block
 block discarded – undo
2006 2006
 				$node->document_count
2007 2007
 			);
2008 2008
 
2009
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2010
-			else $buff .=  sprintf('<node %s />', $attribute);
2009
+			if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2010
+			else $buff .= sprintf('<node %s />', $attribute);
2011 2011
 		}
2012 2012
 		return $buff;
2013 2013
 	}
@@ -2026,13 +2026,13 @@  discard block
 block discarded – undo
2026 2026
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2027 2027
 	{
2028 2028
 		$output = array("buff"=>"", "category_srl_list"=>array());
2029
-		if(!$source_node) return $output;
2029
+		if (!$source_node) return $output;
2030 2030
 
2031 2031
 		// Set to an arraty for looping and then generate php script codes to be included
2032
-		foreach($source_node as $category_srl => $node)
2032
+		foreach ($source_node as $category_srl => $node)
2033 2033
 		{
2034 2034
 			// Get data from child nodes first if exist.
2035
-			if($category_srl && $tree[$category_srl]){
2035
+			if ($category_srl && $tree[$category_srl]) {
2036 2036
 				$child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff);
2037 2037
 			} else {
2038 2038
 				$child_output = array("buff"=>"", "category_srl_list"=>array());
@@ -2043,8 +2043,8 @@  discard block
 block discarded – undo
2043 2043
 			$output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']);
2044 2044
 
2045 2045
 			// If node->group_srls value exists
2046
-			if($node->group_srls) {
2047
-				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls);
2046
+			if ($node->group_srls) {
2047
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls);
2048 2048
 			} else {
2049 2049
 				$group_check_code = "true";
2050 2050
 			}
@@ -2059,32 +2059,32 @@  discard block
 block discarded – undo
2059 2059
 			$oModuleAdminModel = getAdminModel('module');
2060 2060
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
2061 2061
 
2062
-			if(count($langs))
2062
+			if (count($langs))
2063 2063
 			{
2064
-				foreach($langs as $key => $val)
2064
+				foreach ($langs as $key => $val)
2065 2065
 				{
2066 2066
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2067 2067
 					$php_header_buff .= sprintf(
2068 2068
 						'$_titles[%d]["%s"] = "%s"; ',
2069 2069
 						$category_srl,
2070 2070
 						$key,
2071
-						str_replace('"','\\"', $val)
2071
+						str_replace('"', '\\"', $val)
2072 2072
 					);
2073 2073
 				}
2074 2074
 			}
2075 2075
 
2076 2076
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2077 2077
 
2078
-			if(count($langx))
2078
+			if (count($langx))
2079 2079
 			{
2080
-				foreach($langx as $key => $val)
2080
+				foreach ($langx as $key => $val)
2081 2081
 				{
2082 2082
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2083 2083
 					$php_header_buff .= sprintf(
2084 2084
 						'$_descriptions[%d]["%s"] = "%s"; ',
2085 2085
 						$category_srl,
2086 2086
 						$key,
2087
-						str_replace('"','\\"', $val)
2087
+						str_replace('"', '\\"', $val)
2088 2088
 					);
2089 2089
 				}
2090 2090
 			}
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 			);
2109 2109
 
2110 2110
 			// Generate buff data
2111
-			$output['buff'] .=  sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2111
+			$output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2112 2112
 		}
2113 2113
 
2114 2114
 		return $output;
@@ -2125,7 +2125,7 @@  discard block
 block discarded – undo
2125 2125
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2126 2126
 	{
2127 2127
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2128
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2128
+		if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2129 2129
 
2130 2130
 		$obj = new stdClass();
2131 2131
 		$obj->url = $url;
@@ -2143,68 +2143,68 @@  discard block
 block discarded – undo
2143 2143
 	 */
2144 2144
 	function procDocumentAddCart()
2145 2145
 	{
2146
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2146
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2147 2147
 
2148 2148
 		// Get document_srl
2149
-		$srls = explode(',',Context::get('srls'));
2150
-		for($i = 0; $i < count($srls); $i++)
2149
+		$srls = explode(',', Context::get('srls'));
2150
+		for ($i = 0; $i < count($srls); $i++)
2151 2151
 		{
2152 2152
 			$srl = trim($srls[$i]);
2153 2153
 
2154
-			if(!$srl) continue;
2154
+			if (!$srl) continue;
2155 2155
 
2156 2156
 			$document_srls[] = $srl;
2157 2157
 		}
2158
-		if(!count($document_srls)) return;
2158
+		if (!count($document_srls)) return;
2159 2159
 
2160 2160
 		// Get module_srl of the documents
2161 2161
 		$args = new stdClass;
2162 2162
 		$args->list_count = count($document_srls);
2163
-		$args->document_srls = implode(',',$document_srls);
2163
+		$args->document_srls = implode(',', $document_srls);
2164 2164
 		$args->order_type = 'asc';
2165 2165
 		$output = executeQueryArray('document.getDocuments', $args);
2166
-		if(!$output->data) return new Object();
2166
+		if (!$output->data) return new Object();
2167 2167
 
2168 2168
 		unset($document_srls);
2169
-		foreach($output->data as $key => $val)
2169
+		foreach ($output->data as $key => $val)
2170 2170
 		{
2171 2171
 			$document_srls[$val->module_srl][] = $val->document_srl;
2172 2172
 		}
2173
-		if(!$document_srls || !count($document_srls)) return new Object();
2173
+		if (!$document_srls || !count($document_srls)) return new Object();
2174 2174
 
2175 2175
 		// 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)
2176 2176
 		$oModuleModel = getModel('module');
2177 2177
 		$module_srls = array_keys($document_srls);
2178
-		for($i=0;$i<count($module_srls);$i++)
2178
+		for ($i = 0; $i < count($module_srls); $i++)
2179 2179
 		{
2180 2180
 			$module_srl = $module_srls[$i];
2181 2181
 			$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
2182 2182
 			$logged_info = Context::get('logged_info');
2183
-			if($logged_info->is_admin != 'Y')
2183
+			if ($logged_info->is_admin != 'Y')
2184 2184
 			{
2185
-				if(!$module_info)
2185
+				if (!$module_info)
2186 2186
 				{
2187 2187
 					unset($document_srls[$module_srl]);
2188 2188
 					continue;
2189 2189
 				}
2190 2190
 				$grant = $oModuleModel->getGrant($module_info, $logged_info);
2191
-				if(!$grant->manager)
2191
+				if (!$grant->manager)
2192 2192
 				{
2193 2193
 					unset($document_srls[$module_srl]);
2194 2194
 					continue;
2195 2195
 				}
2196 2196
 			}
2197 2197
 		}
2198
-		if(!count($document_srls)) return new Object();
2198
+		if (!count($document_srls)) return new Object();
2199 2199
 
2200
-		foreach($document_srls as $module_srl => $documents)
2200
+		foreach ($document_srls as $module_srl => $documents)
2201 2201
 		{
2202 2202
 			$cnt = count($documents);
2203
-			for($i=0;$i<$cnt;$i++)
2203
+			for ($i = 0; $i < $cnt; $i++)
2204 2204
 			{
2205
-				$document_srl = (int)trim($documents[$i]);
2206
-				if(!$document_srls) continue;
2207
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2205
+				$document_srl = (int) trim($documents[$i]);
2206
+				if (!$document_srls) continue;
2207
+				if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2208 2208
 				else $_SESSION['document_management'][$document_srl] = true;
2209 2209
 			}
2210 2210
 		}
@@ -2217,9 +2217,9 @@  discard block
 block discarded – undo
2217 2217
 	function procDocumentManageCheckedDocument()
2218 2218
 	{
2219 2219
 		@set_time_limit(0);
2220
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2220
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2221 2221
 
2222
-		if(!checkCSRF())
2222
+		if (!checkCSRF())
2223 2223
 		{
2224 2224
 			return new Object(-1, 'msg_invalid_request');
2225 2225
 		}
@@ -2227,44 +2227,44 @@  discard block
 block discarded – undo
2227 2227
 		$type = Context::get('type');
2228 2228
 		$target_module = Context::get('target_module');
2229 2229
 		$module_srl = Context::get('module_srl');
2230
-		if($target_module && !$module_srl) $module_srl = $target_module;
2230
+		if ($target_module && !$module_srl) $module_srl = $target_module;
2231 2231
 		$category_srl = Context::get('target_category');
2232 2232
 		$message_content = Context::get('message_content');
2233
-		if($message_content) $message_content = nl2br($message_content);
2233
+		if ($message_content) $message_content = nl2br($message_content);
2234 2234
 
2235 2235
 		$cart = Context::get('cart');
2236
-		if(!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2236
+		if (!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2237 2237
 		else $document_srl_list = $cart;
2238 2238
 
2239 2239
 		$document_srl_count = count($document_srl_list);
2240 2240
 
2241 2241
 		$oDocumentModel = getModel('document');
2242 2242
 		$document_items = array();
2243
-		foreach($document_srl_list as $document_srl)
2243
+		foreach ($document_srl_list as $document_srl)
2244 2244
 		{
2245 2245
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2246 2246
 			$document_items[] = $oDocument;
2247
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2247
+			if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2248 2248
 		}
2249 2249
 
2250 2250
 		// Send a message
2251
-		if($message_content)
2251
+		if ($message_content)
2252 2252
 		{
2253 2253
 
2254 2254
 			$oCommunicationController = getController('communication');
2255 2255
 
2256 2256
 			$logged_info = Context::get('logged_info');
2257 2257
 
2258
-			$title = cut_str($message_content,10,'...');
2258
+			$title = cut_str($message_content, 10, '...');
2259 2259
 			$sender_member_srl = $logged_info->member_srl;
2260 2260
 
2261
-			foreach($document_items as $oDocument)
2261
+			foreach ($document_items as $oDocument)
2262 2262
 			{
2263
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2263
+				if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue;
2264 2264
 
2265
-				if($type=='move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2265
+				if ($type == 'move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2266 2266
 				else $purl = "";
2267
-				$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));
2267
+				$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));
2268 2268
 
2269 2269
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
2270 2270
 			}
@@ -2274,54 +2274,54 @@  discard block
 block discarded – undo
2274 2274
 		$oSpamController->setAvoidLog();
2275 2275
 
2276 2276
 		$oDocumentAdminController = getAdminController('document');
2277
-		if($type == 'move')
2277
+		if ($type == 'move')
2278 2278
 		{
2279
-			if(!$module_srl) return new Object(-1, 'fail_to_move');
2279
+			if (!$module_srl) return new Object(-1, 'fail_to_move');
2280 2280
 
2281 2281
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2282
-			if(!$output->toBool()) return new Object(-1, 'fail_to_move');
2282
+			if (!$output->toBool()) return new Object(-1, 'fail_to_move');
2283 2283
 
2284 2284
 			$msg_code = 'success_moved';
2285 2285
 
2286 2286
 		}
2287
-		else if($type == 'copy')
2287
+		else if ($type == 'copy')
2288 2288
 		{
2289
-			if(!$module_srl) return new Object(-1, 'fail_to_move');
2289
+			if (!$module_srl) return new Object(-1, 'fail_to_move');
2290 2290
 
2291 2291
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2292
-			if(!$output->toBool()) return new Object(-1, 'fail_to_move');
2292
+			if (!$output->toBool()) return new Object(-1, 'fail_to_move');
2293 2293
 
2294 2294
 			$msg_code = 'success_copied';
2295 2295
 		}
2296
-		else if($type =='delete')
2296
+		else if ($type == 'delete')
2297 2297
 		{
2298 2298
 			$oDB = &DB::getInstance();
2299 2299
 			$oDB->begin();
2300
-			for($i=0;$i<$document_srl_count;$i++)
2300
+			for ($i = 0; $i < $document_srl_count; $i++)
2301 2301
 			{
2302 2302
 				$document_srl = $document_srl_list[$i];
2303 2303
 				$output = $this->deleteDocument($document_srl, true);
2304
-				if(!$output->toBool()) return new Object(-1, 'fail_to_delete');
2304
+				if (!$output->toBool()) return new Object(-1, 'fail_to_delete');
2305 2305
 			}
2306 2306
 			$oDB->commit();
2307 2307
 			$msg_code = 'success_deleted';
2308 2308
 		}
2309
-		else if($type == 'trash')
2309
+		else if ($type == 'trash')
2310 2310
 		{
2311 2311
 			$args = new stdClass();
2312 2312
 			$args->description = $message_content;
2313 2313
 
2314 2314
 			$oDB = &DB::getInstance();
2315 2315
 			$oDB->begin();
2316
-			for($i=0;$i<$document_srl_count;$i++) {
2316
+			for ($i = 0; $i < $document_srl_count; $i++) {
2317 2317
 				$args->document_srl = $document_srl_list[$i];
2318 2318
 				$output = $this->moveDocumentToTrash($args);
2319
-				if(!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash');
2319
+				if (!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash');
2320 2320
 			}
2321 2321
 			$oDB->commit();
2322 2322
 			$msg_code = 'success_trashed';
2323 2323
 		}
2324
-		else if($type == 'cancelDeclare')
2324
+		else if ($type == 'cancelDeclare')
2325 2325
 		{
2326 2326
 			$args->document_srl = $document_srl_list;
2327 2327
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2343,27 +2343,27 @@  discard block
 block discarded – undo
2343 2343
 	function procDocumentInsertModuleConfig()
2344 2344
 	{
2345 2345
 		$module_srl = Context::get('target_module_srl');
2346
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2346
+		if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl);
2347 2347
 		else $module_srl = array($module_srl);
2348 2348
 
2349 2349
 		$document_config = new stdClass();
2350 2350
 		$document_config->use_history = Context::get('use_history');
2351
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2351
+		if (!$document_config->use_history) $document_config->use_history = 'N';
2352 2352
 
2353 2353
 		$document_config->use_vote_up = Context::get('use_vote_up');
2354
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2354
+		if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2355 2355
 
2356 2356
 		$document_config->use_vote_down = Context::get('use_vote_down');
2357
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2357
+		if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2358 2358
 
2359 2359
 		$document_config->use_status = Context::get('use_status');
2360 2360
 
2361 2361
 		$oModuleController = getController('module');
2362
-		for($i=0;$i<count($module_srl);$i++)
2362
+		for ($i = 0; $i < count($module_srl); $i++)
2363 2363
 		{
2364 2364
 			$srl = trim($module_srl[$i]);
2365
-			if(!$srl) continue;
2366
-			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2365
+			if (!$srl) continue;
2366
+			$output = $oModuleController->insertModulePartConfig('document', $srl, $document_config);
2367 2367
 		}
2368 2368
 		$this->setError(-1);
2369 2369
 		$this->setMessage('success_updated', 'info');
@@ -2379,7 +2379,7 @@  discard block
 block discarded – undo
2379 2379
 	function procDocumentTempSave()
2380 2380
 	{
2381 2381
 		// Check login information
2382
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
2382
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
2383 2383
 		$module_info = Context::get('module_info');
2384 2384
 		$logged_info = Context::get('logged_info');
2385 2385
 
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 		unset($obj->is_notice);
2392 2392
 
2393 2393
 		// Extract from beginning part of contents in the guestbook
2394
-		if(!$obj->title)
2394
+		if (!$obj->title)
2395 2395
 		{
2396 2396
 			$obj->title = cut_str(strip_tags($obj->content), 20, '...');
2397 2397
 		}
@@ -2402,13 +2402,13 @@  discard block
 block discarded – undo
2402 2402
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2403 2403
 
2404 2404
 		// Update if already exists
2405
-		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2405
+		if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2406 2406
 		{
2407
-			if($oDocument->get('module_srl') != $obj->module_srl)
2407
+			if ($oDocument->get('module_srl') != $obj->module_srl)
2408 2408
 			{
2409 2409
 				return new Object(-1, 'msg_invalid_request');
2410 2410
 			}
2411
-			if(!$oDocument->isGranted())
2411
+			if (!$oDocument->isGranted())
2412 2412
 			{
2413 2413
 				return new Object(-1, 'msg_invalid_request');
2414 2414
 			}
@@ -2426,7 +2426,7 @@  discard block
 block discarded – undo
2426 2426
 			$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2427 2427
 		}
2428 2428
 		// Set the attachment to be invalid state
2429
-		if($oDocument->hasUploadedFiles())
2429
+		if ($oDocument->hasUploadedFiles())
2430 2430
 		{
2431 2431
 			$args = new stdClass;
2432 2432
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -2444,11 +2444,11 @@  discard block
 block discarded – undo
2444 2444
 	 */
2445 2445
 	function procDocumentGetList()
2446 2446
 	{
2447
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2447
+		if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2448 2448
 		$documentSrls = Context::get('document_srls');
2449
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2449
+		if ($documentSrls) $documentSrlList = explode(',', $documentSrls);
2450 2450
 
2451
-		if(count($documentSrlList) > 0)
2451
+		if (count($documentSrlList) > 0)
2452 2452
 		{
2453 2453
 			$oDocumentModel = getModel('document');
2454 2454
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
@@ -2472,10 +2472,10 @@  discard block
 block discarded – undo
2472 2472
 	 */
2473 2473
 	function _checkCommentStatusForOldVersion(&$obj)
2474 2474
 	{
2475
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2476
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2475
+		if (!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2476
+		if (!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2477 2477
 
2478
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2478
+		if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2479 2479
 		else $obj->commentStatus = 'DENY';
2480 2480
 	}
2481 2481
 
@@ -2486,8 +2486,8 @@  discard block
 block discarded – undo
2486 2486
 	 */
2487 2487
 	function _checkDocumentStatusForOldVersion(&$obj)
2488 2488
 	{
2489
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2490
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2489
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2490
+		if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2491 2491
 	}
2492 2492
 
2493 2493
 	public function updateUploaedCount($documentSrlList)
@@ -2495,10 +2495,10 @@  discard block
 block discarded – undo
2495 2495
 		$oDocumentModel = getModel('document');
2496 2496
 		$oFileModel = getModel('file');
2497 2497
 
2498
-		if(is_array($documentSrlList))
2498
+		if (is_array($documentSrlList))
2499 2499
 		{
2500 2500
 			$documentSrlList = array_unique($documentSrlList);
2501
-			foreach($documentSrlList AS $key => $documentSrl)
2501
+			foreach ($documentSrlList AS $key => $documentSrl)
2502 2502
 			{
2503 2503
 				$fileCount = $oFileModel->getFilesCount($documentSrl);
2504 2504
 				$args = new stdClass();
@@ -2519,14 +2519,14 @@  discard block
 block discarded – undo
2519 2519
 		$oDocumentModel = getModel('document');
2520 2520
 		$documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl);
2521 2521
 
2522
-		if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2522
+		if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2523 2523
 		{
2524
-			$oDocumentController=getController('document');
2525
-			foreach($obj->moduleSrlList AS $key=>$value)
2524
+			$oDocumentController = getController('document');
2525
+			foreach ($obj->moduleSrlList AS $key=>$value)
2526 2526
 			{
2527
-				foreach($documentExtraKeys AS $extraItem)
2527
+				foreach ($documentExtraKeys AS $extraItem)
2528 2528
 				{
2529
-					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ;
2529
+					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid);
2530 2530
 				}
2531 2531
 			}
2532 2532
 		}
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
 		$documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl);
2539 2539
 
2540 2540
 		$oModuleController = getController('module');
2541
-		if(is_array($obj->moduleSrlList))
2541
+		if (is_array($obj->moduleSrlList))
2542 2542
 		{
2543
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
2543
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
2544 2544
 			{
2545 2545
 				$oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig);
2546 2546
 			}
Please login to merge, or discard this patch.
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 Object(-1, 'msg_invalid_request');
27
+		if(!Context::get('is_logged')) {
28
+			return new Object(-1, 'msg_invalid_request');
29
+		}
28 30
 
29 31
 		$document_srl = Context::get('target_srl');
30
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
32
+		if(!$document_srl) {
33
+			return new Object(-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 Object(-1, 'msg_invalid_request');
39
+		if(!$module_srl) {
40
+			return new Object(-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 Object(-1, 'msg_invalid_request');
45
+		if($document_config->use_vote_up=='N') {
46
+			return new Object(-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 Object(-1, 'msg_invalid_request');
80
+		if(!Context::get('is_logged')) {
81
+			return new Object(-1, 'msg_invalid_request');
82
+		}
73 83
 
74 84
 		$document_srl = Context::get('target_srl');
75
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
85
+		if(!$document_srl) {
86
+			return new Object(-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 Object(-1, 'msg_invalid_request');
92
+		if(!$module_srl) {
93
+			return new Object(-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 Object(-1, 'msg_invalid_request');
98
+		if($document_config->use_vote_down=='N') {
99
+			return new Object(-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 Object(-1, 'msg_invalid_request');
114
+		if(!Context::get('is_logged')) {
115
+			return new Object(-1, 'msg_invalid_request');
116
+		}
99 117
 
100 118
 		$document_srl = Context::get('target_srl');
101
-		if(!$document_srl) return new Object(-1, 'msg_invalid_request');
119
+		if(!$document_srl) {
120
+			return new Object(-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 Object();
177
+		if(!$module_srl) {
178
+			return new Object();
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 Object(-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 Object(-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 Object(-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);
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())
@@ -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 Object(-1,'msg_invalid_request');
357
+		if(!$logged_info->member_srl && !$obj->nick_name) {
358
+			return new Object(-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
 		{
@@ -365,27 +437,39 @@  discard block
 block discarded – undo
365 437
 			return new Object(-1, 'msg_invalid_request');
366 438
 		}
367 439
 
368
-		if(!$source_obj->document_srl || !$obj->document_srl) return new Object(-1,'msg_invalied_request');
369
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
370
-		if(!$obj->status) $obj->status = 'PUBLIC';
440
+		if(!$source_obj->document_srl || !$obj->document_srl) {
441
+			return new Object(-1,'msg_invalied_request');
442
+		}
443
+		if(!$obj->status && $obj->is_secret == 'Y') {
444
+			$obj->status = 'SECRET';
445
+		}
446
+		if(!$obj->status) {
447
+			$obj->status = 'PUBLIC';
448
+		}
371 449
 
372 450
 		// Call a trigger (before)
373 451
 		$output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
374
-		if(!$output->toBool()) return $output;
452
+		if(!$output->toBool()) {
453
+			return $output;
454
+		}
375 455
 
376 456
 		// begin transaction
377 457
 		$oDB = &DB::getInstance();
378 458
 		$oDB->begin();
379 459
 
380 460
 		$oModuleModel = getModel('module');
381
-		if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
461
+		if(!$obj->module_srl) {
462
+			$obj->module_srl = $source_obj->get('module_srl');
463
+		}
382 464
 		$module_srl = $obj->module_srl;
383 465
 		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
384 466
 		if(!$document_config)
385 467
 		{
386 468
 			$document_config = new stdClass();
387 469
 		}
388
-		if(!isset($document_config->use_history)) $document_config->use_history = 'N';
470
+		if(!isset($document_config->use_history)) {
471
+			$document_config->use_history = 'N';
472
+		}
389 473
 		$bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace';
390 474
 
391 475
 		if($bUseHistory)
@@ -394,22 +478,31 @@  discard block
 block discarded – undo
394 478
 			$args->history_srl = getNextSequence();
395 479
 			$args->document_srl = $obj->document_srl;
396 480
 			$args->module_srl = $module_srl;
397
-			if($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
481
+			if($document_config->use_history == 'Y') {
482
+				$args->content = $source_obj->get('content');
483
+			}
398 484
 			$args->nick_name = $source_obj->get('nick_name');
399 485
 			$args->member_srl = $source_obj->get('member_srl');
400 486
 			$args->regdate = $source_obj->get('last_update');
401 487
 			$args->ipaddress = $source_obj->get('ipaddress');
402 488
 			$output = executeQuery("document.insertHistory", $args);
403
-		}
404
-		else
489
+		} else
405 490
 		{
406 491
 			$obj->ipaddress = $source_obj->get('ipaddress');
407 492
 		}
408 493
 		// List variables
409
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
410
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
411
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
412
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
494
+		if($obj->comment_status) {
495
+			$obj->commentStatus = $obj->comment_status;
496
+		}
497
+		if(!$obj->commentStatus) {
498
+			$obj->commentStatus = 'DENY';
499
+		}
500
+		if($obj->commentStatus == 'DENY') {
501
+			$this->_checkCommentStatusForOldVersion($obj);
502
+		}
503
+		if($obj->allow_trackback!='Y') {
504
+			$obj->allow_trackback = 'N';
505
+		}
413 506
 		if($obj->homepage)
414 507
 		{
415 508
 			$obj->homepage = removeHackTag($obj->homepage);
@@ -419,7 +512,9 @@  discard block
 block discarded – undo
419 512
 			}
420 513
 		}
421 514
 		
422
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
515
+		if($obj->notify_message != 'Y') {
516
+			$obj->notify_message = 'N';
517
+		}
423 518
 		
424 519
 		// can modify regdate only manager
425 520
                 $grant = Context::get('grant');
@@ -429,7 +524,9 @@  discard block
 block discarded – undo
429 524
 		}
430 525
 		
431 526
 		// Serialize the $extra_vars
432
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
527
+		if(!is_string($obj->extra_vars)) {
528
+			$obj->extra_vars = serialize($obj->extra_vars);
529
+		}
433 530
 		// Remove the columns for automatic saving
434 531
 		unset($obj->_saved_doc_srl);
435 532
 		unset($obj->_saved_doc_title);
@@ -441,7 +538,9 @@  discard block
 block discarded – undo
441 538
 		if($source_obj->get('category_srl')!=$obj->category_srl)
442 539
 		{
443 540
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
444
-			if(!$category_list[$obj->category_srl]) $obj->category_srl = 0;
541
+			if(!$category_list[$obj->category_srl]) {
542
+				$obj->category_srl = 0;
543
+			}
445 544
 		}
446 545
 		// Change the update order
447 546
 		$obj->update_order = getNextSequence() * -1;
@@ -474,9 +573,13 @@  discard block
 block discarded – undo
474 573
 		}
475 574
 		// If the tile is empty, extract string from the contents.
476 575
 		settype($obj->title, "string");
477
-		if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
576
+		if($obj->title == '') {
577
+			$obj->title = cut_str(strip_tags($obj->content),20,'...');
578
+		}
478 579
 		// If no tile extracted from the contents, leave it untitled.
479
-		if($obj->title == '') $obj->title = 'Untitled';
580
+		if($obj->title == '') {
581
+			$obj->title = 'Untitled';
582
+		}
480 583
 		// Remove XE's own tags from the contents.
481 584
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
482 585
 		if(Mobile::isFromMobilePhone())
@@ -496,8 +599,7 @@  discard block
 block discarded – undo
496 599
 				$lang_code_args->document_srl = $source_obj->get('document_srl');
497 600
 				$lang_code_args->lang_code = Context::getLangType();
498 601
 				$output = executeQuery('document.updateDocumentsLangCode', $lang_code_args);
499
-			}
500
-			else
602
+			} else
501 603
 			{
502 604
 				$extra_content = new stdClass;
503 605
 				$extra_content->title = $obj->title;
@@ -516,7 +618,9 @@  discard block
 block discarded – undo
516 618
 			$obj->content = removeHackTag($obj->content);
517 619
 		}
518 620
 		// if temporary document, regdate is now setting
519
-		if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
621
+		if($source_obj->get('status') == $this->getConfigStatus('temp')) {
622
+			$obj->regdate = date('YmdHis');
623
+		}
520 624
 
521 625
 		// Insert data into the DB
522 626
 		$output = executeQuery('document.updateDocument', $obj);
@@ -539,25 +643,37 @@  discard block
 block discarded – undo
539 643
 					if(isset($obj->{'extra_vars'.$idx}))
540 644
 					{
541 645
 						$tmp = $obj->{'extra_vars'.$idx};
542
-						if(is_array($tmp))
543
-							$value = implode('|@|', $tmp);
544
-						else
545
-							$value = trim($tmp);
646
+						if(is_array($tmp)) {
647
+													$value = implode('|@|', $tmp);
648
+						} else {
649
+													$value = trim($tmp);
650
+						}
651
+					} else if(isset($obj->{$extra_item->name})) {
652
+						$value = trim($obj->{$extra_item->name});
653
+					}
654
+					if($value == NULL) {
655
+						continue;
546 656
 					}
547
-					else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
548
-					if($value == NULL) continue;
549 657
 					$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
550 658
 				}
551 659
 			}
552 660
 			// Inert extra vars for multi-language support of title and contents.
553
-			if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
554
-			if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
661
+			if($extra_content->title) {
662
+				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
663
+			}
664
+			if($extra_content->content) {
665
+				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
666
+			}
555 667
 		}
556 668
 		// Update the category if the category_srl exists.
557 669
 		if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
558 670
 		{
559
-			if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
560
-			if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
671
+			if($source_obj->get('category_srl') != $obj->category_srl) {
672
+				$this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
673
+			}
674
+			if($obj->category_srl) {
675
+				$this->updateCategoryCount($obj->module_srl, $obj->category_srl);
676
+			}
561 677
 		}
562 678
 		// Call a trigger (after)
563 679
 		if($output->toBool())
@@ -602,7 +718,9 @@  discard block
 block discarded – undo
602 718
 		$trigger_obj = new stdClass();
603 719
 		$trigger_obj->document_srl = $document_srl;
604 720
 		$output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
605
-		if(!$output->toBool()) return $output;
721
+		if(!$output->toBool()) {
722
+			return $output;
723
+		}
606 724
 
607 725
 		// begin transaction
608 726
 		$oDB = &DB::getInstance();
@@ -614,12 +732,17 @@  discard block
 block discarded – undo
614 732
 			$oDocumentModel = getModel('document');
615 733
 			// Check if the documnet exists
616 734
 			$oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
735
+		} else if($isEmptyTrash && $oDocument == null) {
736
+			return new Object(-1, 'document is not exists');
617 737
 		}
618
-		else if($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists');
619 738
 
620
-		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
739
+		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) {
740
+			return new Object(-1, 'msg_invalid_document');
741
+		}
621 742
 		// Check if a permossion is granted
622
-		if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
743
+		if(!$oDocument->isGranted()) {
744
+			return new Object(-1, 'msg_not_permitted');
745
+		}
623 746
 
624 747
 		//if empty trash, document already deleted, therefore document not delete
625 748
 		$args = new stdClass();
@@ -639,7 +762,9 @@  discard block
 block discarded – undo
639 762
 
640 763
 		$this->deleteDocumentHistory(null, $document_srl, null);
641 764
 		// Update category information if the category_srl exists.
642
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
765
+		if($oDocument->get('category_srl')) {
766
+			$this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
767
+		}
643 768
 		// Delete a declared list
644 769
 		executeQuery('document.deleteDeclared', $args);
645 770
 		// Delete extra variable
@@ -719,8 +844,11 @@  discard block
 block discarded – undo
719 844
 	{
720 845
 		$trash_args = new stdClass();
721 846
 		// Get trash_srl if a given trash_srl doesn't exist
722
-		if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
723
-		else $trash_args->trash_srl = $obj->trash_srl;
847
+		if(!$obj->trash_srl) {
848
+			$trash_args->trash_srl = getNextSequence();
849
+		} else {
850
+			$trash_args->trash_srl = $obj->trash_srl;
851
+		}
724 852
 		// Get its module_srl which the document belongs to
725 853
 		$oDocumentModel = getModel('document');
726 854
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl);
@@ -728,7 +856,9 @@  discard block
 block discarded – undo
728 856
 		$trash_args->module_srl = $oDocument->get('module_srl');
729 857
 		$obj->module_srl = $oDocument->get('module_srl');
730 858
 		// Cannot throw data from the trash to the trash
731
-		if($trash_args->module_srl == 0) return false;
859
+		if($trash_args->module_srl == 0) {
860
+			return false;
861
+		}
732 862
 		// Data setting
733 863
 		$trash_args->document_srl = $obj->document_srl;
734 864
 		$trash_args->description = $obj->description;
@@ -789,7 +919,9 @@  discard block
 block discarded – undo
789 919
 		  }*/
790 920
 
791 921
 		// update category
792
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
922
+		if($oDocument->get('category_srl')) {
923
+			$this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
924
+		}
793 925
 
794 926
 		// remove thumbnails
795 927
 		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
@@ -834,7 +966,9 @@  discard block
 block discarded – undo
834 966
 	function updateReadedCount(&$oDocument)
835 967
 	{
836 968
 		// Pass if Crawler access
837
-		if(isCrawler()) return false;
969
+		if(isCrawler()) {
970
+			return false;
971
+		}
838 972
 		
839 973
 		$document_srl = $oDocument->document_srl;
840 974
 		$member_srl = $oDocument->get('member_srl');
@@ -842,10 +976,14 @@  discard block
 block discarded – undo
842 976
 
843 977
 		// Call a trigger when the read count is updated (before)
844 978
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument);
845
-		if(!$trigger_output->toBool()) return $trigger_output;
979
+		if(!$trigger_output->toBool()) {
980
+			return $trigger_output;
981
+		}
846 982
 
847 983
 		// Pass if read count is increaded on the session information
848
-		if($_SESSION['readed_document'][$document_srl]) return false;
984
+		if($_SESSION['readed_document'][$document_srl]) {
985
+			return false;
986
+		}
849 987
 
850 988
 		// Pass if the author's IP address is as same as visitor's.
851 989
 		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
@@ -910,7 +1048,9 @@  discard block
 block discarded – undo
910 1048
 	 */
911 1049
 	function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid)
912 1050
 	{
913
-		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1,'msg_invalid_request');
1051
+		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) {
1052
+			return new Object(-1,'msg_invalid_request');
1053
+		}
914 1054
 
915 1055
 		$obj = new stdClass();
916 1056
 		$obj->module_srl = $module_srl;
@@ -927,8 +1067,7 @@  discard block
 block discarded – undo
927 1067
 		if(!$output->data)
928 1068
 		{
929 1069
 			$output = executeQuery('document.insertDocumentExtraKey', $obj);
930
-		}
931
-		else
1070
+		} else
932 1071
 		{
933 1072
 			$output = executeQuery('document.updateDocumentExtraKey', $obj);
934 1073
 			// Update the extra var(eid)
@@ -954,10 +1093,14 @@  discard block
 block discarded – undo
954 1093
 	 */
955 1094
 	function deleteDocumentExtraKeys($module_srl, $var_idx = null)
956 1095
 	{
957
-		if(!$module_srl) return new Object(-1,'msg_invalid_request');
1096
+		if(!$module_srl) {
1097
+			return new Object(-1,'msg_invalid_request');
1098
+		}
958 1099
 		$obj = new stdClass();
959 1100
 		$obj->module_srl = $module_srl;
960
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1101
+		if(!is_null($var_idx)) {
1102
+			$obj->var_idx = $var_idx;
1103
+		}
961 1104
 
962 1105
 		$oDB = DB::getInstance();
963 1106
 		$oDB->begin();
@@ -1021,8 +1164,12 @@  discard block
 block discarded – undo
1021 1164
 	 */
1022 1165
 	function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
1023 1166
 	{
1024
-		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1,'msg_invalid_request');
1025
-		if(!$lang_code) $lang_code = Context::getLangType();
1167
+		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) {
1168
+			return new Object(-1,'msg_invalid_request');
1169
+		}
1170
+		if(!$lang_code) {
1171
+			$lang_code = Context::getLangType();
1172
+		}
1026 1173
 
1027 1174
 		$obj = new stdClass;
1028 1175
 		$obj->module_srl = $module_srl;
@@ -1048,10 +1195,18 @@  discard block
 block discarded – undo
1048 1195
 	{
1049 1196
 		$obj = new stdClass();
1050 1197
 		$obj->module_srl = $module_srl;
1051
-		if(!is_null($document_srl)) $obj->document_srl = $document_srl;
1052
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1053
-		if(!is_null($lang_code)) $obj->lang_code = $lang_code;
1054
-		if(!is_null($eid)) $obj->eid = $eid;
1198
+		if(!is_null($document_srl)) {
1199
+			$obj->document_srl = $document_srl;
1200
+		}
1201
+		if(!is_null($var_idx)) {
1202
+			$obj->var_idx = $var_idx;
1203
+		}
1204
+		if(!is_null($lang_code)) {
1205
+			$obj->lang_code = $lang_code;
1206
+		}
1207
+		if(!is_null($eid)) {
1208
+			$obj->eid = $eid;
1209
+		}
1055 1210
 		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
1056 1211
 		return $output;
1057 1212
 	}
@@ -1065,8 +1220,11 @@  discard block
 block discarded – undo
1065 1220
 	 */
1066 1221
 	function updateVotedCount($document_srl, $point = 1)
1067 1222
 	{
1068
-		if($point > 0) $failed_voted = 'failed_voted';
1069
-		else $failed_voted = 'failed_blamed';
1223
+		if($point > 0) {
1224
+			$failed_voted = 'failed_voted';
1225
+		} else {
1226
+			$failed_voted = 'failed_blamed';
1227
+		}
1070 1228
 		// Return fail if session already has information about votes
1071 1229
 		if($_SESSION['voted_document'][$document_srl])
1072 1230
 		{
@@ -1102,8 +1260,7 @@  discard block
 block discarded – undo
1102 1260
 		if($member_srl)
1103 1261
 		{
1104 1262
 			$args->member_srl = $member_srl;
1105
-		}
1106
-		else
1263
+		} else
1107 1264
 		{
1108 1265
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1109 1266
 		}
@@ -1125,17 +1282,20 @@  discard block
 block discarded – undo
1125 1282
 		{
1126 1283
 			$args->blamed_count = $oDocument->get('blamed_count') + $point;
1127 1284
 			$output = executeQuery('document.updateBlamedCount', $args);
1128
-		}
1129
-		else
1285
+		} else
1130 1286
 		{
1131 1287
 			$args->voted_count = $oDocument->get('voted_count') + $point;
1132 1288
 			$output = executeQuery('document.updateVotedCount', $args);
1133 1289
 		}
1134
-		if(!$output->toBool()) return $output;
1290
+		if(!$output->toBool()) {
1291
+			return $output;
1292
+		}
1135 1293
 		// Leave logs
1136 1294
 		$args->point = $point;
1137 1295
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1138
-		if(!$output->toBool()) return $output;
1296
+		if(!$output->toBool()) {
1297
+			return $output;
1298
+		}
1139 1299
 
1140 1300
 		$obj = new stdClass;
1141 1301
 		$obj->member_srl = $oDocument->get('member_srl');
@@ -1171,8 +1331,7 @@  discard block
 block discarded – undo
1171 1331
 		{
1172 1332
 			$output->setMessage('success_voted');
1173 1333
 			$output->add('voted_count', $obj->after_point);
1174
-		}
1175
-		else
1334
+		} else
1176 1335
 		{
1177 1336
 			$output->setMessage('success_blamed');
1178 1337
 			$output->add('blamed_count', $obj->after_point);
@@ -1189,13 +1348,17 @@  discard block
 block discarded – undo
1189 1348
 	function declaredDocument($document_srl)
1190 1349
 	{
1191 1350
 		// Fail if session information already has a reported document
1192
-		if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
1351
+		if($_SESSION['declared_document'][$document_srl]) {
1352
+			return new Object(-1, 'failed_declared');
1353
+		}
1193 1354
 
1194 1355
 		// Check if previously reported
1195 1356
 		$args = new stdClass();
1196 1357
 		$args->document_srl = $document_srl;
1197 1358
 		$output = executeQuery('document.getDeclaredDocument', $args);
1198
-		if(!$output->toBool()) return $output;
1359
+		if(!$output->toBool()) {
1360
+			return $output;
1361
+		}
1199 1362
 
1200 1363
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1201 1364
 
@@ -1239,8 +1402,7 @@  discard block
 block discarded – undo
1239 1402
 		if($member_srl)
1240 1403
 		{
1241 1404
 			$args->member_srl = $member_srl;
1242
-		}
1243
-		else
1405
+		} else
1244 1406
 		{
1245 1407
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1246 1408
 		}
@@ -1260,9 +1422,14 @@  discard block
 block discarded – undo
1260 1422
 		$oDB->begin();
1261 1423
 
1262 1424
 		// Add the declared document
1263
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1264
-		else $output = executeQuery('document.insertDeclaredDocument', $args);
1265
-		if(!$output->toBool()) return $output;
1425
+		if($declared_count > 0) {
1426
+			$output = executeQuery('document.updateDeclaredDocument', $args);
1427
+		} else {
1428
+			$output = executeQuery('document.insertDeclaredDocument', $args);
1429
+		}
1430
+		if(!$output->toBool()) {
1431
+			return $output;
1432
+		}
1266 1433
 		// Leave logs
1267 1434
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1268 1435
 		if(!$output->toBool())
@@ -1361,9 +1528,10 @@  discard block
 block discarded – undo
1361 1528
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1362 1529
 			$obj->list_order = $parent_category->list_order;
1363 1530
 			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1364
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1365
-		}
1366
-		else
1531
+			if(!$obj->category_srl) {
1532
+				$obj->category_srl = getNextSequence();
1533
+			}
1534
+		} else
1367 1535
 		{
1368 1536
 			$obj->list_order = $obj->category_srl = getNextSequence();
1369 1537
 		}
@@ -1403,13 +1571,17 @@  discard block
 block discarded – undo
1403 1571
 	{
1404 1572
 		// Create a document model object
1405 1573
 		$oDocumentModel = getModel('document');
1406
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1574
+		if(!$document_count) {
1575
+			$document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1576
+		}
1407 1577
 
1408 1578
 		$args = new stdClass;
1409 1579
 		$args->category_srl = $category_srl;
1410 1580
 		$args->document_count = $document_count;
1411 1581
 		$output = executeQuery('document.updateCategoryCount', $args);
1412
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1582
+		if($output->toBool()) {
1583
+			$this->makeCategoryFile($module_srl);
1584
+		}
1413 1585
 
1414 1586
 		return $output;
1415 1587
 	}
@@ -1422,7 +1594,9 @@  discard block
 block discarded – undo
1422 1594
 	function updateCategory($obj)
1423 1595
 	{
1424 1596
 		$output = executeQuery('document.updateCategory', $obj);
1425
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1597
+		if($output->toBool()) {
1598
+			$this->makeCategoryFile($obj->module_srl);
1599
+		}
1426 1600
 		return $output;
1427 1601
 	}
1428 1602
 
@@ -1439,11 +1613,17 @@  discard block
 block discarded – undo
1439 1613
 		$category_info = $oDocumentModel->getCategory($category_srl);
1440 1614
 		// Display an error that the category cannot be deleted if it has a child
1441 1615
 		$output = executeQuery('document.getChildCategoryCount', $args);
1442
-		if(!$output->toBool()) return $output;
1443
-		if($output->data->count>0) return new Object(-1, 'msg_cannot_delete_for_child');
1616
+		if(!$output->toBool()) {
1617
+			return $output;
1618
+		}
1619
+		if($output->data->count>0) {
1620
+			return new Object(-1, 'msg_cannot_delete_for_child');
1621
+		}
1444 1622
 		// Delete a category information
1445 1623
 		$output = executeQuery('document.deleteCategory', $args);
1446
-		if(!$output->toBool()) return $output;
1624
+		if(!$output->toBool()) {
1625
+			return $output;
1626
+		}
1447 1627
 
1448 1628
 		$this->makeCategoryFile($category_info->module_srl);
1449 1629
 		// remvove cache
@@ -1458,8 +1638,9 @@  discard block
 block discarded – undo
1458 1638
 				$args->page = ++$page;
1459 1639
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1460 1640
 
1461
-				if($output->data == array())
1462
-					break;
1641
+				if($output->data == array()) {
1642
+									break;
1643
+				}
1463 1644
 
1464 1645
 				foreach($output->data as $val)
1465 1646
 				{
@@ -1511,18 +1692,26 @@  discard block
 block discarded – undo
1511 1692
 		// Seek a full list of categories
1512 1693
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1513 1694
 		$category_srl_list = array_keys($category_list);
1514
-		if(count($category_srl_list)<2) return new Object();
1695
+		if(count($category_srl_list)<2) {
1696
+			return new Object();
1697
+		}
1515 1698
 
1516 1699
 		$prev_category = NULL;
1517 1700
 		foreach($category_list as $key => $val)
1518 1701
 		{
1519
-			if($key==$category_srl) break;
1702
+			if($key==$category_srl) {
1703
+				break;
1704
+			}
1520 1705
 			$prev_category = $val;
1521 1706
 		}
1522 1707
 		// Return if the previous category doesn't exist
1523
-		if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved'));
1708
+		if(!$prev_category) {
1709
+			return new Object(-1,Context::getLang('msg_category_not_moved'));
1710
+		}
1524 1711
 		// Return if the selected category is the top level
1525
-		if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved'));
1712
+		if($category_srl_list[0]==$category_srl) {
1713
+			return new Object(-1,Context::getLang('msg_category_not_moved'));
1714
+		}
1526 1715
 		// Information of the selected category
1527 1716
 		$cur_args = new stdClass;
1528 1717
 		$cur_args->category_srl = $category_srl;
@@ -1558,15 +1747,21 @@  discard block
 block discarded – undo
1558 1747
 		// Seek a full list of categories
1559 1748
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1560 1749
 		$category_srl_list = array_keys($category_list);
1561
-		if(count($category_srl_list)<2) return new Object();
1750
+		if(count($category_srl_list)<2) {
1751
+			return new Object();
1752
+		}
1562 1753
 
1563 1754
 		for($i=0;$i<count($category_srl_list);$i++)
1564 1755
 		{
1565
-			if($category_srl_list[$i]==$category_srl) break;
1756
+			if($category_srl_list[$i]==$category_srl) {
1757
+				break;
1758
+			}
1566 1759
 		}
1567 1760
 
1568 1761
 		$next_category_srl = $category_srl_list[$i+1];
1569
-		if(!$category_list[$next_category_srl]) return new Object(-1,Context::getLang('msg_category_not_moved'));
1762
+		if(!$category_list[$next_category_srl]) {
1763
+			return new Object(-1,Context::getLang('msg_category_not_moved'));
1764
+		}
1570 1765
 		$next_category = $category_list[$next_category_srl];
1571 1766
 		// Information of the selected category
1572 1767
 		$cur_args = new stdClass;
@@ -1593,7 +1788,9 @@  discard block
 block discarded – undo
1593 1788
 	{
1594 1789
 		$oDocumentModel = getModel('document');
1595 1790
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1596
-		if(!count($extra_keys)) return;
1791
+		if(!count($extra_keys)) {
1792
+			return;
1793
+		}
1597 1794
 
1598 1795
 		$js_code = array();
1599 1796
 		$js_code[] = '<script>//<![CDATA[';
@@ -1612,7 +1809,9 @@  discard block
 block discarded – undo
1612 1809
 			}
1613 1810
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1614 1811
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1615
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1812
+			if($val->is_required == 'Y') {
1813
+				$js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1814
+			}
1616 1815
 		}
1617 1816
 
1618 1817
 		$js_code[] = '})(jQuery);';
@@ -1630,7 +1829,9 @@  discard block
 block discarded – undo
1630 1829
 	function procDocumentInsertCategory($args = null)
1631 1830
 	{
1632 1831
 		// List variables
1633
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1832
+		if(!$args) {
1833
+			$args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1834
+		}
1634 1835
 		$args->title = $args->category_title;
1635 1836
 		$args->description = $args->category_description;
1636 1837
 		$args->color = $args->category_color;
@@ -1646,11 +1847,18 @@  discard block
 block discarded – undo
1646 1847
 		$columnList = array('module_srl', 'module');
1647 1848
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1648 1849
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1649
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1850
+		if(!$grant->manager) {
1851
+			return new Object(-1,'msg_not_permitted');
1852
+		}
1650 1853
 
1651
-		if($args->expand !="Y") $args->expand = "N";
1652
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1653
-		else $args->group_srls = implode(',', $args->group_srls);
1854
+		if($args->expand !="Y") {
1855
+			$args->expand = "N";
1856
+		}
1857
+		if(!is_array($args->group_srls)) {
1858
+			$args->group_srls = str_replace('|@|',',',$args->group_srls);
1859
+		} else {
1860
+			$args->group_srls = implode(',', $args->group_srls);
1861
+		}
1654 1862
 		$args->parent_srl = (int)$args->parent_srl;
1655 1863
 
1656 1864
 		$oDocumentModel = getModel('document');
@@ -1661,7 +1869,9 @@  discard block
 block discarded – undo
1661 1869
 		if($args->category_srl)
1662 1870
 		{
1663 1871
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1664
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1872
+			if($category_info->category_srl != $args->category_srl) {
1873
+				$args->category_srl = null;
1874
+			}
1665 1875
 		}
1666 1876
 		// Update if exists
1667 1877
 		if($args->category_srl)
@@ -1673,8 +1883,7 @@  discard block
 block discarded – undo
1673 1883
 				return $output;
1674 1884
 			}
1675 1885
 			// Insert if not exist
1676
-		}
1677
-		else
1886
+		} else
1678 1887
 		{
1679 1888
 			$output = $this->insertCategory($args);
1680 1889
 			if(!$output->toBool())
@@ -1716,7 +1925,9 @@  discard block
 block discarded – undo
1716 1925
 		$columnList = array('module_srl', 'module');
1717 1926
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1718 1927
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1719
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
1928
+		if(!$grant->manager) {
1929
+			return new Object(-1,'msg_not_permitted');
1930
+		}
1720 1931
 
1721 1932
 		// First child of the parent_category_srl
1722 1933
 		$source_args = new stdClass;
@@ -1729,30 +1940,39 @@  discard block
 block discarded – undo
1729 1940
 			$args->parent_srl = $parent_category_srl;
1730 1941
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1731 1942
 
1732
-			if(!$output->toBool()) return $output;
1943
+			if(!$output->toBool()) {
1944
+				return $output;
1945
+			}
1733 1946
 			$args->list_order = (int)$output->data->list_order;
1734
-			if(!$args->list_order) $args->list_order = 0;
1947
+			if(!$args->list_order) {
1948
+				$args->list_order = 0;
1949
+			}
1735 1950
 			$args->list_order--;
1736 1951
 
1737 1952
 			$source_args->category_srl = $source_category_srl;
1738 1953
 			$source_args->parent_srl = $parent_category_srl;
1739 1954
 			$source_args->list_order = $args->list_order;
1740 1955
 			$output = $this->updateCategory($source_args);
1741
-			if(!$output->toBool()) return $output;
1956
+			if(!$output->toBool()) {
1957
+				return $output;
1958
+			}
1742 1959
 			// Sibling of the $target_category_srl
1743
-		}
1744
-		else if($target_category_srl > 0)
1960
+		} else if($target_category_srl > 0)
1745 1961
 		{
1746 1962
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1747 1963
 			// Move all siblings of the $target_category down
1748 1964
 			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1749
-			if(!$output->toBool()) return $output;
1965
+			if(!$output->toBool()) {
1966
+				return $output;
1967
+			}
1750 1968
 
1751 1969
 			$source_args->category_srl = $source_category_srl;
1752 1970
 			$source_args->parent_srl = $target_category->parent_srl;
1753 1971
 			$source_args->list_order = $target_category->list_order+1;
1754 1972
 			$output = $this->updateCategory($source_args);
1755
-			if(!$output->toBool()) return $output;
1973
+			if(!$output->toBool()) {
1974
+				return $output;
1975
+			}
1756 1976
 		}
1757 1977
 		// Re-generate the xml file
1758 1978
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1777,14 +1997,20 @@  discard block
 block discarded – undo
1777 1997
 		$columnList = array('module_srl', 'module');
1778 1998
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1779 1999
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1780
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
2000
+		if(!$grant->manager) {
2001
+			return new Object(-1,'msg_not_permitted');
2002
+		}
1781 2003
 
1782 2004
 		$oDocumentModel = getModel('document');
1783 2005
 		// Get original information
1784 2006
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1785
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
2007
+		if($category_info->parent_srl) {
2008
+			$parent_srl = $category_info->parent_srl;
2009
+		}
1786 2010
 		// Display an error that the category cannot be deleted if it has a child node
1787
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
2011
+		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) {
2012
+			return new Object(-1, 'msg_cannot_delete_for_child');
2013
+		}
1788 2014
 		// Remove from the DB
1789 2015
 		$output = $this->deleteCategory($args->category_srl);
1790 2016
 		if(!$output->toBool())
@@ -1818,7 +2044,9 @@  discard block
 block discarded – undo
1818 2044
 		$columnList = array('module_srl', 'module');
1819 2045
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1820 2046
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1821
-		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
2047
+		if(!$grant->manager) {
2048
+			return new Object(-1,'msg_not_permitted');
2049
+		}
1822 2050
 
1823 2051
 		$xml_file = $this->makeCategoryFile($module_srl);
1824 2052
 		// Set return value
@@ -1833,14 +2061,18 @@  discard block
 block discarded – undo
1833 2061
 	function makeCategoryFile($module_srl)
1834 2062
 	{
1835 2063
 		// Return if there is no information you need for creating a cache file
1836
-		if(!$module_srl) return false;
2064
+		if(!$module_srl) {
2065
+			return false;
2066
+		}
1837 2067
 		// Get module information (to obtain mid)
1838 2068
 		$oModuleModel = getModel('module');
1839 2069
 		$columnList = array('module_srl', 'mid', 'site_srl');
1840 2070
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1841 2071
 		$mid = $module_info->mid;
1842 2072
 
1843
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
2073
+		if(!is_dir('./files/cache/document_category')) {
2074
+			FileHandler::makeDir('./files/cache/document_category');
2075
+		}
1844 2076
 		// Cache file's name
1845 2077
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1846 2078
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1852,13 +2084,17 @@  discard block
 block discarded – undo
1852 2084
 
1853 2085
 		$category_list = $output->data;
1854 2086
 
1855
-		if(!is_array($category_list)) $category_list = array($category_list);
2087
+		if(!is_array($category_list)) {
2088
+			$category_list = array($category_list);
2089
+		}
1856 2090
 
1857 2091
 		$category_count = count($category_list);
1858 2092
 		for($i=0;$i<$category_count;$i++)
1859 2093
 		{
1860 2094
 			$category_srl = $category_list[$i]->category_srl;
1861
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
2095
+			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) {
2096
+				$category_list[$i]->group_srls = '';
2097
+			}
1862 2098
 			$list[$category_srl] = $category_list[$i];
1863 2099
 		}
1864 2100
 		// Create the xml file without node data if no data is obtained
@@ -1870,7 +2106,9 @@  discard block
 block discarded – undo
1870 2106
 			return $xml_file;
1871 2107
 		}
1872 2108
 		// Change to an array if only a single data is obtained
1873
-		if(!is_array($list)) $list = array($list);
2109
+		if(!is_array($list)) {
2110
+			$list = array($list);
2111
+		}
1874 2112
 		// Create a tree for loop
1875 2113
 		foreach($list as $category_srl => $node)
1876 2114
 		{
@@ -1949,13 +2187,17 @@  discard block
 block discarded – undo
1949 2187
 	 */
1950 2188
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1951 2189
 	{
1952
-		if(!$source_node) return;
2190
+		if(!$source_node) {
2191
+			return;
2192
+		}
1953 2193
 
1954 2194
 		foreach($source_node as $category_srl => $node)
1955 2195
 		{
1956 2196
 			$child_buff = "";
1957 2197
 			// Get data of the child nodes
1958
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
2198
+			if($category_srl && $tree[$category_srl]) {
2199
+				$child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
2200
+			}
1959 2201
 			// List variables
1960 2202
 			$expand = $node->expand;
1961 2203
 			$group_srls = $node->group_srls;
@@ -1965,8 +2207,11 @@  discard block
 block discarded – undo
1965 2207
 			$color = $node->color;
1966 2208
 			$description = $node->description;
1967 2209
 			// If node->group_srls value exists
1968
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1969
-			else $group_check_code = "true";
2210
+			if($group_srls) {
2211
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
2212
+			} else {
2213
+				$group_check_code = "true";
2214
+			}
1970 2215
 
1971 2216
 			$title = $node->title;
1972 2217
 			$oModuleAdminModel = getAdminModel('module');
@@ -2006,8 +2251,11 @@  discard block
 block discarded – undo
2006 2251
 				$node->document_count
2007 2252
 			);
2008 2253
 
2009
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2010
-			else $buff .=  sprintf('<node %s />', $attribute);
2254
+			if($child_buff) {
2255
+				$buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2256
+			} else {
2257
+				$buff .=  sprintf('<node %s />', $attribute);
2258
+			}
2011 2259
 		}
2012 2260
 		return $buff;
2013 2261
 	}
@@ -2026,7 +2274,9 @@  discard block
 block discarded – undo
2026 2274
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2027 2275
 	{
2028 2276
 		$output = array("buff"=>"", "category_srl_list"=>array());
2029
-		if(!$source_node) return $output;
2277
+		if(!$source_node) {
2278
+			return $output;
2279
+		}
2030 2280
 
2031 2281
 		// Set to an arraty for looping and then generate php script codes to be included
2032 2282
 		foreach($source_node as $category_srl => $node)
@@ -2125,7 +2375,9 @@  discard block
 block discarded – undo
2125 2375
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2126 2376
 	{
2127 2377
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2128
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2378
+		if(!is_array($document_popup_menu_list)) {
2379
+			$document_popup_menu_list = array();
2380
+		}
2129 2381
 
2130 2382
 		$obj = new stdClass();
2131 2383
 		$obj->url = $url;
@@ -2143,7 +2395,9 @@  discard block
 block discarded – undo
2143 2395
 	 */
2144 2396
 	function procDocumentAddCart()
2145 2397
 	{
2146
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted');
2398
+		if(!Context::get('is_logged')) {
2399
+			return new Object(-1, 'msg_not_permitted');
2400
+		}
2147 2401
 
2148 2402
 		// Get document_srl
2149 2403
 		$srls = explode(',',Context::get('srls'));
@@ -2151,11 +2405,15 @@  discard block
 block discarded – undo
2151 2405
 		{
2152 2406
 			$srl = trim($srls[$i]);
2153 2407
 
2154
-			if(!$srl) continue;
2408
+			if(!$srl) {
2409
+				continue;
2410
+			}
2155 2411
 
2156 2412
 			$document_srls[] = $srl;
2157 2413
 		}
2158
-		if(!count($document_srls)) return;
2414
+		if(!count($document_srls)) {
2415
+			return;
2416
+		}
2159 2417
 
2160 2418
 		// Get module_srl of the documents
2161 2419
 		$args = new stdClass;
@@ -2163,14 +2421,18 @@  discard block
 block discarded – undo
2163 2421
 		$args->document_srls = implode(',',$document_srls);
2164 2422
 		$args->order_type = 'asc';
2165 2423
 		$output = executeQueryArray('document.getDocuments', $args);
2166
-		if(!$output->data) return new Object();
2424
+		if(!$output->data) {
2425
+			return new Object();
2426
+		}
2167 2427
 
2168 2428
 		unset($document_srls);
2169 2429
 		foreach($output->data as $key => $val)
2170 2430
 		{
2171 2431
 			$document_srls[$val->module_srl][] = $val->document_srl;
2172 2432
 		}
2173
-		if(!$document_srls || !count($document_srls)) return new Object();
2433
+		if(!$document_srls || !count($document_srls)) {
2434
+			return new Object();
2435
+		}
2174 2436
 
2175 2437
 		// 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)
2176 2438
 		$oModuleModel = getModel('module');
@@ -2195,7 +2457,9 @@  discard block
 block discarded – undo
2195 2457
 				}
2196 2458
 			}
2197 2459
 		}
2198
-		if(!count($document_srls)) return new Object();
2460
+		if(!count($document_srls)) {
2461
+			return new Object();
2462
+		}
2199 2463
 
2200 2464
 		foreach($document_srls as $module_srl => $documents)
2201 2465
 		{
@@ -2203,9 +2467,14 @@  discard block
 block discarded – undo
2203 2467
 			for($i=0;$i<$cnt;$i++)
2204 2468
 			{
2205 2469
 				$document_srl = (int)trim($documents[$i]);
2206
-				if(!$document_srls) continue;
2207
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2208
-				else $_SESSION['document_management'][$document_srl] = true;
2470
+				if(!$document_srls) {
2471
+					continue;
2472
+				}
2473
+				if($_SESSION['document_management'][$document_srl]) {
2474
+					unset($_SESSION['document_management'][$document_srl]);
2475
+				} else {
2476
+					$_SESSION['document_management'][$document_srl] = true;
2477
+				}
2209 2478
 			}
2210 2479
 		}
2211 2480
 	}
@@ -2217,7 +2486,9 @@  discard block
 block discarded – undo
2217 2486
 	function procDocumentManageCheckedDocument()
2218 2487
 	{
2219 2488
 		@set_time_limit(0);
2220
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2489
+		if(!Context::get('is_logged')) {
2490
+			return new Object(-1,'msg_not_permitted');
2491
+		}
2221 2492
 
2222 2493
 		if(!checkCSRF())
2223 2494
 		{
@@ -2227,14 +2498,21 @@  discard block
 block discarded – undo
2227 2498
 		$type = Context::get('type');
2228 2499
 		$target_module = Context::get('target_module');
2229 2500
 		$module_srl = Context::get('module_srl');
2230
-		if($target_module && !$module_srl) $module_srl = $target_module;
2501
+		if($target_module && !$module_srl) {
2502
+			$module_srl = $target_module;
2503
+		}
2231 2504
 		$category_srl = Context::get('target_category');
2232 2505
 		$message_content = Context::get('message_content');
2233
-		if($message_content) $message_content = nl2br($message_content);
2506
+		if($message_content) {
2507
+			$message_content = nl2br($message_content);
2508
+		}
2234 2509
 
2235 2510
 		$cart = Context::get('cart');
2236
-		if(!is_array($cart)) $document_srl_list = explode('|@|', $cart);
2237
-		else $document_srl_list = $cart;
2511
+		if(!is_array($cart)) {
2512
+			$document_srl_list = explode('|@|', $cart);
2513
+		} else {
2514
+			$document_srl_list = $cart;
2515
+		}
2238 2516
 
2239 2517
 		$document_srl_count = count($document_srl_list);
2240 2518
 
@@ -2244,7 +2522,9 @@  discard block
 block discarded – undo
2244 2522
 		{
2245 2523
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2246 2524
 			$document_items[] = $oDocument;
2247
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2525
+			if(!$oDocument->isGranted()) {
2526
+				return $this->stop('msg_not_permitted');
2527
+			}
2248 2528
 		}
2249 2529
 
2250 2530
 		// Send a message
@@ -2260,10 +2540,15 @@  discard block
 block discarded – undo
2260 2540
 
2261 2541
 			foreach($document_items as $oDocument)
2262 2542
 			{
2263
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2543
+				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) {
2544
+					continue;
2545
+				}
2264 2546
 
2265
-				if($type=='move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2266
-				else $purl = "";
2547
+				if($type=='move') {
2548
+					$purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2549
+				} else {
2550
+					$purl = "";
2551
+				}
2267 2552
 				$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));
2268 2553
 
2269 2554
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
@@ -2276,24 +2561,30 @@  discard block
 block discarded – undo
2276 2561
 		$oDocumentAdminController = getAdminController('document');
2277 2562
 		if($type == 'move')
2278 2563
 		{
2279
-			if(!$module_srl) return new Object(-1, 'fail_to_move');
2564
+			if(!$module_srl) {
2565
+				return new Object(-1, 'fail_to_move');
2566
+			}
2280 2567
 
2281 2568
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2282
-			if(!$output->toBool()) return new Object(-1, 'fail_to_move');
2569
+			if(!$output->toBool()) {
2570
+				return new Object(-1, 'fail_to_move');
2571
+			}
2283 2572
 
2284 2573
 			$msg_code = 'success_moved';
2285 2574
 
2286
-		}
2287
-		else if($type == 'copy')
2575
+		} else if($type == 'copy')
2288 2576
 		{
2289
-			if(!$module_srl) return new Object(-1, 'fail_to_move');
2577
+			if(!$module_srl) {
2578
+				return new Object(-1, 'fail_to_move');
2579
+			}
2290 2580
 
2291 2581
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2292
-			if(!$output->toBool()) return new Object(-1, 'fail_to_move');
2582
+			if(!$output->toBool()) {
2583
+				return new Object(-1, 'fail_to_move');
2584
+			}
2293 2585
 
2294 2586
 			$msg_code = 'success_copied';
2295
-		}
2296
-		else if($type =='delete')
2587
+		} else if($type =='delete')
2297 2588
 		{
2298 2589
 			$oDB = &DB::getInstance();
2299 2590
 			$oDB->begin();
@@ -2301,12 +2592,13 @@  discard block
 block discarded – undo
2301 2592
 			{
2302 2593
 				$document_srl = $document_srl_list[$i];
2303 2594
 				$output = $this->deleteDocument($document_srl, true);
2304
-				if(!$output->toBool()) return new Object(-1, 'fail_to_delete');
2595
+				if(!$output->toBool()) {
2596
+					return new Object(-1, 'fail_to_delete');
2597
+				}
2305 2598
 			}
2306 2599
 			$oDB->commit();
2307 2600
 			$msg_code = 'success_deleted';
2308
-		}
2309
-		else if($type == 'trash')
2601
+		} else if($type == 'trash')
2310 2602
 		{
2311 2603
 			$args = new stdClass();
2312 2604
 			$args->description = $message_content;
@@ -2316,12 +2608,13 @@  discard block
 block discarded – undo
2316 2608
 			for($i=0;$i<$document_srl_count;$i++) {
2317 2609
 				$args->document_srl = $document_srl_list[$i];
2318 2610
 				$output = $this->moveDocumentToTrash($args);
2319
-				if(!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash');
2611
+				if(!$output || !$output->toBool()) {
2612
+					return new Object(-1, 'fail_to_trash');
2613
+				}
2320 2614
 			}
2321 2615
 			$oDB->commit();
2322 2616
 			$msg_code = 'success_trashed';
2323
-		}
2324
-		else if($type == 'cancelDeclare')
2617
+		} else if($type == 'cancelDeclare')
2325 2618
 		{
2326 2619
 			$args->document_srl = $document_srl_list;
2327 2620
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2343,18 +2636,27 @@  discard block
 block discarded – undo
2343 2636
 	function procDocumentInsertModuleConfig()
2344 2637
 	{
2345 2638
 		$module_srl = Context::get('target_module_srl');
2346
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2347
-		else $module_srl = array($module_srl);
2639
+		if(preg_match('/^([0-9,]+)$/',$module_srl)) {
2640
+			$module_srl = explode(',',$module_srl);
2641
+		} else {
2642
+			$module_srl = array($module_srl);
2643
+		}
2348 2644
 
2349 2645
 		$document_config = new stdClass();
2350 2646
 		$document_config->use_history = Context::get('use_history');
2351
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2647
+		if(!$document_config->use_history) {
2648
+			$document_config->use_history = 'N';
2649
+		}
2352 2650
 
2353 2651
 		$document_config->use_vote_up = Context::get('use_vote_up');
2354
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2652
+		if(!$document_config->use_vote_up) {
2653
+			$document_config->use_vote_up = 'Y';
2654
+		}
2355 2655
 
2356 2656
 		$document_config->use_vote_down = Context::get('use_vote_down');
2357
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2657
+		if(!$document_config->use_vote_down) {
2658
+			$document_config->use_vote_down = 'Y';
2659
+		}
2358 2660
 
2359 2661
 		$document_config->use_status = Context::get('use_status');
2360 2662
 
@@ -2362,7 +2664,9 @@  discard block
 block discarded – undo
2362 2664
 		for($i=0;$i<count($module_srl);$i++)
2363 2665
 		{
2364 2666
 			$srl = trim($module_srl[$i]);
2365
-			if(!$srl) continue;
2667
+			if(!$srl) {
2668
+				continue;
2669
+			}
2366 2670
 			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2367 2671
 		}
2368 2672
 		$this->setError(-1);
@@ -2379,7 +2683,9 @@  discard block
 block discarded – undo
2379 2683
 	function procDocumentTempSave()
2380 2684
 	{
2381 2685
 		// Check login information
2382
-		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
2686
+		if(!Context::get('is_logged')) {
2687
+			return new Object(-1, 'msg_not_logged');
2688
+		}
2383 2689
 		$module_info = Context::get('module_info');
2384 2690
 		$logged_info = Context::get('logged_info');
2385 2691
 
@@ -2417,8 +2723,7 @@  discard block
 block discarded – undo
2417 2723
 			$output = $oDocumentController->updateDocument($oDocument, $obj);
2418 2724
 			$msg_code = 'success_updated';
2419 2725
 			// Otherwise, get a new
2420
-		}
2421
-		else
2726
+		} else
2422 2727
 		{
2423 2728
 			$output = $oDocumentController->insertDocument($obj);
2424 2729
 			$msg_code = 'success_registed';
@@ -2444,17 +2749,20 @@  discard block
 block discarded – undo
2444 2749
 	 */
2445 2750
 	function procDocumentGetList()
2446 2751
 	{
2447
-		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2752
+		if(!Context::get('is_logged')) {
2753
+			return new Object(-1,'msg_not_permitted');
2754
+		}
2448 2755
 		$documentSrls = Context::get('document_srls');
2449
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2756
+		if($documentSrls) {
2757
+			$documentSrlList = explode(',', $documentSrls);
2758
+		}
2450 2759
 
2451 2760
 		if(count($documentSrlList) > 0)
2452 2761
 		{
2453 2762
 			$oDocumentModel = getModel('document');
2454 2763
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
2455 2764
 			$documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList);
2456
-		}
2457
-		else
2765
+		} else
2458 2766
 		{
2459 2767
 			global $lang;
2460 2768
 			$documentList = array();
@@ -2472,11 +2780,18 @@  discard block
 block discarded – undo
2472 2780
 	 */
2473 2781
 	function _checkCommentStatusForOldVersion(&$obj)
2474 2782
 	{
2475
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2476
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2783
+		if(!isset($obj->allow_comment)) {
2784
+			$obj->allow_comment = 'N';
2785
+		}
2786
+		if(!isset($obj->lock_comment)) {
2787
+			$obj->lock_comment = 'N';
2788
+		}
2477 2789
 
2478
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2479
-		else $obj->commentStatus = 'DENY';
2790
+		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') {
2791
+			$obj->commentStatus = 'ALLOW';
2792
+		} else {
2793
+			$obj->commentStatus = 'DENY';
2794
+		}
2480 2795
 	}
2481 2796
 
2482 2797
 	/**
@@ -2486,8 +2801,12 @@  discard block
 block discarded – undo
2486 2801
 	 */
2487 2802
 	function _checkDocumentStatusForOldVersion(&$obj)
2488 2803
 	{
2489
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2490
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2804
+		if(!$obj->status && $obj->is_secret == 'Y') {
2805
+			$obj->status = $this->getConfigStatus('secret');
2806
+		}
2807
+		if(!$obj->status && $obj->is_secret != 'Y') {
2808
+			$obj->status = $this->getConfigStatus('public');
2809
+		}
2491 2810
 	}
2492 2811
 
2493 2812
 	public function updateUploaedCount($documentSrlList)
Please login to merge, or discard this patch.
modules/document/document.item.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1106,8 +1106,7 @@
 block discarded – undo
1106 1106
 
1107 1107
 	/**
1108 1108
 	 * Check accessible by document status
1109
-	 * @param array $matches
1110
-	 * @return mixed
1109
+	 * @return boolean
1111 1110
 	 */
1112 1111
 	function _checkAccessibleFromStatus()
1113 1112
 	{
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 /**
4
- * documentItem class
5
- * document object
6
- *
7
- * @author NAVER ([email protected])
8
- * @package /modules/document
9
- * @version 0.1
10
- */
4
+	 * documentItem class
5
+	 * document object
6
+	 *
7
+	 * @author NAVER ([email protected])
8
+	 * @package /modules/document
9
+	 * @version 0.1
10
+	 */
11 11
 class documentItem extends Object
12 12
 {
13 13
 	/**
Please login to merge, or discard this patch.
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	function _loadFromDB($load_extra_vars = true)
76 76
 	{
77
-		if(!$this->document_srl) return;
77
+		if (!$this->document_srl) return;
78 78
 
79 79
 		$document_item = false;
80 80
 		$cache_put = false;
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 
84 84
 		// cache controll
85 85
 		$oCacheHandler = CacheHandler::getInstance('object');
86
-		if($oCacheHandler->isSupport())
86
+		if ($oCacheHandler->isSupport())
87 87
 		{
88 88
 			$cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl;
89 89
 			$document_item = $oCacheHandler->get($cache_key);
90
-			if($document_item !== false)
90
+			if ($document_item !== false)
91 91
 			{
92 92
 				$columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
93 93
 			}
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 		$args->document_srl = $this->document_srl;
98 98
 		$output = executeQuery('document.getDocument', $args, $columnList);
99 99
 
100
-		if($document_item === false)
100
+		if ($document_item === false)
101 101
 		{
102 102
 			$document_item = $output->data;
103 103
 
104 104
 				//insert in cache
105
-			if($document_item && $oCacheHandler->isSupport())
105
+			if ($document_item && $oCacheHandler->isSupport())
106 106
 			{
107 107
 				$oCacheHandler->put($cache_key, $document_item);
108 108
 			}
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 		$this->setAttribute($document_item, $load_extra_vars);
120 120
 	}
121 121
 
122
-	function setAttribute($attribute, $load_extra_vars=true)
122
+	function setAttribute($attribute, $load_extra_vars = true)
123 123
 	{
124
-		if(!$attribute->document_srl)
124
+		if (!$attribute->document_srl)
125 125
 		{
126 126
 			$this->document_srl = null;
127 127
 			return;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		$this->adds($attribute);
132 132
 
133 133
 		// Tags
134
-		if($this->get('tags'))
134
+		if ($this->get('tags'))
135 135
 		{
136 136
 			$tag_list = explode(',', $this->get('tags'));
137 137
 			$tag_list = array_map('trim', $tag_list);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 
141 141
 		$oDocumentModel = getModel('document');
142
-		if($load_extra_vars)
142
+		if ($load_extra_vars)
143 143
 		{
144 144
 			$GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this;
145 145
 			$oDocumentModel->setToAllDocumentExtraVars();
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
 
155 155
 	function isGranted()
156 156
 	{
157
-		if($_SESSION['own_document'][$this->document_srl]) return true;
157
+		if ($_SESSION['own_document'][$this->document_srl]) return true;
158 158
 
159
-		if(!Context::get('is_logged')) return false;
159
+		if (!Context::get('is_logged')) return false;
160 160
 
161 161
 		$logged_info = Context::get('logged_info');
162
-		if($logged_info->is_admin == 'Y') return true;
162
+		if ($logged_info->is_admin == 'Y') return true;
163 163
 
164 164
 		$oModuleModel = getModel('module');
165 165
 		$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
166
-		if($grant->manager) return true;
166
+		if ($grant->manager) return true;
167 167
 
168
-		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true;
168
+		if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl)) return true;
169 169
 
170 170
 		return false;
171 171
 	}
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 
178 178
 	function isAccessible()
179 179
 	{
180
-		return $_SESSION['accessible'][$this->document_srl]==true?true:false;
180
+		return $_SESSION['accessible'][$this->document_srl] == true ? true : false;
181 181
 	}
182 182
 
183 183
 	function allowComment()
184 184
 	{
185 185
 		// init write, document is not exists. so allow comment status is true
186
-		if(!$this->isExists()) return true;
186
+		if (!$this->isExists()) return true;
187 187
 
188 188
 		return $this->get('comment_status') == 'ALLOW' ? true : false;
189 189
 	}
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 	function allowTrackback()
192 192
 	{
193 193
 		static $allow_trackback_status = null;
194
-		if(is_null($allow_trackback_status))
194
+		if (is_null($allow_trackback_status))
195 195
 		{
196 196
 			
197 197
 			// Check the tarckback module exist
198
-			if(!getClass('trackback'))
198
+			if (!getClass('trackback'))
199 199
 			{
200 200
 				$allow_trackback_status = false;
201 201
 			}
@@ -205,20 +205,20 @@  discard block
 block discarded – undo
205 205
 				$oModuleModel = getModel('module');
206 206
 				$trackback_config = $oModuleModel->getModuleConfig('trackback');
207 207
 				
208
-				if(!$trackback_config)
208
+				if (!$trackback_config)
209 209
 				{
210 210
 					$trackback_config = new stdClass();
211 211
 				}
212 212
 				
213
-				if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
214
-				if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
213
+				if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
214
+				if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
215 215
 				else
216 216
 				{
217 217
 					$module_srl = $this->get('module_srl');
218 218
 					// Check settings of each module
219 219
 					$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
220
-					if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
221
-					else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
220
+					if ($module_config->enable_trackback == 'N') $allow_trackback_status = false;
221
+					else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true;
222 222
 				}
223 223
 			}
224 224
 		}
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 
228 228
 	function isLocked()
229 229
 	{
230
-		if(!$this->isExists()) return false;
230
+		if (!$this->isExists()) return false;
231 231
 
232 232
 		return $this->get('comment_status') == 'ALLOW' ? false : true;
233 233
 	}
234 234
 
235 235
 	function isEditable()
236 236
 	{
237
-		if($this->isGranted() || !$this->get('member_srl')) return true;
237
+		if ($this->isGranted() || !$this->get('member_srl')) return true;
238 238
 		return false;
239 239
 	}
240 240
 
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 
252 252
 	function useNotify()
253 253
 	{
254
-		return $this->get('notify_message')=='Y' ? true : false;
254
+		return $this->get('notify_message') == 'Y' ? true : false;
255 255
 	}
256 256
 
257 257
 	function doCart()
258 258
 	{
259
-		if(!$this->document_srl) return false;
260
-		if($this->isCarted()) $this->removeCart();
259
+		if (!$this->document_srl) return false;
260
+		if ($this->isCarted()) $this->removeCart();
261 261
 		else $this->addCart();
262 262
 	}
263 263
 
@@ -284,18 +284,18 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	function notify($type, $content)
286 286
 	{
287
-		if(!$this->document_srl) return;
287
+		if (!$this->document_srl) return;
288 288
 		// return if it is not useNotify
289
-		if(!$this->useNotify()) return;
289
+		if (!$this->useNotify()) return;
290 290
 		// Pass if an author is not a logged-in user
291
-		if(!$this->get('member_srl')) return;
291
+		if (!$this->get('member_srl')) return;
292 292
 		// Return if the currently logged-in user is an author
293 293
 		$logged_info = Context::get('logged_info');
294
-		if($logged_info->member_srl == $this->get('member_srl')) return;
294
+		if ($logged_info->member_srl == $this->get('member_srl')) return;
295 295
 		// List variables
296
-		if($type) $title = "[".$type."] ";
296
+		if ($type) $title = "[" . $type . "] ";
297 297
 		$title .= cut_str(strip_tags($content), 10, '...');
298
-		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
298
+		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl));
299 299
 		$receiver_srl = $this->get('member_srl');
300 300
 		$sender_member_srl = $logged_info->member_srl;
301 301
 		// Send a message
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 	function getIpAddress()
312 312
 	{
313
-		if($this->isGranted())
313
+		if ($this->isGranted())
314 314
 		{
315 315
 			return $this->get('ipaddress');
316 316
 		}
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 
321 321
 	function isExistsHomepage()
322 322
 	{
323
-		if(trim($this->get('homepage'))) return true;
323
+		if (trim($this->get('homepage'))) return true;
324 324
 		return false;
325 325
 	}
326 326
 
327 327
 	function getHomepageUrl()
328 328
 	{
329 329
 		$url = trim($this->get('homepage'));
330
-		if(!$url) return;
330
+		if (!$url) return;
331 331
 
332
-		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
332
+		if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
333 333
 
334 334
 		return $url;
335 335
 	}
@@ -359,54 +359,54 @@  discard block
 block discarded – undo
359 359
 		return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
360 360
 	}
361 361
 
362
-	function getTitleText($cut_size = 0, $tail='...')
362
+	function getTitleText($cut_size = 0, $tail = '...')
363 363
 	{
364
-		if(!$this->document_srl) return;
364
+		if (!$this->document_srl) return;
365 365
 
366
-		if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
366
+		if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
367 367
 		else $title = $this->get('title');
368 368
 
369 369
 		return $title;
370 370
 	}
371 371
 
372
-	function getTitle($cut_size = 0, $tail='...')
372
+	function getTitle($cut_size = 0, $tail = '...')
373 373
 	{
374
-		if(!$this->document_srl) return;
374
+		if (!$this->document_srl) return;
375 375
 
376 376
 		$title = $this->getTitleText($cut_size, $tail);
377 377
 
378 378
 		$attrs = array();
379 379
 		$this->add('title_color', trim($this->get('title_color')));
380
-		if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
381
-		if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
380
+		if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;";
381
+		if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#" . $this->get('title_color');
382 382
 
383
-		if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
383
+		if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
384 384
 		else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
385 385
 	}
386 386
 
387 387
 	function getContentText($strlen = 0)
388 388
 	{
389
-		if(!$this->document_srl) return;
389
+		if (!$this->document_srl) return;
390 390
 
391
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
391
+		if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
392 392
 
393 393
 		$result = $this->_checkAccessibleFromStatus();
394
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
394
+		if ($result) $_SESSION['accessible'][$this->document_srl] = true;
395 395
 
396 396
 		$content = $this->get('content');
397 397
 		$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
398 398
 		$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
399 399
 
400
-		if($strlen) return cut_str(strip_tags($content),$strlen,'...');
400
+		if ($strlen) return cut_str(strip_tags($content), $strlen, '...');
401 401
 
402 402
 		return htmlspecialchars($content);
403 403
 	}
404 404
 
405 405
 	function _addAllowScriptAccess($m)
406 406
 	{
407
-		if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
407
+		if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
408 408
 		{
409
-			$m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>';
409
+			$m[0] = $m[0] . '<param name="allowscriptaccess" value="never"></param>';
410 410
 		}
411 411
 		$this->allowscriptaccessKey++;
412 412
 		return $m[0];
@@ -414,26 +414,26 @@  discard block
 block discarded – undo
414 414
 
415 415
 	function _checkAllowScriptAccess($m)
416 416
 	{
417
-		if($m[1] == 'object')
417
+		if ($m[1] == 'object')
418 418
 		{
419 419
 			$this->allowscriptaccessList[] = 1;
420 420
 		}
421 421
 
422
-		if($m[1] == 'param')
422
+		if ($m[1] == 'param')
423 423
 		{
424
-			if(stripos($m[0], 'allowscriptaccess'))
424
+			if (stripos($m[0], 'allowscriptaccess'))
425 425
 			{
426 426
 				$m[0] = '<param name="allowscriptaccess" value="never"';
427
-				if(substr($m[0], -1) == '/')
427
+				if (substr($m[0], -1) == '/')
428 428
 				{
429 429
 					$m[0] .= '/';
430 430
 				}
431
-				$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
431
+				$this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--;
432 432
 			}
433 433
 		}
434
-		else if($m[1] == 'embed')
434
+		else if ($m[1] == 'embed')
435 435
 		{
436
-			if(stripos($m[0], 'allowscriptaccess'))
436
+			if (stripos($m[0], 'allowscriptaccess'))
437 437
 			{
438 438
 				$m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]);
439 439
 			}
@@ -447,24 +447,24 @@  discard block
 block discarded – undo
447 447
 
448 448
 	function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
449 449
 	{
450
-		if(!$this->document_srl) return;
450
+		if (!$this->document_srl) return;
451 451
 
452
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
452
+		if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
453 453
 
454 454
 		$result = $this->_checkAccessibleFromStatus();
455
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
455
+		if ($result) $_SESSION['accessible'][$this->document_srl] = true;
456 456
 
457 457
 		$content = $this->get('content');
458
-		if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
458
+		if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
459 459
 
460 460
 		// Define a link if using a rewrite module
461 461
 		$oContext = &Context::getInstance();
462
-		if($oContext->allow_rewrite)
462
+		if ($oContext->allow_rewrite)
463 463
 		{
464
-			$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content);
464
+			$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2" . Context::getRequestUri() . "?", $content);
465 465
 		}
466 466
 		// To display a pop-up menu
467
-		if($add_popup_menu)
467
+		if ($add_popup_menu)
468 468
 		{
469 469
 			$content = sprintf(
470 470
 				'%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>',
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 			);
474 474
 		}
475 475
 		// If additional content information is set
476
-		if($add_content_info)
476
+		if ($add_content_info)
477 477
 		{
478 478
 			$memberSrl = $this->get('member_srl');
479
-			if($memberSrl < 0)
479
+			if ($memberSrl < 0)
480 480
 			{
481 481
 				$memberSrl = 0;
482 482
 			}
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
 		}
493 493
 		else
494 494
 		{
495
-			if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
495
+			if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
496 496
 		}
497 497
 		// Change the image path to a valid absolute path if resource_realpath is true
498
-		if($resource_realpath)
498
+		if ($resource_realpath)
499 499
 		{
500
-			$content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content);
500
+			$content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content);
501 501
 		}
502 502
 
503 503
 		return $content;
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 		$content = trim(cut_str($content, $str_size, $tail));
547 547
 
548 548
 		// Replace back < , <, "
549
-		$content = str_replace(array('<', '>', '"'),array('&lt;', '&gt;', '&quot;'), $content);
549
+		$content = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $content);
550 550
 
551 551
 		return $content;
552 552
 	}
@@ -559,23 +559,23 @@  discard block
 block discarded – undo
559 559
 	function getRegdateTime()
560 560
 	{
561 561
 		$regdate = $this->get('regdate');
562
-		$year = substr($regdate,0,4);
563
-		$month = substr($regdate,4,2);
564
-		$day = substr($regdate,6,2);
565
-		$hour = substr($regdate,8,2);
566
-		$min = substr($regdate,10,2);
567
-		$sec = substr($regdate,12,2);
568
-		return mktime($hour,$min,$sec,$month,$day,$year);
562
+		$year = substr($regdate, 0, 4);
563
+		$month = substr($regdate, 4, 2);
564
+		$day = substr($regdate, 6, 2);
565
+		$hour = substr($regdate, 8, 2);
566
+		$min = substr($regdate, 10, 2);
567
+		$sec = substr($regdate, 12, 2);
568
+		return mktime($hour, $min, $sec, $month, $day, $year);
569 569
 	}
570 570
 
571 571
 	function getRegdateGM()
572 572
 	{
573
-		return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone'];
573
+		return $this->getRegdate('D, d M Y H:i:s') . ' ' . $GLOBALS['_time_zone'];
574 574
 	}
575 575
 
576 576
 	function getRegdateDT()
577 577
 	{
578
-		return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
578
+		return $this->getRegdate('Y-m-d') . 'T' . $this->getRegdate('H:i:s') . substr($GLOBALS['_time_zone'], 0, 3) . ':' . substr($GLOBALS['_time_zone'], 3, 2);
579 579
 	}
580 580
 
581 581
 	function getUpdate($format = 'Y.m.d H:i:s')
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 
586 586
 	function getUpdateTime()
587 587
 	{
588
-		$year = substr($this->get('last_update'),0,4);
589
-		$month = substr($this->get('last_update'),4,2);
590
-		$day = substr($this->get('last_update'),6,2);
591
-		$hour = substr($this->get('last_update'),8,2);
592
-		$min = substr($this->get('last_update'),10,2);
593
-		$sec = substr($this->get('last_update'),12,2);
594
-		return mktime($hour,$min,$sec,$month,$day,$year);
588
+		$year = substr($this->get('last_update'), 0, 4);
589
+		$month = substr($this->get('last_update'), 4, 2);
590
+		$day = substr($this->get('last_update'), 6, 2);
591
+		$hour = substr($this->get('last_update'), 8, 2);
592
+		$min = substr($this->get('last_update'), 10, 2);
593
+		$sec = substr($this->get('last_update'), 12, 2);
594
+		return mktime($hour, $min, $sec, $month, $day, $year);
595 595
 	}
596 596
 
597 597
 	function getUpdateGM()
@@ -601,21 +601,21 @@  discard block
 block discarded – undo
601 601
 
602 602
 	function getUpdateDT()
603 603
 	{
604
-		return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
604
+		return $this->getUpdate('Y-m-d') . 'T' . $this->getUpdate('H:i:s') . substr($GLOBALS['_time_zone'], 0, 3) . ':' . substr($GLOBALS['_time_zone'], 3, 2);
605 605
 	}
606 606
 
607 607
 	function getPermanentUrl()
608 608
 	{
609
-		return getFullUrl('','document_srl',$this->get('document_srl'));
609
+		return getFullUrl('', 'document_srl', $this->get('document_srl'));
610 610
 	}
611 611
 
612 612
 	function getTrackbackUrl()
613 613
 	{
614
-		if(!$this->document_srl) return;
614
+		if (!$this->document_srl) return;
615 615
 
616 616
 		// Generate a key to prevent spams
617 617
 		$oTrackbackModel = getModel('trackback');
618
-		if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
618
+		if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
619 619
 	}
620 620
 
621 621
 	/**
@@ -625,24 +625,24 @@  discard block
 block discarded – undo
625 625
 	function updateReadedCount()
626 626
 	{
627 627
 		$oDocumentController = getController('document');
628
-		if($oDocumentController->updateReadedCount($this))
628
+		if ($oDocumentController->updateReadedCount($this))
629 629
 		{
630 630
 			$readed_count = $this->get('readed_count');
631
-			$this->add('readed_count', $readed_count+1);
631
+			$this->add('readed_count', $readed_count + 1);
632 632
 		}
633 633
 	}
634 634
 
635 635
 	function isExtraVarsExists()
636 636
 	{
637
-		if(!$this->get('module_srl')) return false;
637
+		if (!$this->get('module_srl')) return false;
638 638
 		$oDocumentModel = getModel('document');
639 639
 		$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
640
-		return count($extra_keys)?true:false;
640
+		return count($extra_keys) ? true : false;
641 641
 	}
642 642
 
643 643
 	function getExtraVars()
644 644
 	{
645
-		if(!$this->get('module_srl') || !$this->document_srl) return null;
645
+		if (!$this->get('module_srl') || !$this->document_srl) return null;
646 646
 
647 647
 		$oDocumentModel = getModel('document');
648 648
 		return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	function getExtraValue($idx)
652 652
 	{
653 653
 		$extra_vars = $this->getExtraVars();
654
-		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
654
+		if (is_array($extra_vars) && array_key_exists($idx, $extra_vars))
655 655
 		{
656 656
 			return $extra_vars[$idx]->getValue();
657 657
 		}
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	function getExtraValueHTML($idx)
665 665
 	{
666 666
 		$extra_vars = $this->getExtraVars();
667
-		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
667
+		if (is_array($extra_vars) && array_key_exists($idx, $extra_vars))
668 668
 		{
669 669
 			return $extra_vars[$idx]->getValueHTML();
670 670
 		}
@@ -678,16 +678,16 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		$extra_vars = $this->getExtraVars();
680 680
 
681
-		if($extra_vars)
681
+		if ($extra_vars)
682 682
 		{
683 683
 			// Handle extra variable(eid)
684
-			foreach($extra_vars as $idx => $key)
684
+			foreach ($extra_vars as $idx => $key)
685 685
 			{
686 686
 				$extra_eid[$key->eid] = $key;
687 687
 			}
688 688
 		}
689 689
 		
690
-		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
690
+		if (is_array($extra_eid) && array_key_exists($eid, $extra_eid))
691 691
 		{
692 692
 			return $extra_eid[$eid]->getValue();
693 693
 		}
@@ -701,12 +701,12 @@  discard block
 block discarded – undo
701 701
 	{
702 702
 		$extra_vars = $this->getExtraVars();
703 703
 		// Handle extra variable(eid)
704
-		foreach($extra_vars as $idx => $key)
704
+		foreach ($extra_vars as $idx => $key)
705 705
 		{
706 706
 			$extra_eid[$key->eid] = $key;
707 707
 		}
708 708
 		
709
-		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
709
+		if (is_array($extra_eid) && array_key_exists($eid, $extra_eid))
710 710
 		{
711 711
 			return $extra_eid[$eid]->getValueHTML();
712 712
 		}
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
 
731 731
 	function getComments()
732 732
 	{
733
-		if(!$this->getCommentCount()) return;
734
-		if(!$this->isGranted() && $this->isSecret()) return;
733
+		if (!$this->getCommentCount()) return;
734
+		if (!$this->isGranted() && $this->isSecret()) return;
735 735
 		// cpage is a number of comment pages
736 736
 		$cpageStr = sprintf('%d_cpage', $this->document_srl);
737 737
 		$cpage = Context::get($cpageStr);
738 738
 
739
-		if(!$cpage)
739
+		if (!$cpage)
740 740
 		{
741 741
 			$cpage = Context::get('cpage');
742 742
 		}
@@ -744,19 +744,19 @@  discard block
 block discarded – undo
744 744
 		// Get a list of comments
745 745
 		$oCommentModel = getModel('comment');
746 746
 		$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
747
-		if(!$output->toBool() || !count($output->data)) return;
747
+		if (!$output->toBool() || !count($output->data)) return;
748 748
 		// Create commentItem object from a comment list
749 749
 		// If admin priviledge is granted on parent posts, you can read its child posts.
750 750
 		$accessible = array();
751 751
 		$comment_list = array();
752
-		foreach($output->data as $key => $val)
752
+		foreach ($output->data as $key => $val)
753 753
 		{
754 754
 			$oCommentItem = new commentItem();
755 755
 			$oCommentItem->setAttribute($val);
756 756
 			// If permission is granted to the post, you can access it temporarily
757
-			if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
757
+			if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
758 758
 			// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
759
-			if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
759
+			if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true)
760 760
 			{
761 761
 				$oCommentItem->setAccessible();
762 762
 			}
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 		// Variable setting to be displayed on the skin
766 766
 		Context::set($cpageStr, $output->page_navigation->cur_page);
767 767
 		Context::set('cpage', $output->page_navigation->cur_page);
768
-		if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation;
768
+		if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation;
769 769
 
770 770
 		return $comment_list;
771 771
 	}
@@ -777,9 +777,9 @@  discard block
 block discarded – undo
777 777
 
778 778
 	function getTrackbacks()
779 779
 	{
780
-		if(!$this->document_srl) return;
780
+		if (!$this->document_srl) return;
781 781
 
782
-		if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
782
+		if (!$this->allowTrackback() || !$this->get('trackback_count')) return;
783 783
 
784 784
 		$oTrackbackModel = getModel('trackback');
785 785
 		return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
@@ -787,30 +787,30 @@  discard block
 block discarded – undo
787 787
 
788 788
 	function thumbnailExists($width = 80, $height = 0, $type = '')
789 789
 	{
790
-		if(!$this->document_srl) return false;
791
-		if(!$this->getThumbnail($width, $height, $type)) return false;
790
+		if (!$this->document_srl) return false;
791
+		if (!$this->getThumbnail($width, $height, $type)) return false;
792 792
 		return true;
793 793
 	}
794 794
 
795 795
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
796 796
 	{
797 797
 		// Return false if the document doesn't exist
798
-		if(!$this->document_srl) return;
798
+		if (!$this->document_srl) return;
799 799
 
800
-		if($this->isSecret() && !$this->isGranted())
800
+		if ($this->isSecret() && !$this->isGranted())
801 801
 		{
802 802
 			return;
803 803
 		}
804 804
 
805 805
 		// If not specify its height, create a square
806
-		if(!$height) $height = $width;
806
+		if (!$height) $height = $width;
807 807
 		// Return false if neither attachement nor image files in the document
808
-		if(!$this->get('uploaded_count') && !preg_match("!<img!is", $this->get('content'))) return;
808
+		if (!$this->get('uploaded_count') && !preg_match("!<img!is", $this->get('content'))) return;
809 809
 		// Get thumbnai_type information from document module's configuration
810
-		if(!in_array($thumbnail_type, array('crop','ratio')))
810
+		if (!in_array($thumbnail_type, array('crop', 'ratio')))
811 811
 		{
812 812
 			$config = $GLOBALS['__document_config__'];
813
-			if(!$config)
813
+			if (!$config)
814 814
 			{
815 815
 				$oDocumentModel = getModel('document');
816 816
 				$config = $oDocumentModel->getDocumentConfig();
@@ -819,13 +819,13 @@  discard block
 block discarded – undo
819 819
 			$thumbnail_type = $config->thumbnail_type;
820 820
 		}
821 821
 		// Define thumbnail information
822
-		$thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3));
822
+		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3));
823 823
 		$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
824
-		$thumbnail_url  = Context::getRequestUri().$thumbnail_file;
824
+		$thumbnail_url  = Context::getRequestUri() . $thumbnail_file;
825 825
 		// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
826
-		if(file_exists($thumbnail_file))
826
+		if (file_exists($thumbnail_file))
827 827
 		{
828
-			if(filesize($thumbnail_file)<1) return false;
828
+			if (filesize($thumbnail_file) < 1) return false;
829 829
 			else return $thumbnail_url;
830 830
 		}
831 831
 
@@ -834,62 +834,62 @@  discard block
 block discarded – undo
834 834
 		$is_tmp_file = false;
835 835
 
836 836
 		// Find an iamge file among attached files if exists
837
-		if($this->hasUploadedFiles())
837
+		if ($this->hasUploadedFiles())
838 838
 		{
839 839
 			$file_list = $this->getUploadedFiles();
840 840
 
841 841
 			$first_image = null;
842
-			foreach($file_list as $file)
842
+			foreach ($file_list as $file)
843 843
 			{
844
-				if($file->direct_download !== 'Y') continue;
844
+				if ($file->direct_download !== 'Y') continue;
845 845
 
846
-				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
846
+				if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
847 847
 				{
848 848
 					$source_file = $file->uploaded_filename;
849 849
 					break;
850 850
 				}
851 851
 
852
-				if($first_image) continue;
852
+				if ($first_image) continue;
853 853
 
854
-				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
854
+				if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
855 855
 				{
856
-					if(file_exists($file->uploaded_filename))
856
+					if (file_exists($file->uploaded_filename))
857 857
 					{
858 858
 						$first_image = $file->uploaded_filename;
859 859
 					}
860 860
 				}
861 861
 			}
862 862
 
863
-			if(!$source_file && $first_image)
863
+			if (!$source_file && $first_image)
864 864
 			{
865 865
 				$source_file = $first_image;
866 866
 			}
867 867
 		}
868 868
 
869 869
 		// If not exists, file an image file from the content
870
-		if(!$source_file)
870
+		if (!$source_file)
871 871
 		{
872 872
 			$content = $this->get('content');
873 873
 			$target_src = null;
874 874
 			preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER);
875 875
 			$cnt = count($matches);
876
-			for($i=0;$i<$cnt;$i++)
876
+			for ($i = 0; $i < $cnt; $i++)
877 877
 			{
878 878
 				$target_src = trim($matches[$i][2]);
879
-				if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$target_src)) continue;
880
-				if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue;
879
+				if (!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i", $target_src)) continue;
880
+				if (preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue;
881 881
 				else
882 882
 				{
883
-					if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src;
883
+					if (!preg_match('/^(http|https):\/\//i', $target_src)) $target_src = Context::getRequestUri() . $target_src;
884 884
 
885
-					$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->document_srl));
886
-					if(!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp');
885
+					$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111, 999999) . $this->document_srl));
886
+					if (!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp');
887 887
 					FileHandler::getRemoteFile($target_src, $tmp_file);
888
-					if(!file_exists($tmp_file)) continue;
888
+					if (!file_exists($tmp_file)) continue;
889 889
 					else
890 890
 					{
891 891
 						list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file);
892
-						if($_w<$width || $_h<$height) continue;
892
+						if ($_w < $width || $_h < $height) continue;
893 893
 
894 894
 						$source_file = $tmp_file;
895 895
 						$is_tmp_file = true;
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 			}
900 900
 		}
901 901
 
902
-		if($source_file)
902
+		if ($source_file)
903 903
 		{
904 904
 			$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
905 905
 		}
906
-		if($is_tmp_file) FileHandler::removeFile($source_file);
906
+		if ($is_tmp_file) FileHandler::removeFile($source_file);
907 907
 		// Return its path if a thumbnail is successfully genetated
908
-		if($output) return $thumbnail_url;
908
+		if ($output) return $thumbnail_url;
909 909
 		// Create an empty file not to re-generate the thumbnail
910
-		else FileHandler::writeFile($thumbnail_file, '','w');
910
+		else FileHandler::writeFile($thumbnail_file, '', 'w');
911 911
 
912 912
 		return;
913 913
 	}
@@ -920,21 +920,21 @@  discard block
 block discarded – undo
920 920
 	 */
921 921
 	function getExtraImages($time_interval = 43200)
922 922
 	{
923
-		if(!$this->document_srl) return;
923
+		if (!$this->document_srl) return;
924 924
 		// variables for icon list
925 925
 		$buffs = array();
926 926
 
927 927
 		$check_files = false;
928 928
 
929 929
 		// Check if secret post is
930
-		if($this->isSecret()) $buffs[] = "secret";
930
+		if ($this->isSecret()) $buffs[] = "secret";
931 931
 
932 932
 		// Set the latest time
933
-		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval);
933
+		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval);
934 934
 
935 935
 		// Check new post
936
-		if($this->get('regdate')>$time_check) $buffs[] = "new";
937
-		else if($this->get('last_update')>$time_check) $buffs[] = "update";
936
+		if ($this->get('regdate') > $time_check) $buffs[] = "new";
937
+		else if ($this->get('last_update') > $time_check) $buffs[] = "update";
938 938
 
939 939
 		/*
940 940
 		   $content = $this->get('content');
@@ -957,14 +957,14 @@  discard block
 block discarded – undo
957 957
 		 */
958 958
 
959 959
 		// Check the attachment
960
-		if($this->hasUploadedFiles()) $buffs[] = "file";
960
+		if ($this->hasUploadedFiles()) $buffs[] = "file";
961 961
 
962 962
 		return $buffs;
963 963
 	}
964 964
 
965 965
 	function getStatus()
966 966
 	{
967
-		if(!$this->get('status')) return $this->getDefaultStatus();
967
+		if (!$this->get('status')) return $this->getDefaultStatus();
968 968
 		return $this->get('status');
969 969
 	}
970 970
 
@@ -975,15 +975,15 @@  discard block
 block discarded – undo
975 975
 	 */
976 976
 	function printExtraImages($time_check = 43200)
977 977
 	{
978
-		if(!$this->document_srl) return;
978
+		if (!$this->document_srl) return;
979 979
 		// Get the icon directory
980
-		$path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/');
980
+		$path = sprintf('%s%s', getUrl(), 'modules/document/tpl/icons/');
981 981
 
982 982
 		$buffs = $this->getExtraImages($time_check);
983
-		if(!count($buffs)) return;
983
+		if (!count($buffs)) return;
984 984
 
985 985
 		$buff = array();
986
-		foreach($buffs as $key => $val)
986
+		foreach ($buffs as $key => $val)
987 987
 		{
988 988
 			$buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val);
989 989
 		}
@@ -992,20 +992,20 @@  discard block
 block discarded – undo
992 992
 
993 993
 	function hasUploadedFiles()
994 994
 	{
995
-		if(!$this->document_srl) return;
995
+		if (!$this->document_srl) return;
996 996
 
997
-		if($this->isSecret() && !$this->isGranted()) return false;
998
-		return $this->get('uploaded_count')? true : false;
997
+		if ($this->isSecret() && !$this->isGranted()) return false;
998
+		return $this->get('uploaded_count') ? true : false;
999 999
 	}
1000 1000
 
1001 1001
 	function getUploadedFiles($sortIndex = 'file_srl')
1002 1002
 	{
1003
-		if(!$this->document_srl) return;
1003
+		if (!$this->document_srl) return;
1004 1004
 
1005
-		if($this->isSecret() && !$this->isGranted()) return;
1006
-		if(!$this->get('uploaded_count')) return;
1005
+		if ($this->isSecret() && !$this->isGranted()) return;
1006
+		if (!$this->get('uploaded_count')) return;
1007 1007
 
1008
-		if(!$this->uploadedFiles[$sortIndex])
1008
+		if (!$this->uploadedFiles[$sortIndex])
1009 1009
 		{
1010 1010
 			$oFileModel = getModel('file');
1011 1011
 			$this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true);
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 	function getEditor()
1022 1022
 	{
1023 1023
 		$module_srl = $this->get('module_srl');
1024
-		if(!$module_srl) $module_srl = Context::get('module_srl');
1024
+		if (!$module_srl) $module_srl = Context::get('module_srl');
1025 1025
 
1026 1026
 		$oEditorModel = getModel('editor');
1027 1027
 		return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 	{
1037 1037
 		// Return false if not authorized, if a secret document, if the document is set not to allow any comment
1038 1038
 		if (!$this->allowComment()) return false;
1039
-		if(!$this->isGranted() && $this->isSecret()) return false;
1039
+		if (!$this->isGranted() && $this->isSecret()) return false;
1040 1040
 
1041 1041
 		return true;
1042 1042
 	}
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 	 */
1048 1048
 	function getCommentEditor()
1049 1049
 	{
1050
-		if(!$this->isEnableComment()) return;
1050
+		if (!$this->isEnableComment()) return;
1051 1051
 
1052 1052
 		$oEditorModel = getModel('editor');
1053 1053
 		return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content');
@@ -1059,10 +1059,10 @@  discard block
 block discarded – undo
1059 1059
 	 */
1060 1060
 	function getProfileImage()
1061 1061
 	{
1062
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1062
+		if (!$this->isExists() || !$this->get('member_srl')) return;
1063 1063
 		$oMemberModel = getModel('member');
1064 1064
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
1065
-		if(!$profile_info) return;
1065
+		if (!$profile_info) return;
1066 1066
 
1067 1067
 		return $profile_info->src;
1068 1068
 	}
@@ -1074,21 +1074,21 @@  discard block
 block discarded – undo
1074 1074
 	function getSignature()
1075 1075
 	{
1076 1076
 		// Pass if a document doesn't exist
1077
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1077
+		if (!$this->isExists() || !$this->get('member_srl')) return;
1078 1078
 		// Get signature information
1079 1079
 		$oMemberModel = getModel('member');
1080 1080
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
1081 1081
 		// Check if a maximum height of signiture is set in the member module
1082
-		if(!isset($GLOBALS['__member_signature_max_height']))
1082
+		if (!isset($GLOBALS['__member_signature_max_height']))
1083 1083
 		{
1084 1084
 			$oModuleModel = getModel('module');
1085 1085
 			$member_config = $oModuleModel->getModuleConfig('member');
1086 1086
 			$GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height;
1087 1087
 		}
1088
-		if($signature)
1088
+		if ($signature)
1089 1089
 		{
1090 1090
 			$max_signature_height = $GLOBALS['__member_signature_max_height'];
1091
-			if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1091
+			if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1092 1092
 		}
1093 1093
 
1094 1094
 		return $signature;
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 	 */
1102 1102
 	function replaceResourceRealPath($matches)
1103 1103
 	{
1104
-		return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]);
1104
+		return preg_replace('/src=(["\']?)files/i', 'src=$1' . Context::getRequestUri() . 'files', $matches[0]);
1105 1105
 	}
1106 1106
 
1107 1107
 	/**
@@ -1112,19 +1112,19 @@  discard block
 block discarded – undo
1112 1112
 	function _checkAccessibleFromStatus()
1113 1113
 	{
1114 1114
 		$logged_info = Context::get('logged_info');
1115
-		if($logged_info->is_admin == 'Y') return true;
1115
+		if ($logged_info->is_admin == 'Y') return true;
1116 1116
 
1117 1117
 		$status = $this->get('status');
1118
-		if(empty($status)) return false;
1118
+		if (empty($status)) return false;
1119 1119
 
1120 1120
 		$oDocumentModel = getModel('document');
1121 1121
 		$configStatusList = $oDocumentModel->getStatusList();
1122 1122
 
1123
-		if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1123
+		if ($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1124 1124
 			return true;
1125
-		else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1125
+		else if ($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1126 1126
 		{
1127
-			if($this->get('member_srl') == $logged_info->member_srl)
1127
+			if ($this->get('member_srl') == $logged_info->member_srl)
1128 1128
 				return true;
1129 1129
 		}
1130 1130
 		return false;
Please login to merge, or discard this patch.
Braces   +288 added lines, -119 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	function _loadFromDB($load_extra_vars = true)
76 76
 	{
77
-		if(!$this->document_srl) return;
77
+		if(!$this->document_srl) {
78
+			return;
79
+		}
78 80
 
79 81
 		$document_item = false;
80 82
 		$cache_put = false;
@@ -106,8 +108,7 @@  discard block
 block discarded – undo
106 108
 			{
107 109
 				$oCacheHandler->put($cache_key, $document_item);
108 110
 			}
109
-		}
110
-		else
111
+		} else
111 112
 		{
112 113
 			$document_item->readed_count = $output->data->readed_count;
113 114
 			$document_item->voted_count = $output->data->voted_count;
@@ -154,18 +155,28 @@  discard block
 block discarded – undo
154 155
 
155 156
 	function isGranted()
156 157
 	{
157
-		if($_SESSION['own_document'][$this->document_srl]) return true;
158
+		if($_SESSION['own_document'][$this->document_srl]) {
159
+			return true;
160
+		}
158 161
 
159
-		if(!Context::get('is_logged')) return false;
162
+		if(!Context::get('is_logged')) {
163
+			return false;
164
+		}
160 165
 
161 166
 		$logged_info = Context::get('logged_info');
162
-		if($logged_info->is_admin == 'Y') return true;
167
+		if($logged_info->is_admin == 'Y') {
168
+			return true;
169
+		}
163 170
 
164 171
 		$oModuleModel = getModel('module');
165 172
 		$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
166
-		if($grant->manager) return true;
173
+		if($grant->manager) {
174
+			return true;
175
+		}
167 176
 
168
-		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true;
177
+		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) {
178
+			return true;
179
+		}
169 180
 
170 181
 		return false;
171 182
 	}
@@ -183,7 +194,9 @@  discard block
 block discarded – undo
183 194
 	function allowComment()
184 195
 	{
185 196
 		// init write, document is not exists. so allow comment status is true
186
-		if(!$this->isExists()) return true;
197
+		if(!$this->isExists()) {
198
+			return true;
199
+		}
187 200
 
188 201
 		return $this->get('comment_status') == 'ALLOW' ? true : false;
189 202
 	}
@@ -198,8 +211,7 @@  discard block
 block discarded – undo
198 211
 			if(!getClass('trackback'))
199 212
 			{
200 213
 				$allow_trackback_status = false;
201
-			}
202
-			else
214
+			} else
203 215
 			{
204 216
 				// If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module.
205 217
 				$oModuleModel = getModel('module');
@@ -210,15 +222,21 @@  discard block
 block discarded – undo
210 222
 					$trackback_config = new stdClass();
211 223
 				}
212 224
 				
213
-				if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
214
-				if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
215
-				else
225
+				if(!isset($trackback_config->enable_trackback)) {
226
+					$trackback_config->enable_trackback = 'Y';
227
+				}
228
+				if($trackback_config->enable_trackback != 'Y') {
229
+					$allow_trackback_status = false;
230
+				} else
216 231
 				{
217 232
 					$module_srl = $this->get('module_srl');
218 233
 					// Check settings of each module
219 234
 					$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
220
-					if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
221
-					else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
235
+					if($module_config->enable_trackback == 'N') {
236
+						$allow_trackback_status = false;
237
+					} else if($this->get('allow_trackback')=='Y' || !$this->isExists()) {
238
+						$allow_trackback_status = true;
239
+					}
222 240
 				}
223 241
 			}
224 242
 		}
@@ -227,14 +245,18 @@  discard block
 block discarded – undo
227 245
 
228 246
 	function isLocked()
229 247
 	{
230
-		if(!$this->isExists()) return false;
248
+		if(!$this->isExists()) {
249
+			return false;
250
+		}
231 251
 
232 252
 		return $this->get('comment_status') == 'ALLOW' ? false : true;
233 253
 	}
234 254
 
235 255
 	function isEditable()
236 256
 	{
237
-		if($this->isGranted() || !$this->get('member_srl')) return true;
257
+		if($this->isGranted() || !$this->get('member_srl')) {
258
+			return true;
259
+		}
238 260
 		return false;
239 261
 	}
240 262
 
@@ -256,9 +278,14 @@  discard block
 block discarded – undo
256 278
 
257 279
 	function doCart()
258 280
 	{
259
-		if(!$this->document_srl) return false;
260
-		if($this->isCarted()) $this->removeCart();
261
-		else $this->addCart();
281
+		if(!$this->document_srl) {
282
+			return false;
283
+		}
284
+		if($this->isCarted()) {
285
+			$this->removeCart();
286
+		} else {
287
+			$this->addCart();
288
+		}
262 289
 	}
263 290
 
264 291
 	function addCart()
@@ -284,16 +311,26 @@  discard block
 block discarded – undo
284 311
 	 */
285 312
 	function notify($type, $content)
286 313
 	{
287
-		if(!$this->document_srl) return;
314
+		if(!$this->document_srl) {
315
+			return;
316
+		}
288 317
 		// return if it is not useNotify
289
-		if(!$this->useNotify()) return;
318
+		if(!$this->useNotify()) {
319
+			return;
320
+		}
290 321
 		// Pass if an author is not a logged-in user
291
-		if(!$this->get('member_srl')) return;
322
+		if(!$this->get('member_srl')) {
323
+			return;
324
+		}
292 325
 		// Return if the currently logged-in user is an author
293 326
 		$logged_info = Context::get('logged_info');
294
-		if($logged_info->member_srl == $this->get('member_srl')) return;
327
+		if($logged_info->member_srl == $this->get('member_srl')) {
328
+			return;
329
+		}
295 330
 		// List variables
296
-		if($type) $title = "[".$type."] ";
331
+		if($type) {
332
+			$title = "[".$type."] ";
333
+		}
297 334
 		$title .= cut_str(strip_tags($content), 10, '...');
298 335
 		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
299 336
 		$receiver_srl = $this->get('member_srl');
@@ -320,16 +357,22 @@  discard block
 block discarded – undo
320 357
 
321 358
 	function isExistsHomepage()
322 359
 	{
323
-		if(trim($this->get('homepage'))) return true;
360
+		if(trim($this->get('homepage'))) {
361
+			return true;
362
+		}
324 363
 		return false;
325 364
 	}
326 365
 
327 366
 	function getHomepageUrl()
328 367
 	{
329 368
 		$url = trim($this->get('homepage'));
330
-		if(!$url) return;
369
+		if(!$url) {
370
+			return;
371
+		}
331 372
 
332
-		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
373
+		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) {
374
+			$url = 'http://' . $url;
375
+		}
333 376
 
334 377
 		return $url;
335 378
 	}
@@ -361,43 +404,65 @@  discard block
 block discarded – undo
361 404
 
362 405
 	function getTitleText($cut_size = 0, $tail='...')
363 406
 	{
364
-		if(!$this->document_srl) return;
407
+		if(!$this->document_srl) {
408
+			return;
409
+		}
365 410
 
366
-		if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
367
-		else $title = $this->get('title');
411
+		if($cut_size) {
412
+			$title = cut_str($this->get('title'), $cut_size, $tail);
413
+		} else {
414
+			$title = $this->get('title');
415
+		}
368 416
 
369 417
 		return $title;
370 418
 	}
371 419
 
372 420
 	function getTitle($cut_size = 0, $tail='...')
373 421
 	{
374
-		if(!$this->document_srl) return;
422
+		if(!$this->document_srl) {
423
+			return;
424
+		}
375 425
 
376 426
 		$title = $this->getTitleText($cut_size, $tail);
377 427
 
378 428
 		$attrs = array();
379 429
 		$this->add('title_color', trim($this->get('title_color')));
380
-		if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
381
-		if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
430
+		if($this->get('title_bold')=='Y') {
431
+			$attrs[] = "font-weight:bold;";
432
+		}
433
+		if($this->get('title_color') && $this->get('title_color') != 'N') {
434
+			$attrs[] = "color:#".$this->get('title_color');
435
+		}
382 436
 
383
-		if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
384
-		else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
437
+		if(count($attrs)) {
438
+			return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
439
+		} else {
440
+			return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
441
+		}
385 442
 	}
386 443
 
387 444
 	function getContentText($strlen = 0)
388 445
 	{
389
-		if(!$this->document_srl) return;
446
+		if(!$this->document_srl) {
447
+			return;
448
+		}
390 449
 
391
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
450
+		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) {
451
+			return Context::getLang('msg_is_secret');
452
+		}
392 453
 
393 454
 		$result = $this->_checkAccessibleFromStatus();
394
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
455
+		if($result) {
456
+			$_SESSION['accessible'][$this->document_srl] = true;
457
+		}
395 458
 
396 459
 		$content = $this->get('content');
397 460
 		$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
398 461
 		$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
399 462
 
400
-		if($strlen) return cut_str(strip_tags($content),$strlen,'...');
463
+		if($strlen) {
464
+			return cut_str(strip_tags($content),$strlen,'...');
465
+		}
401 466
 
402 467
 		return htmlspecialchars($content);
403 468
 	}
@@ -430,14 +495,12 @@  discard block
 block discarded – undo
430 495
 				}
431 496
 				$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
432 497
 			}
433
-		}
434
-		else if($m[1] == 'embed')
498
+		} else if($m[1] == 'embed')
435 499
 		{
436 500
 			if(stripos($m[0], 'allowscriptaccess'))
437 501
 			{
438 502
 				$m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]);
439
-			}
440
-			else
503
+			} else
441 504
 			{
442 505
 				$m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]);
443 506
 			}
@@ -447,15 +510,23 @@  discard block
 block discarded – undo
447 510
 
448 511
 	function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
449 512
 	{
450
-		if(!$this->document_srl) return;
513
+		if(!$this->document_srl) {
514
+			return;
515
+		}
451 516
 
452
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
517
+		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) {
518
+			return Context::getLang('msg_is_secret');
519
+		}
453 520
 
454 521
 		$result = $this->_checkAccessibleFromStatus();
455
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
522
+		if($result) {
523
+			$_SESSION['accessible'][$this->document_srl] = true;
524
+		}
456 525
 
457 526
 		$content = $this->get('content');
458
-		if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
527
+		if(!$stripEmbedTagException) {
528
+			stripEmbedTagForAdmin($content, $this->get('member_srl'));
529
+		}
459 530
 
460 531
 		// Define a link if using a rewrite module
461 532
 		$oContext = &Context::getInstance();
@@ -489,10 +560,11 @@  discard block
 block discarded – undo
489 560
 				$this->document_srl, $memberSrl
490 561
 			);
491 562
 			// Add xe_content class although accessing content is not required
492
-		}
493
-		else
563
+		} else
494 564
 		{
495
-			if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
565
+			if($add_xe_content_class) {
566
+				$content = sprintf('<div class="xe_content">%s</div>', $content);
567
+			}
496 568
 		}
497 569
 		// Change the image path to a valid absolute path if resource_realpath is true
498 570
 		if($resource_realpath)
@@ -611,11 +683,15 @@  discard block
 block discarded – undo
611 683
 
612 684
 	function getTrackbackUrl()
613 685
 	{
614
-		if(!$this->document_srl) return;
686
+		if(!$this->document_srl) {
687
+			return;
688
+		}
615 689
 
616 690
 		// Generate a key to prevent spams
617 691
 		$oTrackbackModel = getModel('trackback');
618
-		if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
692
+		if($oTrackbackModel) {
693
+			return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
694
+		}
619 695
 	}
620 696
 
621 697
 	/**
@@ -634,7 +710,9 @@  discard block
 block discarded – undo
634 710
 
635 711
 	function isExtraVarsExists()
636 712
 	{
637
-		if(!$this->get('module_srl')) return false;
713
+		if(!$this->get('module_srl')) {
714
+			return false;
715
+		}
638 716
 		$oDocumentModel = getModel('document');
639 717
 		$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
640 718
 		return count($extra_keys)?true:false;
@@ -642,7 +720,9 @@  discard block
 block discarded – undo
642 720
 
643 721
 	function getExtraVars()
644 722
 	{
645
-		if(!$this->get('module_srl') || !$this->document_srl) return null;
723
+		if(!$this->get('module_srl') || !$this->document_srl) {
724
+			return null;
725
+		}
646 726
 
647 727
 		$oDocumentModel = getModel('document');
648 728
 		return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
@@ -654,8 +734,7 @@  discard block
 block discarded – undo
654 734
 		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
655 735
 		{
656 736
 			return $extra_vars[$idx]->getValue();
657
-		}
658
-		else
737
+		} else
659 738
 		{
660 739
 			return '';
661 740
 		}
@@ -667,8 +746,7 @@  discard block
 block discarded – undo
667 746
 		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
668 747
 		{
669 748
 			return $extra_vars[$idx]->getValueHTML();
670
-		}
671
-		else
749
+		} else
672 750
 		{
673 751
 			return '';
674 752
 		}
@@ -690,8 +768,7 @@  discard block
 block discarded – undo
690 768
 		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
691 769
 		{
692 770
 			return $extra_eid[$eid]->getValue();
693
-		}
694
-		else
771
+		} else
695 772
 		{
696 773
 			return '';
697 774
 		}
@@ -709,8 +786,7 @@  discard block
 block discarded – undo
709 786
 		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
710 787
 		{
711 788
 			return $extra_eid[$eid]->getValueHTML();
712
-		}
713
-		else
789
+		} else
714 790
 		{
715 791
 			return '';
716 792
 		}
@@ -730,8 +806,12 @@  discard block
 block discarded – undo
730 806
 
731 807
 	function getComments()
732 808
 	{
733
-		if(!$this->getCommentCount()) return;
734
-		if(!$this->isGranted() && $this->isSecret()) return;
809
+		if(!$this->getCommentCount()) {
810
+			return;
811
+		}
812
+		if(!$this->isGranted() && $this->isSecret()) {
813
+			return;
814
+		}
735 815
 		// cpage is a number of comment pages
736 816
 		$cpageStr = sprintf('%d_cpage', $this->document_srl);
737 817
 		$cpage = Context::get($cpageStr);
@@ -744,7 +824,9 @@  discard block
 block discarded – undo
744 824
 		// Get a list of comments
745 825
 		$oCommentModel = getModel('comment');
746 826
 		$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
747
-		if(!$output->toBool() || !count($output->data)) return;
827
+		if(!$output->toBool() || !count($output->data)) {
828
+			return;
829
+		}
748 830
 		// Create commentItem object from a comment list
749 831
 		// If admin priviledge is granted on parent posts, you can read its child posts.
750 832
 		$accessible = array();
@@ -754,7 +836,9 @@  discard block
 block discarded – undo
754 836
 			$oCommentItem = new commentItem();
755 837
 			$oCommentItem->setAttribute($val);
756 838
 			// If permission is granted to the post, you can access it temporarily
757
-			if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
839
+			if($oCommentItem->isGranted()) {
840
+				$accessible[$val->comment_srl] = true;
841
+			}
758 842
 			// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
759 843
 			if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
760 844
 			{
@@ -765,7 +849,9 @@  discard block
 block discarded – undo
765 849
 		// Variable setting to be displayed on the skin
766 850
 		Context::set($cpageStr, $output->page_navigation->cur_page);
767 851
 		Context::set('cpage', $output->page_navigation->cur_page);
768
-		if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation;
852
+		if($output->total_page>1) {
853
+			$this->comment_page_navigation = $output->page_navigation;
854
+		}
769 855
 
770 856
 		return $comment_list;
771 857
 	}
@@ -777,9 +863,13 @@  discard block
 block discarded – undo
777 863
 
778 864
 	function getTrackbacks()
779 865
 	{
780
-		if(!$this->document_srl) return;
866
+		if(!$this->document_srl) {
867
+			return;
868
+		}
781 869
 
782
-		if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
870
+		if(!$this->allowTrackback() || !$this->get('trackback_count')) {
871
+			return;
872
+		}
783 873
 
784 874
 		$oTrackbackModel = getModel('trackback');
785 875
 		return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
@@ -787,15 +877,21 @@  discard block
 block discarded – undo
787 877
 
788 878
 	function thumbnailExists($width = 80, $height = 0, $type = '')
789 879
 	{
790
-		if(!$this->document_srl) return false;
791
-		if(!$this->getThumbnail($width, $height, $type)) return false;
880
+		if(!$this->document_srl) {
881
+			return false;
882
+		}
883
+		if(!$this->getThumbnail($width, $height, $type)) {
884
+			return false;
885
+		}
792 886
 		return true;
793 887
 	}
794 888
 
795 889
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
796 890
 	{
797 891
 		// Return false if the document doesn't exist
798
-		if(!$this->document_srl) return;
892
+		if(!$this->document_srl) {
893
+			return;
894
+		}
799 895
 
800 896
 		if($this->isSecret() && !$this->isGranted())
801 897
 		{
@@ -803,9 +899,13 @@  discard block
 block discarded – undo
803 899
 		}
804 900
 
805 901
 		// If not specify its height, create a square
806
-		if(!$height) $height = $width;
902
+		if(!$height) {
903
+			$height = $width;
904
+		}
807 905
 		// Return false if neither attachement nor image files in the document
808
-		if(!$this->get('uploaded_count') && !preg_match("!<img!is", $this->get('content'))) return;
906
+		if(!$this->get('uploaded_count') && !preg_match("!<img!is", $this->get('content'))) {
907
+			return;
908
+		}
809 909
 		// Get thumbnai_type information from document module's configuration
810 910
 		if(!in_array($thumbnail_type, array('crop','ratio')))
811 911
 		{
@@ -825,8 +925,11 @@  discard block
 block discarded – undo
825 925
 		// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
826 926
 		if(file_exists($thumbnail_file))
827 927
 		{
828
-			if(filesize($thumbnail_file)<1) return false;
829
-			else return $thumbnail_url;
928
+			if(filesize($thumbnail_file)<1) {
929
+				return false;
930
+			} else {
931
+				return $thumbnail_url;
932
+			}
830 933
 		}
831 934
 
832 935
 		// Target File
@@ -841,7 +944,9 @@  discard block
 block discarded – undo
841 944
 			$first_image = null;
842 945
 			foreach($file_list as $file)
843 946
 			{
844
-				if($file->direct_download !== 'Y') continue;
947
+				if($file->direct_download !== 'Y') {
948
+					continue;
949
+				}
845 950
 
846 951
 				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
847 952
 				{
@@ -849,7 +954,9 @@  discard block
 block discarded – undo
849 954
 					break;
850 955
 				}
851 956
 
852
-				if($first_image) continue;
957
+				if($first_image) {
958
+					continue;
959
+				}
853 960
 
854 961
 				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
855 962
 				{
@@ -876,20 +983,30 @@  discard block
 block discarded – undo
876 983
 			for($i=0;$i<$cnt;$i++)
877 984
 			{
878 985
 				$target_src = trim($matches[$i][2]);
879
-				if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$target_src)) continue;
880
-				if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue;
881
-				else
986
+				if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$target_src)) {
987
+					continue;
988
+				}
989
+				if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) {
990
+					continue;
991
+				} else
882 992
 				{
883
-					if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src;
993
+					if(!preg_match('/^(http|https):\/\//i',$target_src)) {
994
+						$target_src = Context::getRequestUri().$target_src;
995
+					}
884 996
 
885 997
 					$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->document_srl));
886
-					if(!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp');
998
+					if(!is_dir('./files/cache/tmp')) {
999
+						FileHandler::makeDir('./files/cache/tmp');
1000
+					}
887 1001
 					FileHandler::getRemoteFile($target_src, $tmp_file);
888
-					if(!file_exists($tmp_file)) continue;
889
-					else
1002
+					if(!file_exists($tmp_file)) {
1003
+						continue;
1004
+					} else
890 1005
 					{
891 1006
 						list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file);
892
-						if($_w<$width || $_h<$height) continue;
1007
+						if($_w<$width || $_h<$height) {
1008
+							continue;
1009
+						}
893 1010
 
894 1011
 						$source_file = $tmp_file;
895 1012
 						$is_tmp_file = true;
@@ -903,11 +1020,17 @@  discard block
 block discarded – undo
903 1020
 		{
904 1021
 			$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
905 1022
 		}
906
-		if($is_tmp_file) FileHandler::removeFile($source_file);
1023
+		if($is_tmp_file) {
1024
+			FileHandler::removeFile($source_file);
1025
+		}
907 1026
 		// Return its path if a thumbnail is successfully genetated
908
-		if($output) return $thumbnail_url;
1027
+		if($output) {
1028
+			return $thumbnail_url;
1029
+		}
909 1030
 		// Create an empty file not to re-generate the thumbnail
910
-		else FileHandler::writeFile($thumbnail_file, '','w');
1031
+		else {
1032
+			FileHandler::writeFile($thumbnail_file, '','w');
1033
+		}
911 1034
 
912 1035
 		return;
913 1036
 	}
@@ -920,21 +1043,28 @@  discard block
 block discarded – undo
920 1043
 	 */
921 1044
 	function getExtraImages($time_interval = 43200)
922 1045
 	{
923
-		if(!$this->document_srl) return;
1046
+		if(!$this->document_srl) {
1047
+			return;
1048
+		}
924 1049
 		// variables for icon list
925 1050
 		$buffs = array();
926 1051
 
927 1052
 		$check_files = false;
928 1053
 
929 1054
 		// Check if secret post is
930
-		if($this->isSecret()) $buffs[] = "secret";
1055
+		if($this->isSecret()) {
1056
+			$buffs[] = "secret";
1057
+		}
931 1058
 
932 1059
 		// Set the latest time
933 1060
 		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval);
934 1061
 
935 1062
 		// Check new post
936
-		if($this->get('regdate')>$time_check) $buffs[] = "new";
937
-		else if($this->get('last_update')>$time_check) $buffs[] = "update";
1063
+		if($this->get('regdate')>$time_check) {
1064
+			$buffs[] = "new";
1065
+		} else if($this->get('last_update')>$time_check) {
1066
+			$buffs[] = "update";
1067
+		}
938 1068
 
939 1069
 		/*
940 1070
 		   $content = $this->get('content');
@@ -957,14 +1087,18 @@  discard block
 block discarded – undo
957 1087
 		 */
958 1088
 
959 1089
 		// Check the attachment
960
-		if($this->hasUploadedFiles()) $buffs[] = "file";
1090
+		if($this->hasUploadedFiles()) {
1091
+			$buffs[] = "file";
1092
+		}
961 1093
 
962 1094
 		return $buffs;
963 1095
 	}
964 1096
 
965 1097
 	function getStatus()
966 1098
 	{
967
-		if(!$this->get('status')) return $this->getDefaultStatus();
1099
+		if(!$this->get('status')) {
1100
+			return $this->getDefaultStatus();
1101
+		}
968 1102
 		return $this->get('status');
969 1103
 	}
970 1104
 
@@ -975,12 +1109,16 @@  discard block
 block discarded – undo
975 1109
 	 */
976 1110
 	function printExtraImages($time_check = 43200)
977 1111
 	{
978
-		if(!$this->document_srl) return;
1112
+		if(!$this->document_srl) {
1113
+			return;
1114
+		}
979 1115
 		// Get the icon directory
980 1116
 		$path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/');
981 1117
 
982 1118
 		$buffs = $this->getExtraImages($time_check);
983
-		if(!count($buffs)) return;
1119
+		if(!count($buffs)) {
1120
+			return;
1121
+		}
984 1122
 
985 1123
 		$buff = array();
986 1124
 		foreach($buffs as $key => $val)
@@ -992,18 +1130,28 @@  discard block
 block discarded – undo
992 1130
 
993 1131
 	function hasUploadedFiles()
994 1132
 	{
995
-		if(!$this->document_srl) return;
1133
+		if(!$this->document_srl) {
1134
+			return;
1135
+		}
996 1136
 
997
-		if($this->isSecret() && !$this->isGranted()) return false;
1137
+		if($this->isSecret() && !$this->isGranted()) {
1138
+			return false;
1139
+		}
998 1140
 		return $this->get('uploaded_count')? true : false;
999 1141
 	}
1000 1142
 
1001 1143
 	function getUploadedFiles($sortIndex = 'file_srl')
1002 1144
 	{
1003
-		if(!$this->document_srl) return;
1145
+		if(!$this->document_srl) {
1146
+			return;
1147
+		}
1004 1148
 
1005
-		if($this->isSecret() && !$this->isGranted()) return;
1006
-		if(!$this->get('uploaded_count')) return;
1149
+		if($this->isSecret() && !$this->isGranted()) {
1150
+			return;
1151
+		}
1152
+		if(!$this->get('uploaded_count')) {
1153
+			return;
1154
+		}
1007 1155
 
1008 1156
 		if(!$this->uploadedFiles[$sortIndex])
1009 1157
 		{
@@ -1021,7 +1169,9 @@  discard block
 block discarded – undo
1021 1169
 	function getEditor()
1022 1170
 	{
1023 1171
 		$module_srl = $this->get('module_srl');
1024
-		if(!$module_srl) $module_srl = Context::get('module_srl');
1172
+		if(!$module_srl) {
1173
+			$module_srl = Context::get('module_srl');
1174
+		}
1025 1175
 
1026 1176
 		$oEditorModel = getModel('editor');
1027 1177
 		return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
@@ -1035,8 +1185,12 @@  discard block
 block discarded – undo
1035 1185
 	function isEnableComment()
1036 1186
 	{
1037 1187
 		// Return false if not authorized, if a secret document, if the document is set not to allow any comment
1038
-		if (!$this->allowComment()) return false;
1039
-		if(!$this->isGranted() && $this->isSecret()) return false;
1188
+		if (!$this->allowComment()) {
1189
+			return false;
1190
+		}
1191
+		if(!$this->isGranted() && $this->isSecret()) {
1192
+			return false;
1193
+		}
1040 1194
 
1041 1195
 		return true;
1042 1196
 	}
@@ -1047,7 +1201,9 @@  discard block
 block discarded – undo
1047 1201
 	 */
1048 1202
 	function getCommentEditor()
1049 1203
 	{
1050
-		if(!$this->isEnableComment()) return;
1204
+		if(!$this->isEnableComment()) {
1205
+			return;
1206
+		}
1051 1207
 
1052 1208
 		$oEditorModel = getModel('editor');
1053 1209
 		return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content');
@@ -1059,10 +1215,14 @@  discard block
 block discarded – undo
1059 1215
 	 */
1060 1216
 	function getProfileImage()
1061 1217
 	{
1062
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1218
+		if(!$this->isExists() || !$this->get('member_srl')) {
1219
+			return;
1220
+		}
1063 1221
 		$oMemberModel = getModel('member');
1064 1222
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
1065
-		if(!$profile_info) return;
1223
+		if(!$profile_info) {
1224
+			return;
1225
+		}
1066 1226
 
1067 1227
 		return $profile_info->src;
1068 1228
 	}
@@ -1074,7 +1234,9 @@  discard block
 block discarded – undo
1074 1234
 	function getSignature()
1075 1235
 	{
1076 1236
 		// Pass if a document doesn't exist
1077
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1237
+		if(!$this->isExists() || !$this->get('member_srl')) {
1238
+			return;
1239
+		}
1078 1240
 		// Get signature information
1079 1241
 		$oMemberModel = getModel('member');
1080 1242
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
@@ -1088,7 +1250,9 @@  discard block
 block discarded – undo
1088 1250
 		if($signature)
1089 1251
 		{
1090 1252
 			$max_signature_height = $GLOBALS['__member_signature_max_height'];
1091
-			if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1253
+			if($max_signature_height) {
1254
+				$signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1255
+			}
1092 1256
 		}
1093 1257
 
1094 1258
 		return $signature;
@@ -1112,20 +1276,25 @@  discard block
 block discarded – undo
1112 1276
 	function _checkAccessibleFromStatus()
1113 1277
 	{
1114 1278
 		$logged_info = Context::get('logged_info');
1115
-		if($logged_info->is_admin == 'Y') return true;
1279
+		if($logged_info->is_admin == 'Y') {
1280
+			return true;
1281
+		}
1116 1282
 
1117 1283
 		$status = $this->get('status');
1118
-		if(empty($status)) return false;
1284
+		if(empty($status)) {
1285
+			return false;
1286
+		}
1119 1287
 
1120 1288
 		$oDocumentModel = getModel('document');
1121 1289
 		$configStatusList = $oDocumentModel->getStatusList();
1122 1290
 
1123
-		if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1124
-			return true;
1125
-		else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1291
+		if($status == $configStatusList['public'] || $status == $configStatusList['publish']) {
1292
+					return true;
1293
+		} else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1126 1294
 		{
1127
-			if($this->get('member_srl') == $logged_info->member_srl)
1128
-				return true;
1295
+			if($this->get('member_srl') == $logged_info->member_srl) {
1296
+							return true;
1297
+			}
1129 1298
 		}
1130 1299
 		return false;
1131 1300
 	}
Please login to merge, or discard this patch.