@@ -219,8 +219,8 @@ discard block |
||
| 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 |
||
| 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); |
@@ -24,19 +24,19 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 140 | 140 | $args->history_srl = $history_srl; |
| 141 | 141 | $args->module_srl = $module_srl; |
| 142 | 142 | $args->document_srl = $document_srl; |
| 143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 143 | + if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
| 144 | 144 | executeQuery("document.deleteHistory", $args); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | function triggerDeleteModuleDocuments(&$obj) |
| 153 | 153 | { |
| 154 | 154 | $module_srl = $obj->module_srl; |
| 155 | - if(!$module_srl) return new 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 276 | 276 | // If the tile is empty, extract string from the contents. |
| 277 | 277 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 278 | 278 | settype($obj->title, "string"); |
| 279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 279 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
| 280 | 280 | // If no tile extracted from the contents, leave it untitled. |
| 281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 281 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 282 | 282 | // Remove XE's own tags from the contents. |
| 283 | 283 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 284 | - if(Mobile::isFromMobilePhone()) |
|
| 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 |
||
| 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 |
||
| 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 |
||
| 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,24 +438,24 @@ discard block |
||
| 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 | |
| 454 | 454 | // If an author is identical to the modifier or history is used, use the logged-in user's information. |
| 455 | - if(Context::get('is_logged') && !$manual_updated) |
|
| 455 | + if (Context::get('is_logged') && !$manual_updated) |
|
| 456 | 456 | { |
| 457 | 457 | $logged_info = Context::get('logged_info'); |
| 458 | - if($source_obj->get('member_srl')==$logged_info->member_srl) |
|
| 458 | + if ($source_obj->get('member_srl') == $logged_info->member_srl) |
|
| 459 | 459 | { |
| 460 | 460 | $obj->member_srl = $logged_info->member_srl; |
| 461 | 461 | $obj->user_name = htmlspecialchars_decode($logged_info->user_name); |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // For the document written by logged-in user however no nick_name exists |
| 469 | - if($source_obj->get('member_srl')&& !$obj->nick_name) |
|
| 469 | + if ($source_obj->get('member_srl') && !$obj->nick_name) |
|
| 470 | 470 | { |
| 471 | 471 | $obj->member_srl = $source_obj->get('member_srl'); |
| 472 | 472 | $obj->user_name = $source_obj->get('user_name'); |
@@ -477,24 +477,24 @@ discard block |
||
| 477 | 477 | // If the tile is empty, extract string from the contents. |
| 478 | 478 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 479 | 479 | settype($obj->title, "string"); |
| 480 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
| 480 | + if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
| 481 | 481 | // If no tile extracted from the contents, leave it untitled. |
| 482 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 482 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 483 | 483 | // Remove XE's own tags from the contents. |
| 484 | 484 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
| 485 | - if(Mobile::isFromMobilePhone()) |
|
| 485 | + if (Mobile::isFromMobilePhone()) |
|
| 486 | 486 | { |
| 487 | - if($obj->use_html != 'Y') |
|
| 487 | + if ($obj->use_html != 'Y') |
|
| 488 | 488 | { |
| 489 | 489 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 490 | 490 | } |
| 491 | 491 | $obj->content = nl2br($obj->content); |
| 492 | 492 | } |
| 493 | 493 | // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. |
| 494 | - if($source_obj->get('lang_code') != Context::getLangType()) |
|
| 494 | + if ($source_obj->get('lang_code') != Context::getLangType()) |
|
| 495 | 495 | { |
| 496 | 496 | // Change not extra vars but language code of the original document if document's lang_code doesn't exist. |
| 497 | - if(!$source_obj->get('lang_code')) |
|
| 497 | + if (!$source_obj->get('lang_code')) |
|
| 498 | 498 | { |
| 499 | 499 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
| 500 | 500 | $lang_code_args->lang_code = Context::getLangType(); |
@@ -514,59 +514,59 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | // Remove iframe and script if not a top adminisrator in the session. |
| 517 | - if($logged_info->is_admin != 'Y') |
|
| 517 | + if ($logged_info->is_admin != 'Y') |
|
| 518 | 518 | { |
| 519 | 519 | $obj->content = removeHackTag($obj->content); |
| 520 | 520 | } |
| 521 | 521 | // if temporary document, regdate is now setting |
| 522 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 522 | + if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
| 523 | 523 | |
| 524 | 524 | // Insert data into the DB |
| 525 | 525 | $output = executeQuery('document.updateDocument', $obj); |
| 526 | - if(!$output->toBool()) |
|
| 526 | + if (!$output->toBool()) |
|
| 527 | 527 | { |
| 528 | 528 | $oDB->rollback(); |
| 529 | 529 | return $output; |
| 530 | 530 | } |
| 531 | 531 | // Remove all extra variables |
| 532 | - if(Context::get('act')!='procFileDelete') |
|
| 532 | + if (Context::get('act') != 'procFileDelete') |
|
| 533 | 533 | { |
| 534 | 534 | $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType()); |
| 535 | 535 | // Insert extra variables if the document successfully inserted. |
| 536 | 536 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
| 537 | - if(count($extra_keys)) |
|
| 537 | + if (count($extra_keys)) |
|
| 538 | 538 | { |
| 539 | - foreach($extra_keys as $idx => $extra_item) |
|
| 539 | + foreach ($extra_keys as $idx => $extra_item) |
|
| 540 | 540 | { |
| 541 | 541 | $value = NULL; |
| 542 | - if(isset($obj->{'extra_vars'.$idx})) |
|
| 542 | + if (isset($obj->{'extra_vars' . $idx})) |
|
| 543 | 543 | { |
| 544 | - $tmp = $obj->{'extra_vars'.$idx}; |
|
| 545 | - if(is_array($tmp)) |
|
| 544 | + $tmp = $obj->{'extra_vars' . $idx}; |
|
| 545 | + if (is_array($tmp)) |
|
| 546 | 546 | $value = implode('|@|', $tmp); |
| 547 | 547 | else |
| 548 | 548 | $value = trim($tmp); |
| 549 | 549 | } |
| 550 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 551 | - if($value == NULL) continue; |
|
| 550 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
| 551 | + if ($value == NULL) continue; |
|
| 552 | 552 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | // Inert extra vars for multi-language support of title and contents. |
| 556 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
| 557 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
| 556 | + if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_' . Context::getLangType()); |
|
| 557 | + if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_' . Context::getLangType()); |
|
| 558 | 558 | } |
| 559 | 559 | // Update the category if the category_srl exists. |
| 560 | - if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
| 560 | + if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
| 561 | 561 | { |
| 562 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 563 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 562 | + if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
| 563 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
| 564 | 564 | } |
| 565 | 565 | // Call a trigger (after) |
| 566 | - if($output->toBool()) |
|
| 566 | + if ($output->toBool()) |
|
| 567 | 567 | { |
| 568 | 568 | $trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); |
| 569 | - if(!$trigger_output->toBool()) |
|
| 569 | + if (!$trigger_output->toBool()) |
|
| 570 | 570 | { |
| 571 | 571 | $oDB->rollback(); |
| 572 | 572 | return $trigger_output; |
@@ -576,15 +576,15 @@ discard block |
||
| 576 | 576 | // commit |
| 577 | 577 | $oDB->commit(); |
| 578 | 578 | // Remove the thumbnail file |
| 579 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
| 579 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
| 580 | 580 | |
| 581 | - $output->add('document_srl',$obj->document_srl); |
|
| 581 | + $output->add('document_srl', $obj->document_srl); |
|
| 582 | 582 | //remove from cache |
| 583 | 583 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 584 | - if($oCacheHandler->isSupport()) |
|
| 584 | + if ($oCacheHandler->isSupport()) |
|
| 585 | 585 | { |
| 586 | 586 | //remove document item from cache |
| 587 | - $cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
| 587 | + $cache_key = 'document_item:' . getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
| 588 | 588 | $oCacheHandler->delete($cache_key); |
| 589 | 589 | } |
| 590 | 590 | |
@@ -605,33 +605,33 @@ discard block |
||
| 605 | 605 | $trigger_obj = new stdClass(); |
| 606 | 606 | $trigger_obj->document_srl = $document_srl; |
| 607 | 607 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
| 608 | - if(!$output->toBool()) return $output; |
|
| 608 | + if (!$output->toBool()) return $output; |
|
| 609 | 609 | |
| 610 | 610 | // begin transaction |
| 611 | 611 | $oDB = &DB::getInstance(); |
| 612 | 612 | $oDB->begin(); |
| 613 | 613 | |
| 614 | - if(!$isEmptyTrash) |
|
| 614 | + if (!$isEmptyTrash) |
|
| 615 | 615 | { |
| 616 | 616 | // get model object of the document |
| 617 | 617 | $oDocumentModel = getModel('document'); |
| 618 | 618 | // Check if the documnet exists |
| 619 | 619 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
| 620 | 620 | } |
| 621 | - else if($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists'); |
|
| 621 | + else if ($isEmptyTrash && $oDocument == null) return new Object(-1, 'document is not exists'); |
|
| 622 | 622 | |
| 623 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document'); |
|
| 623 | + if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document'); |
|
| 624 | 624 | // Check if a permossion is granted |
| 625 | - if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); |
|
| 625 | + if (!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); |
|
| 626 | 626 | |
| 627 | 627 | //if empty trash, document already deleted, therefore document not delete |
| 628 | 628 | $args = new stdClass(); |
| 629 | 629 | $args->document_srl = $document_srl; |
| 630 | - if(!$isEmptyTrash) |
|
| 630 | + if (!$isEmptyTrash) |
|
| 631 | 631 | { |
| 632 | 632 | // Delete the document |
| 633 | 633 | $output = executeQuery('document.deleteDocument', $args); |
| 634 | - if(!$output->toBool()) |
|
| 634 | + if (!$output->toBool()) |
|
| 635 | 635 | { |
| 636 | 636 | $oDB->rollback(); |
| 637 | 637 | return $output; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | $this->deleteDocumentHistory(null, $document_srl, null); |
| 644 | 644 | // Update category information if the category_srl exists. |
| 645 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 645 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
| 646 | 646 | // Delete a declared list |
| 647 | 647 | executeQuery('document.deleteDeclared', $args); |
| 648 | 648 | // Delete extra variable |
@@ -650,11 +650,11 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | //this |
| 652 | 652 | // Call a trigger (after) |
| 653 | - if($output->toBool()) |
|
| 653 | + if ($output->toBool()) |
|
| 654 | 654 | { |
| 655 | 655 | $trigger_obj = $oDocument->getObjectVars(); |
| 656 | 656 | $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); |
| 657 | - if(!$trigger_output->toBool()) |
|
| 657 | + if (!$trigger_output->toBool()) |
|
| 658 | 658 | { |
| 659 | 659 | $oDB->rollback(); |
| 660 | 660 | return $trigger_output; |
@@ -666,16 +666,16 @@ discard block |
||
| 666 | 666 | $this->_deleteDocumentVotedLog($args); |
| 667 | 667 | |
| 668 | 668 | // Remove the thumbnail file |
| 669 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3))); |
|
| 669 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3))); |
|
| 670 | 670 | |
| 671 | 671 | // commit |
| 672 | 672 | $oDB->commit(); |
| 673 | 673 | |
| 674 | 674 | //remove from cache |
| 675 | 675 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 676 | - if($oCacheHandler->isSupport()) |
|
| 676 | + if ($oCacheHandler->isSupport()) |
|
| 677 | 677 | { |
| 678 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 678 | + $cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl; |
|
| 679 | 679 | $oCacheHandler->delete($cache_key); |
| 680 | 680 | } |
| 681 | 681 | |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | { |
| 723 | 723 | $trash_args = new stdClass(); |
| 724 | 724 | // Get trash_srl if a given trash_srl doesn't exist |
| 725 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 725 | + if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
| 726 | 726 | else $trash_args->trash_srl = $obj->trash_srl; |
| 727 | 727 | // Get its module_srl which the document belongs to |
| 728 | 728 | $oDocumentModel = getModel('document'); |
@@ -731,12 +731,12 @@ discard block |
||
| 731 | 731 | $trash_args->module_srl = $oDocument->get('module_srl'); |
| 732 | 732 | $obj->module_srl = $oDocument->get('module_srl'); |
| 733 | 733 | // Cannot throw data from the trash to the trash |
| 734 | - if($trash_args->module_srl == 0) return false; |
|
| 734 | + if ($trash_args->module_srl == 0) return false; |
|
| 735 | 735 | // Data setting |
| 736 | 736 | $trash_args->document_srl = $obj->document_srl; |
| 737 | 737 | $trash_args->description = $obj->description; |
| 738 | 738 | // Insert member's information only if the member is logged-in and not manually registered. |
| 739 | - if(Context::get('is_logged')&&!$manual_inserted) |
|
| 739 | + if (Context::get('is_logged') && !$manual_inserted) |
|
| 740 | 740 | { |
| 741 | 741 | $logged_info = Context::get('logged_info'); |
| 742 | 742 | $trash_args->member_srl = $logged_info->member_srl; |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | }*/ |
| 763 | 763 | |
| 764 | 764 | // new trash module |
| 765 | - require_once(_XE_PATH_.'modules/trash/model/TrashVO.php'); |
|
| 765 | + require_once(_XE_PATH_ . 'modules/trash/model/TrashVO.php'); |
|
| 766 | 766 | $oTrashVO = new TrashVO(); |
| 767 | 767 | $oTrashVO->setTrashSrl(getNextSequence()); |
| 768 | 768 | $oTrashVO->setTitle($oDocument->variables['title']); |
@@ -772,14 +772,14 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | $oTrashAdminController = getAdminController('trash'); |
| 774 | 774 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
| 775 | - if(!$output->toBool()) |
|
| 775 | + if (!$output->toBool()) |
|
| 776 | 776 | { |
| 777 | 777 | $oDB->rollback(); |
| 778 | 778 | return $output; |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | $output = executeQuery('document.deleteDocument', $trash_args); |
| 782 | - if(!$output->toBool()) |
|
| 782 | + if (!$output->toBool()) |
|
| 783 | 783 | { |
| 784 | 784 | $oDB->rollback(); |
| 785 | 785 | return $output; |
@@ -792,12 +792,12 @@ discard block |
||
| 792 | 792 | }*/ |
| 793 | 793 | |
| 794 | 794 | // update category |
| 795 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
| 795 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
| 796 | 796 | |
| 797 | 797 | // remove thumbnails |
| 798 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
| 798 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
| 799 | 799 | // Set the attachment to be invalid state |
| 800 | - if($oDocument->hasUploadedFiles()) |
|
| 800 | + if ($oDocument->hasUploadedFiles()) |
|
| 801 | 801 | { |
| 802 | 802 | $args = new stdClass(); |
| 803 | 803 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -805,10 +805,10 @@ discard block |
||
| 805 | 805 | executeQuery('file.updateFileValid', $args); |
| 806 | 806 | } |
| 807 | 807 | // Call a trigger (after) |
| 808 | - if($output->toBool()) |
|
| 808 | + if ($output->toBool()) |
|
| 809 | 809 | { |
| 810 | 810 | $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj); |
| 811 | - if(!$trigger_output->toBool()) |
|
| 811 | + if (!$trigger_output->toBool()) |
|
| 812 | 812 | { |
| 813 | 813 | $oDB->rollback(); |
| 814 | 814 | return $trigger_output; |
@@ -820,9 +820,9 @@ discard block |
||
| 820 | 820 | |
| 821 | 821 | // Clear cache |
| 822 | 822 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 823 | - if($oCacheHandler->isSupport()) |
|
| 823 | + if ($oCacheHandler->isSupport()) |
|
| 824 | 824 | { |
| 825 | - $cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
| 825 | + $cache_key = 'document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
| 826 | 826 | $oCacheHandler->delete($cache_key); |
| 827 | 827 | } |
| 828 | 828 | |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | function updateReadedCount(&$oDocument) |
| 838 | 838 | { |
| 839 | 839 | // Pass if Crawler access |
| 840 | - if(isCrawler()) return false; |
|
| 840 | + if (isCrawler()) return false; |
|
| 841 | 841 | |
| 842 | 842 | $document_srl = $oDocument->document_srl; |
| 843 | 843 | $member_srl = $oDocument->get('member_srl'); |
@@ -845,19 +845,19 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | // Call a trigger when the read count is updated (before) |
| 847 | 847 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
| 848 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 848 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 849 | 849 | |
| 850 | 850 | // Pass if read count is increaded on the session information |
| 851 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
| 851 | + if ($_SESSION['readed_document'][$document_srl]) return false; |
|
| 852 | 852 | |
| 853 | 853 | // Pass if the author's IP address is as same as visitor's. |
| 854 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 854 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 855 | 855 | { |
| 856 | 856 | $_SESSION['readed_document'][$document_srl] = true; |
| 857 | 857 | return false; |
| 858 | 858 | } |
| 859 | 859 | // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. |
| 860 | - if($member_srl && $logged_info->member_srl == $member_srl) |
|
| 860 | + if ($member_srl && $logged_info->member_srl == $member_srl) |
|
| 861 | 861 | { |
| 862 | 862 | $_SESSION['readed_document'][$document_srl] = true; |
| 863 | 863 | return false; |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | |
| 874 | 874 | // Call a trigger when the read count is updated (after) |
| 875 | 875 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); |
| 876 | - if(!$trigger_output->toBool()) |
|
| 876 | + if (!$trigger_output->toBool()) |
|
| 877 | 877 | { |
| 878 | 878 | $oDB->rollback(); |
| 879 | 879 | return $trigger_output; |
@@ -882,15 +882,15 @@ discard block |
||
| 882 | 882 | $oDB->commit(); |
| 883 | 883 | |
| 884 | 884 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 885 | - if($oCacheHandler->isSupport()) |
|
| 885 | + if ($oCacheHandler->isSupport()) |
|
| 886 | 886 | { |
| 887 | 887 | //remove document item from cache |
| 888 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 888 | + $cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl; |
|
| 889 | 889 | $oCacheHandler->delete($cache_key); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // Register session |
| 893 | - if(!$_SESSION['banned_document'][$document_srl]) |
|
| 893 | + if (!$_SESSION['banned_document'][$document_srl]) |
|
| 894 | 894 | { |
| 895 | 895 | $_SESSION['readed_document'][$document_srl] = true; |
| 896 | 896 | } |
@@ -913,21 +913,21 @@ discard block |
||
| 913 | 913 | */ |
| 914 | 914 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
| 915 | 915 | { |
| 916 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1,'msg_invalid_request'); |
|
| 916 | + if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new Object(-1, 'msg_invalid_request'); |
|
| 917 | 917 | |
| 918 | 918 | $obj = new stdClass(); |
| 919 | 919 | $obj->module_srl = $module_srl; |
| 920 | 920 | $obj->var_idx = $var_idx; |
| 921 | 921 | $obj->var_name = $var_name; |
| 922 | 922 | $obj->var_type = $var_type; |
| 923 | - $obj->var_is_required = $var_is_required=='Y'?'Y':'N'; |
|
| 924 | - $obj->var_search = $var_search=='Y'?'Y':'N'; |
|
| 923 | + $obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N'; |
|
| 924 | + $obj->var_search = $var_search == 'Y' ? 'Y' : 'N'; |
|
| 925 | 925 | $obj->var_default = $var_default; |
| 926 | 926 | $obj->var_desc = $var_desc; |
| 927 | 927 | $obj->eid = $eid; |
| 928 | 928 | |
| 929 | 929 | $output = executeQuery('document.getDocumentExtraKeys', $obj); |
| 930 | - if(!$output->data) |
|
| 930 | + if (!$output->data) |
|
| 931 | 931 | { |
| 932 | 932 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
| 933 | 933 | } |
@@ -939,9 +939,9 @@ discard block |
||
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 942 | - if($oCacheHandler->isSupport()) |
|
| 942 | + if ($oCacheHandler->isSupport()) |
|
| 943 | 943 | { |
| 944 | - $object_key = 'module_document_extra_keys:'.$module_srl; |
|
| 944 | + $object_key = 'module_document_extra_keys:' . $module_srl; |
|
| 945 | 945 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
| 946 | 946 | $oCacheHandler->delete($cache_key); |
| 947 | 947 | } |
@@ -957,42 +957,42 @@ discard block |
||
| 957 | 957 | */ |
| 958 | 958 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
| 959 | 959 | { |
| 960 | - if(!$module_srl) return new Object(-1,'msg_invalid_request'); |
|
| 960 | + if (!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 961 | 961 | $obj = new stdClass(); |
| 962 | 962 | $obj->module_srl = $module_srl; |
| 963 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 963 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 964 | 964 | |
| 965 | 965 | $oDB = DB::getInstance(); |
| 966 | 966 | $oDB->begin(); |
| 967 | 967 | |
| 968 | 968 | $output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj); |
| 969 | - if(!$output->toBool()) |
|
| 969 | + if (!$output->toBool()) |
|
| 970 | 970 | { |
| 971 | 971 | $oDB->rollback(); |
| 972 | 972 | return $output; |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - if($var_idx != NULL) |
|
| 975 | + if ($var_idx != NULL) |
|
| 976 | 976 | { |
| 977 | 977 | $output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj); |
| 978 | - if(!$output->toBool()) |
|
| 978 | + if (!$output->toBool()) |
|
| 979 | 979 | { |
| 980 | 980 | $oDB->rollback(); |
| 981 | 981 | return $output; |
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
| 986 | - if(!$output->toBool()) |
|
| 985 | + $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
| 986 | + if (!$output->toBool()) |
|
| 987 | 987 | { |
| 988 | 988 | $oDB->rollback(); |
| 989 | 989 | return $output; |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - if($var_idx != NULL) |
|
| 992 | + if ($var_idx != NULL) |
|
| 993 | 993 | { |
| 994 | 994 | $output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj); |
| 995 | - if(!$output->toBool()) |
|
| 995 | + if (!$output->toBool()) |
|
| 996 | 996 | { |
| 997 | 997 | $oDB->rollback(); |
| 998 | 998 | return $output; |
@@ -1002,9 +1002,9 @@ discard block |
||
| 1002 | 1002 | $oDB->commit(); |
| 1003 | 1003 | |
| 1004 | 1004 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
| 1005 | - if($oCacheHandler->isSupport()) |
|
| 1005 | + if ($oCacheHandler->isSupport()) |
|
| 1006 | 1006 | { |
| 1007 | - $object_key = 'module_document_extra_keys:'.$module_srl; |
|
| 1007 | + $object_key = 'module_document_extra_keys:' . $module_srl; |
|
| 1008 | 1008 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
| 1009 | 1009 | $oCacheHandler->delete($cache_key); |
| 1010 | 1010 | } |
@@ -1024,8 +1024,8 @@ discard block |
||
| 1024 | 1024 | */ |
| 1025 | 1025 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
| 1026 | 1026 | { |
| 1027 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1,'msg_invalid_request'); |
|
| 1028 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
| 1027 | + if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new Object(-1, 'msg_invalid_request'); |
|
| 1028 | + if (!$lang_code) $lang_code = Context::getLangType(); |
|
| 1029 | 1029 | |
| 1030 | 1030 | $obj = new stdClass; |
| 1031 | 1031 | $obj->module_srl = $module_srl; |
@@ -1051,10 +1051,10 @@ discard block |
||
| 1051 | 1051 | { |
| 1052 | 1052 | $obj = new stdClass(); |
| 1053 | 1053 | $obj->module_srl = $module_srl; |
| 1054 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1055 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1056 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1057 | - if(!is_null($eid)) $obj->eid = $eid; |
|
| 1054 | + if (!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
| 1055 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
| 1056 | + if (!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
| 1057 | + if (!is_null($eid)) $obj->eid = $eid; |
|
| 1058 | 1058 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
| 1059 | 1059 | return $output; |
| 1060 | 1060 | } |
@@ -1068,10 +1068,10 @@ discard block |
||
| 1068 | 1068 | */ |
| 1069 | 1069 | function updateVotedCount($document_srl, $point = 1) |
| 1070 | 1070 | { |
| 1071 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
| 1071 | + if ($point > 0) $failed_voted = 'failed_voted'; |
|
| 1072 | 1072 | else $failed_voted = 'failed_blamed'; |
| 1073 | 1073 | // Return fail if session already has information about votes |
| 1074 | - if($_SESSION['voted_document'][$document_srl]) |
|
| 1074 | + if ($_SESSION['voted_document'][$document_srl]) |
|
| 1075 | 1075 | { |
| 1076 | 1076 | return new Object(-1, $failed_voted); |
| 1077 | 1077 | } |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | $oDocumentModel = getModel('document'); |
| 1080 | 1080 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 1081 | 1081 | // Pass if the author's IP address is as same as visitor's. |
| 1082 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 1082 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
| 1083 | 1083 | { |
| 1084 | 1084 | $_SESSION['voted_document'][$document_srl] = true; |
| 1085 | 1085 | return new Object(-1, $failed_voted); |
@@ -1090,10 +1090,10 @@ discard block |
||
| 1090 | 1090 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
| 1091 | 1091 | |
| 1092 | 1092 | // Check if document's author is a member. |
| 1093 | - if($oDocument->get('member_srl')) |
|
| 1093 | + if ($oDocument->get('member_srl')) |
|
| 1094 | 1094 | { |
| 1095 | 1095 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
| 1096 | - if($member_srl && $member_srl == $oDocument->get('member_srl')) |
|
| 1096 | + if ($member_srl && $member_srl == $oDocument->get('member_srl')) |
|
| 1097 | 1097 | { |
| 1098 | 1098 | $_SESSION['voted_document'][$document_srl] = true; |
| 1099 | 1099 | return new Object(-1, $failed_voted); |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | // Use member_srl for logged-in members and IP address for non-members. |
| 1104 | 1104 | $args = new stdClass; |
| 1105 | - if($member_srl) |
|
| 1105 | + if ($member_srl) |
|
| 1106 | 1106 | { |
| 1107 | 1107 | $args->member_srl = $member_srl; |
| 1108 | 1108 | } |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | $args->document_srl = $document_srl; |
| 1114 | 1114 | $output = executeQuery('document.getDocumentVotedLogInfo', $args); |
| 1115 | 1115 | // Pass after registering a session if log information has vote-up logs |
| 1116 | - if($output->data->count) |
|
| 1116 | + if ($output->data->count) |
|
| 1117 | 1117 | { |
| 1118 | 1118 | $_SESSION['voted_document'][$document_srl] = true; |
| 1119 | 1119 | return new Object(-1, $failed_voted); |
@@ -1124,7 +1124,7 @@ discard block |
||
| 1124 | 1124 | $oDB->begin(); |
| 1125 | 1125 | |
| 1126 | 1126 | // Update the voted count |
| 1127 | - if($point < 0) |
|
| 1127 | + if ($point < 0) |
|
| 1128 | 1128 | { |
| 1129 | 1129 | $args->blamed_count = $oDocument->get('blamed_count') + $point; |
| 1130 | 1130 | $output = executeQuery('document.updateBlamedCount', $args); |
@@ -1134,11 +1134,11 @@ discard block |
||
| 1134 | 1134 | $args->voted_count = $oDocument->get('voted_count') + $point; |
| 1135 | 1135 | $output = executeQuery('document.updateVotedCount', $args); |
| 1136 | 1136 | } |
| 1137 | - if(!$output->toBool()) return $output; |
|
| 1137 | + if (!$output->toBool()) return $output; |
|
| 1138 | 1138 | // Leave logs |
| 1139 | 1139 | $args->point = $point; |
| 1140 | 1140 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
| 1141 | - if(!$output->toBool()) return $output; |
|
| 1141 | + if (!$output->toBool()) return $output; |
|
| 1142 | 1142 | |
| 1143 | 1143 | $obj = new stdClass; |
| 1144 | 1144 | $obj->member_srl = $oDocument->get('member_srl'); |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | $obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); |
| 1150 | 1150 | $obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count; |
| 1151 | 1151 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj); |
| 1152 | - if(!$trigger_output->toBool()) |
|
| 1152 | + if (!$trigger_output->toBool()) |
|
| 1153 | 1153 | { |
| 1154 | 1154 | $oDB->rollback(); |
| 1155 | 1155 | return $trigger_output; |
@@ -1158,10 +1158,10 @@ discard block |
||
| 1158 | 1158 | $oDB->commit(); |
| 1159 | 1159 | |
| 1160 | 1160 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1161 | - if($oCacheHandler->isSupport()) |
|
| 1161 | + if ($oCacheHandler->isSupport()) |
|
| 1162 | 1162 | { |
| 1163 | 1163 | //remove document item from cache |
| 1164 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1164 | + $cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl; |
|
| 1165 | 1165 | $oCacheHandler->delete($cache_key); |
| 1166 | 1166 | } |
| 1167 | 1167 | |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | |
| 1171 | 1171 | // Return result |
| 1172 | 1172 | $output = new Object(); |
| 1173 | - if($point > 0) |
|
| 1173 | + if ($point > 0) |
|
| 1174 | 1174 | { |
| 1175 | 1175 | $output->setMessage('success_voted'); |
| 1176 | 1176 | $output->add('voted_count', $obj->after_point); |
@@ -1192,13 +1192,13 @@ discard block |
||
| 1192 | 1192 | function declaredDocument($document_srl) |
| 1193 | 1193 | { |
| 1194 | 1194 | // Fail if session information already has a reported document |
| 1195 | - if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared'); |
|
| 1195 | + if ($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared'); |
|
| 1196 | 1196 | |
| 1197 | 1197 | // Check if previously reported |
| 1198 | 1198 | $args = new stdClass(); |
| 1199 | 1199 | $args->document_srl = $document_srl; |
| 1200 | 1200 | $output = executeQuery('document.getDeclaredDocument', $args); |
| 1201 | - if(!$output->toBool()) return $output; |
|
| 1201 | + if (!$output->toBool()) return $output; |
|
| 1202 | 1202 | |
| 1203 | 1203 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
| 1204 | 1204 | |
@@ -1208,7 +1208,7 @@ discard block |
||
| 1208 | 1208 | |
| 1209 | 1209 | // Call a trigger (before) |
| 1210 | 1210 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); |
| 1211 | - if(!$trigger_output->toBool()) |
|
| 1211 | + if (!$trigger_output->toBool()) |
|
| 1212 | 1212 | { |
| 1213 | 1213 | return $trigger_output; |
| 1214 | 1214 | } |
@@ -1218,19 +1218,19 @@ discard block |
||
| 1218 | 1218 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
| 1219 | 1219 | |
| 1220 | 1220 | // Pass if the author's IP address is as same as visitor's. |
| 1221 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
| 1221 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
| 1222 | 1222 | $_SESSION['declared_document'][$document_srl] = true; |
| 1223 | 1223 | return new Object(-1, 'failed_declared'); |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | // Check if document's author is a member. |
| 1227 | - if($oDocument->get('member_srl')) |
|
| 1227 | + if ($oDocument->get('member_srl')) |
|
| 1228 | 1228 | { |
| 1229 | 1229 | // Create a member model object |
| 1230 | 1230 | $oMemberModel = getModel('member'); |
| 1231 | 1231 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
| 1232 | 1232 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
| 1233 | - if($member_srl && $member_srl == $oDocument->get('member_srl')) |
|
| 1233 | + if ($member_srl && $member_srl == $oDocument->get('member_srl')) |
|
| 1234 | 1234 | { |
| 1235 | 1235 | $_SESSION['declared_document'][$document_srl] = true; |
| 1236 | 1236 | return new Object(-1, 'failed_declared'); |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | |
| 1240 | 1240 | // Use member_srl for logged-in members and IP address for non-members. |
| 1241 | 1241 | $args = new stdClass; |
| 1242 | - if($member_srl) |
|
| 1242 | + if ($member_srl) |
|
| 1243 | 1243 | { |
| 1244 | 1244 | $args->member_srl = $member_srl; |
| 1245 | 1245 | } |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); |
| 1253 | 1253 | |
| 1254 | 1254 | // Pass after registering a sesson if reported/declared documents are in the logs. |
| 1255 | - if($output->data->count) |
|
| 1255 | + if ($output->data->count) |
|
| 1256 | 1256 | { |
| 1257 | 1257 | $_SESSION['declared_document'][$document_srl] = true; |
| 1258 | 1258 | return new Object(-1, 'failed_declared'); |
@@ -1263,23 +1263,23 @@ discard block |
||
| 1263 | 1263 | $oDB->begin(); |
| 1264 | 1264 | |
| 1265 | 1265 | // Add the declared document |
| 1266 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1266 | + if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
| 1267 | 1267 | else $output = executeQuery('document.insertDeclaredDocument', $args); |
| 1268 | - if(!$output->toBool()) return $output; |
|
| 1268 | + if (!$output->toBool()) return $output; |
|
| 1269 | 1269 | // Leave logs |
| 1270 | 1270 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
| 1271 | - if(!$output->toBool()) |
|
| 1271 | + if (!$output->toBool()) |
|
| 1272 | 1272 | { |
| 1273 | 1273 | $oDB->rollback(); |
| 1274 | 1274 | return $output; |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | - $this->add('declared_count', $declared_count+1); |
|
| 1277 | + $this->add('declared_count', $declared_count + 1); |
|
| 1278 | 1278 | |
| 1279 | 1279 | // Call a trigger (after) |
| 1280 | 1280 | $trigger_obj->declared_count = $declared_count + 1; |
| 1281 | 1281 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); |
| 1282 | - if(!$trigger_output->toBool()) |
|
| 1282 | + if (!$trigger_output->toBool()) |
|
| 1283 | 1283 | { |
| 1284 | 1284 | $oDB->rollback(); |
| 1285 | 1285 | return $trigger_output; |
@@ -1309,16 +1309,16 @@ discard block |
||
| 1309 | 1309 | $args->document_srl = $document_srl; |
| 1310 | 1310 | $args->comment_count = $comment_count; |
| 1311 | 1311 | |
| 1312 | - if($comment_inserted) |
|
| 1312 | + if ($comment_inserted) |
|
| 1313 | 1313 | { |
| 1314 | - $args->update_order = -1*getNextSequence(); |
|
| 1314 | + $args->update_order = -1 * getNextSequence(); |
|
| 1315 | 1315 | $args->last_updater = $last_updater; |
| 1316 | 1316 | |
| 1317 | 1317 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1318 | - if($oCacheHandler->isSupport()) |
|
| 1318 | + if ($oCacheHandler->isSupport()) |
|
| 1319 | 1319 | { |
| 1320 | 1320 | //remove document item from cache |
| 1321 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1321 | + $cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl; |
|
| 1322 | 1322 | $oCacheHandler->delete($cache_key); |
| 1323 | 1323 | } |
| 1324 | 1324 | } |
@@ -1339,10 +1339,10 @@ discard block |
||
| 1339 | 1339 | $args->trackback_count = $trackback_count; |
| 1340 | 1340 | |
| 1341 | 1341 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1342 | - if($oCacheHandler->isSupport()) |
|
| 1342 | + if ($oCacheHandler->isSupport()) |
|
| 1343 | 1343 | { |
| 1344 | 1344 | //remove document item from cache |
| 1345 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
| 1345 | + $cache_key = 'document_item:' . getNumberingPath($document_srl) . $document_srl; |
|
| 1346 | 1346 | $oCacheHandler->delete($cache_key); |
| 1347 | 1347 | } |
| 1348 | 1348 | |
@@ -1357,14 +1357,14 @@ discard block |
||
| 1357 | 1357 | function insertCategory($obj) |
| 1358 | 1358 | { |
| 1359 | 1359 | // Sort the order to display if a child category is added |
| 1360 | - if($obj->parent_srl) |
|
| 1360 | + if ($obj->parent_srl) |
|
| 1361 | 1361 | { |
| 1362 | 1362 | // Get its parent category |
| 1363 | 1363 | $oDocumentModel = getModel('document'); |
| 1364 | 1364 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
| 1365 | 1365 | $obj->list_order = $parent_category->list_order; |
| 1366 | - $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
|
| 1367 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1366 | + $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1); |
|
| 1367 | + if (!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | else |
| 1370 | 1370 | { |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | $output = executeQuery('document.insertCategory', $obj); |
| 1375 | - if($output->toBool()) |
|
| 1375 | + if ($output->toBool()) |
|
| 1376 | 1376 | { |
| 1377 | 1377 | $output->add('category_srl', $obj->category_srl); |
| 1378 | 1378 | $this->makeCategoryFile($obj->module_srl); |
@@ -1406,13 +1406,13 @@ discard block |
||
| 1406 | 1406 | { |
| 1407 | 1407 | // Create a document model object |
| 1408 | 1408 | $oDocumentModel = getModel('document'); |
| 1409 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
| 1409 | + if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl); |
|
| 1410 | 1410 | |
| 1411 | 1411 | $args = new stdClass; |
| 1412 | 1412 | $args->category_srl = $category_srl; |
| 1413 | 1413 | $args->document_count = $document_count; |
| 1414 | 1414 | $output = executeQuery('document.updateCategoryCount', $args); |
| 1415 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1415 | + if ($output->toBool()) $this->makeCategoryFile($module_srl); |
|
| 1416 | 1416 | |
| 1417 | 1417 | return $output; |
| 1418 | 1418 | } |
@@ -1425,7 +1425,7 @@ discard block |
||
| 1425 | 1425 | function updateCategory($obj) |
| 1426 | 1426 | { |
| 1427 | 1427 | $output = executeQuery('document.updateCategory', $obj); |
| 1428 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1428 | + if ($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
| 1429 | 1429 | return $output; |
| 1430 | 1430 | } |
| 1431 | 1431 | |
@@ -1442,32 +1442,32 @@ discard block |
||
| 1442 | 1442 | $category_info = $oDocumentModel->getCategory($category_srl); |
| 1443 | 1443 | // Display an error that the category cannot be deleted if it has a child |
| 1444 | 1444 | $output = executeQuery('document.getChildCategoryCount', $args); |
| 1445 | - if(!$output->toBool()) return $output; |
|
| 1446 | - if($output->data->count>0) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1445 | + if (!$output->toBool()) return $output; |
|
| 1446 | + if ($output->data->count > 0) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1447 | 1447 | // Delete a category information |
| 1448 | 1448 | $output = executeQuery('document.deleteCategory', $args); |
| 1449 | - if(!$output->toBool()) return $output; |
|
| 1449 | + if (!$output->toBool()) return $output; |
|
| 1450 | 1450 | |
| 1451 | 1451 | $this->makeCategoryFile($category_info->module_srl); |
| 1452 | 1452 | // remvove cache |
| 1453 | 1453 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 1454 | - if($oCacheHandler->isSupport()) |
|
| 1454 | + if ($oCacheHandler->isSupport()) |
|
| 1455 | 1455 | { |
| 1456 | 1456 | $page = 0; |
| 1457 | - while(true) { |
|
| 1457 | + while (true) { |
|
| 1458 | 1458 | $args = new stdClass(); |
| 1459 | 1459 | $args->category_srl = $category_srl; |
| 1460 | 1460 | $args->list_count = 100; |
| 1461 | 1461 | $args->page = ++$page; |
| 1462 | 1462 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
| 1463 | 1463 | |
| 1464 | - if($output->data == array()) |
|
| 1464 | + if ($output->data == array()) |
|
| 1465 | 1465 | break; |
| 1466 | 1466 | |
| 1467 | - foreach($output->data as $val) |
|
| 1467 | + foreach ($output->data as $val) |
|
| 1468 | 1468 | { |
| 1469 | 1469 | //remove document item from cache |
| 1470 | - $cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl; |
|
| 1470 | + $cache_key = 'document_item:' . getNumberingPath($val->document_srl) . $val->document_srl; |
|
| 1471 | 1471 | $oCacheHandler->delete($cache_key); |
| 1472 | 1472 | } |
| 1473 | 1473 | } |
@@ -1514,18 +1514,18 @@ discard block |
||
| 1514 | 1514 | // Seek a full list of categories |
| 1515 | 1515 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1516 | 1516 | $category_srl_list = array_keys($category_list); |
| 1517 | - if(count($category_srl_list)<2) return new Object(); |
|
| 1517 | + if (count($category_srl_list) < 2) return new Object(); |
|
| 1518 | 1518 | |
| 1519 | 1519 | $prev_category = NULL; |
| 1520 | - foreach($category_list as $key => $val) |
|
| 1520 | + foreach ($category_list as $key => $val) |
|
| 1521 | 1521 | { |
| 1522 | - if($key==$category_srl) break; |
|
| 1522 | + if ($key == $category_srl) break; |
|
| 1523 | 1523 | $prev_category = $val; |
| 1524 | 1524 | } |
| 1525 | 1525 | // Return if the previous category doesn't exist |
| 1526 | - if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1526 | + if (!$prev_category) return new Object(-1, Context::getLang('msg_category_not_moved')); |
|
| 1527 | 1527 | // Return if the selected category is the top level |
| 1528 | - if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1528 | + if ($category_srl_list[0] == $category_srl) return new Object(-1, Context::getLang('msg_category_not_moved')); |
|
| 1529 | 1529 | // Information of the selected category |
| 1530 | 1530 | $cur_args = new stdClass; |
| 1531 | 1531 | $cur_args->category_srl = $category_srl; |
@@ -1561,15 +1561,15 @@ discard block |
||
| 1561 | 1561 | // Seek a full list of categories |
| 1562 | 1562 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
| 1563 | 1563 | $category_srl_list = array_keys($category_list); |
| 1564 | - if(count($category_srl_list)<2) return new Object(); |
|
| 1564 | + if (count($category_srl_list) < 2) return new Object(); |
|
| 1565 | 1565 | |
| 1566 | - for($i=0;$i<count($category_srl_list);$i++) |
|
| 1566 | + for ($i = 0; $i < count($category_srl_list); $i++) |
|
| 1567 | 1567 | { |
| 1568 | - if($category_srl_list[$i]==$category_srl) break; |
|
| 1568 | + if ($category_srl_list[$i] == $category_srl) break; |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | - $next_category_srl = $category_srl_list[$i+1]; |
|
| 1572 | - if(!$category_list[$next_category_srl]) return new Object(-1,Context::getLang('msg_category_not_moved')); |
|
| 1571 | + $next_category_srl = $category_srl_list[$i + 1]; |
|
| 1572 | + if (!$category_list[$next_category_srl]) return new Object(-1, Context::getLang('msg_category_not_moved')); |
|
| 1573 | 1573 | $next_category = $category_list[$next_category_srl]; |
| 1574 | 1574 | // Information of the selected category |
| 1575 | 1575 | $cur_args = new stdClass; |
@@ -1596,7 +1596,7 @@ discard block |
||
| 1596 | 1596 | { |
| 1597 | 1597 | $oDocumentModel = getModel('document'); |
| 1598 | 1598 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
| 1599 | - if(!count($extra_keys)) return; |
|
| 1599 | + if (!count($extra_keys)) return; |
|
| 1600 | 1600 | |
| 1601 | 1601 | $js_code = array(); |
| 1602 | 1602 | $js_code[] = '<script>//<![CDATA['; |
@@ -1606,16 +1606,16 @@ discard block |
||
| 1606 | 1606 | |
| 1607 | 1607 | $logged_info = Context::get('logged_info'); |
| 1608 | 1608 | |
| 1609 | - foreach($extra_keys as $idx => $val) |
|
| 1609 | + foreach ($extra_keys as $idx => $val) |
|
| 1610 | 1610 | { |
| 1611 | 1611 | $idx = $val->idx; |
| 1612 | - if($val->type == 'kr_zip') |
|
| 1612 | + if ($val->type == 'kr_zip') |
|
| 1613 | 1613 | { |
| 1614 | 1614 | $idx .= '[]'; |
| 1615 | 1615 | } |
| 1616 | 1616 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
| 1617 | 1617 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
| 1618 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1618 | + if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | $js_code[] = '})(jQuery);'; |
@@ -1633,12 +1633,12 @@ discard block |
||
| 1633 | 1633 | function procDocumentInsertCategory($args = null) |
| 1634 | 1634 | { |
| 1635 | 1635 | // List variables |
| 1636 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
| 1636 | + if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid'); |
|
| 1637 | 1637 | $args->title = $args->category_title; |
| 1638 | 1638 | $args->description = $args->category_description; |
| 1639 | 1639 | $args->color = $args->category_color; |
| 1640 | 1640 | |
| 1641 | - if(!$args->module_srl && $args->mid) |
|
| 1641 | + if (!$args->module_srl && $args->mid) |
|
| 1642 | 1642 | { |
| 1643 | 1643 | $mid = $args->mid; |
| 1644 | 1644 | unset($args->mid); |
@@ -1649,28 +1649,28 @@ discard block |
||
| 1649 | 1649 | $columnList = array('module_srl', 'module'); |
| 1650 | 1650 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1651 | 1651 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1652 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1652 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1653 | 1653 | |
| 1654 | - if($args->expand !="Y") $args->expand = "N"; |
|
| 1655 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
| 1654 | + if ($args->expand != "Y") $args->expand = "N"; |
|
| 1655 | + if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls); |
|
| 1656 | 1656 | else $args->group_srls = implode(',', $args->group_srls); |
| 1657 | - $args->parent_srl = (int)$args->parent_srl; |
|
| 1657 | + $args->parent_srl = (int) $args->parent_srl; |
|
| 1658 | 1658 | |
| 1659 | 1659 | $oDocumentModel = getModel('document'); |
| 1660 | 1660 | |
| 1661 | 1661 | $oDB = &DB::getInstance(); |
| 1662 | 1662 | $oDB->begin(); |
| 1663 | 1663 | // Check if already exists |
| 1664 | - if($args->category_srl) |
|
| 1664 | + if ($args->category_srl) |
|
| 1665 | 1665 | { |
| 1666 | 1666 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1667 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1667 | + if ($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
| 1668 | 1668 | } |
| 1669 | 1669 | // Update if exists |
| 1670 | - if($args->category_srl) |
|
| 1670 | + if ($args->category_srl) |
|
| 1671 | 1671 | { |
| 1672 | 1672 | $output = $this->updateCategory($args); |
| 1673 | - if(!$output->toBool()) |
|
| 1673 | + if (!$output->toBool()) |
|
| 1674 | 1674 | { |
| 1675 | 1675 | $oDB->rollback(); |
| 1676 | 1676 | return $output; |
@@ -1680,7 +1680,7 @@ discard block |
||
| 1680 | 1680 | else |
| 1681 | 1681 | { |
| 1682 | 1682 | $output = $this->insertCategory($args); |
| 1683 | - if(!$output->toBool()) |
|
| 1683 | + if (!$output->toBool()) |
|
| 1684 | 1684 | { |
| 1685 | 1685 | $oDB->rollback(); |
| 1686 | 1686 | return $output; |
@@ -1719,11 +1719,11 @@ discard block |
||
| 1719 | 1719 | $columnList = array('module_srl', 'module'); |
| 1720 | 1720 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
| 1721 | 1721 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1722 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1722 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1723 | 1723 | |
| 1724 | 1724 | // First child of the parent_category_srl |
| 1725 | 1725 | $source_args = new stdClass; |
| 1726 | - if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
| 1726 | + if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
| 1727 | 1727 | { |
| 1728 | 1728 | $parent_category = $oDocumentModel->getCategory($parent_category_srl); |
| 1729 | 1729 | |
@@ -1732,30 +1732,30 @@ discard block |
||
| 1732 | 1732 | $args->parent_srl = $parent_category_srl; |
| 1733 | 1733 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
| 1734 | 1734 | |
| 1735 | - if(!$output->toBool()) return $output; |
|
| 1736 | - $args->list_order = (int)$output->data->list_order; |
|
| 1737 | - if(!$args->list_order) $args->list_order = 0; |
|
| 1735 | + if (!$output->toBool()) return $output; |
|
| 1736 | + $args->list_order = (int) $output->data->list_order; |
|
| 1737 | + if (!$args->list_order) $args->list_order = 0; |
|
| 1738 | 1738 | $args->list_order--; |
| 1739 | 1739 | |
| 1740 | 1740 | $source_args->category_srl = $source_category_srl; |
| 1741 | 1741 | $source_args->parent_srl = $parent_category_srl; |
| 1742 | 1742 | $source_args->list_order = $args->list_order; |
| 1743 | 1743 | $output = $this->updateCategory($source_args); |
| 1744 | - if(!$output->toBool()) return $output; |
|
| 1744 | + if (!$output->toBool()) return $output; |
|
| 1745 | 1745 | // Sibling of the $target_category_srl |
| 1746 | 1746 | } |
| 1747 | - else if($target_category_srl > 0) |
|
| 1747 | + else if ($target_category_srl > 0) |
|
| 1748 | 1748 | { |
| 1749 | 1749 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
| 1750 | 1750 | // Move all siblings of the $target_category down |
| 1751 | - $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
|
| 1752 | - if(!$output->toBool()) return $output; |
|
| 1751 | + $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1); |
|
| 1752 | + if (!$output->toBool()) return $output; |
|
| 1753 | 1753 | |
| 1754 | 1754 | $source_args->category_srl = $source_category_srl; |
| 1755 | 1755 | $source_args->parent_srl = $target_category->parent_srl; |
| 1756 | - $source_args->list_order = $target_category->list_order+1; |
|
| 1756 | + $source_args->list_order = $target_category->list_order + 1; |
|
| 1757 | 1757 | $output = $this->updateCategory($source_args); |
| 1758 | - if(!$output->toBool()) return $output; |
|
| 1758 | + if (!$output->toBool()) return $output; |
|
| 1759 | 1759 | } |
| 1760 | 1760 | // Re-generate the xml file |
| 1761 | 1761 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1771,7 +1771,7 @@ discard block |
||
| 1771 | 1771 | function procDocumentDeleteCategory() |
| 1772 | 1772 | { |
| 1773 | 1773 | // List variables |
| 1774 | - $args = Context::gets('module_srl','category_srl'); |
|
| 1774 | + $args = Context::gets('module_srl', 'category_srl'); |
|
| 1775 | 1775 | |
| 1776 | 1776 | $oDB = &DB::getInstance(); |
| 1777 | 1777 | $oDB->begin(); |
@@ -1780,17 +1780,17 @@ discard block |
||
| 1780 | 1780 | $columnList = array('module_srl', 'module'); |
| 1781 | 1781 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
| 1782 | 1782 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1783 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1783 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1784 | 1784 | |
| 1785 | 1785 | $oDocumentModel = getModel('document'); |
| 1786 | 1786 | // Get original information |
| 1787 | 1787 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
| 1788 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 1788 | + if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
| 1789 | 1789 | // Display an error that the category cannot be deleted if it has a child node |
| 1790 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1790 | + if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child'); |
|
| 1791 | 1791 | // Remove from the DB |
| 1792 | 1792 | $output = $this->deleteCategory($args->category_srl); |
| 1793 | - if(!$output->toBool()) |
|
| 1793 | + if (!$output->toBool()) |
|
| 1794 | 1794 | { |
| 1795 | 1795 | $oDB->rollback(); |
| 1796 | 1796 | return $output; |
@@ -1821,11 +1821,11 @@ discard block |
||
| 1821 | 1821 | $columnList = array('module_srl', 'module'); |
| 1822 | 1822 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1823 | 1823 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
| 1824 | - if(!$grant->manager) return new Object(-1,'msg_not_permitted'); |
|
| 1824 | + if (!$grant->manager) return new Object(-1, 'msg_not_permitted'); |
|
| 1825 | 1825 | |
| 1826 | 1826 | $xml_file = $this->makeCategoryFile($module_srl); |
| 1827 | 1827 | // Set return value |
| 1828 | - $this->add('xml_file',$xml_file); |
|
| 1828 | + $this->add('xml_file', $xml_file); |
|
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | 1831 | /** |
@@ -1836,14 +1836,14 @@ discard block |
||
| 1836 | 1836 | function makeCategoryFile($module_srl) |
| 1837 | 1837 | { |
| 1838 | 1838 | // Return if there is no information you need for creating a cache file |
| 1839 | - if(!$module_srl) return false; |
|
| 1839 | + if (!$module_srl) return false; |
|
| 1840 | 1840 | // Get module information (to obtain mid) |
| 1841 | 1841 | $oModuleModel = getModel('module'); |
| 1842 | 1842 | $columnList = array('module_srl', 'mid', 'site_srl'); |
| 1843 | 1843 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
| 1844 | 1844 | $mid = $module_info->mid; |
| 1845 | 1845 | |
| 1846 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 1846 | + if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
| 1847 | 1847 | // Cache file's name |
| 1848 | 1848 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
| 1849 | 1849 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1855,17 +1855,17 @@ discard block |
||
| 1855 | 1855 | |
| 1856 | 1856 | $category_list = $output->data; |
| 1857 | 1857 | |
| 1858 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
| 1858 | + if (!is_array($category_list)) $category_list = array($category_list); |
|
| 1859 | 1859 | |
| 1860 | 1860 | $category_count = count($category_list); |
| 1861 | - for($i=0;$i<$category_count;$i++) |
|
| 1861 | + for ($i = 0; $i < $category_count; $i++) |
|
| 1862 | 1862 | { |
| 1863 | 1863 | $category_srl = $category_list[$i]->category_srl; |
| 1864 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 1864 | + if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
| 1865 | 1865 | $list[$category_srl] = $category_list[$i]; |
| 1866 | 1866 | } |
| 1867 | 1867 | // Create the xml file without node data if no data is obtained |
| 1868 | - if(!$list) |
|
| 1868 | + if (!$list) |
|
| 1869 | 1869 | { |
| 1870 | 1870 | $xml_buff = "<root />"; |
| 1871 | 1871 | FileHandler::writeFile($xml_file, $xml_buff); |
@@ -1873,47 +1873,47 @@ discard block |
||
| 1873 | 1873 | return $xml_file; |
| 1874 | 1874 | } |
| 1875 | 1875 | // Change to an array if only a single data is obtained |
| 1876 | - if(!is_array($list)) $list = array($list); |
|
| 1876 | + if (!is_array($list)) $list = array($list); |
|
| 1877 | 1877 | // Create a tree for loop |
| 1878 | - foreach($list as $category_srl => $node) |
|
| 1878 | + foreach ($list as $category_srl => $node) |
|
| 1879 | 1879 | { |
| 1880 | 1880 | $node->mid = $mid; |
| 1881 | - $parent_srl = (int)$node->parent_srl; |
|
| 1881 | + $parent_srl = (int) $node->parent_srl; |
|
| 1882 | 1882 | $tree[$parent_srl][$category_srl] = $node; |
| 1883 | 1883 | } |
| 1884 | 1884 | // A common header to set permissions and groups of the cache file |
| 1885 | 1885 | $header_script = |
| 1886 | - '$lang_type = Context::getLangType(); '. |
|
| 1887 | - '$is_logged = Context::get(\'is_logged\'); '. |
|
| 1888 | - '$logged_info = Context::get(\'logged_info\'); '. |
|
| 1889 | - 'if($is_logged) {'. |
|
| 1890 | - 'if($logged_info->is_admin=="Y") $is_admin = true; '. |
|
| 1891 | - 'else $is_admin = false; '. |
|
| 1892 | - '$group_srls = array_keys($logged_info->group_list); '. |
|
| 1893 | - '} else { '. |
|
| 1894 | - '$is_admin = false; '. |
|
| 1895 | - '$group_srsl = array(); '. |
|
| 1896 | - '} '."\n"; |
|
| 1886 | + '$lang_type = Context::getLangType(); ' . |
|
| 1887 | + '$is_logged = Context::get(\'is_logged\'); ' . |
|
| 1888 | + '$logged_info = Context::get(\'logged_info\'); ' . |
|
| 1889 | + 'if($is_logged) {' . |
|
| 1890 | + 'if($logged_info->is_admin=="Y") $is_admin = true; ' . |
|
| 1891 | + 'else $is_admin = false; ' . |
|
| 1892 | + '$group_srls = array_keys($logged_info->group_list); ' . |
|
| 1893 | + '} else { ' . |
|
| 1894 | + '$is_admin = false; ' . |
|
| 1895 | + '$group_srsl = array(); ' . |
|
| 1896 | + '} ' . "\n"; |
|
| 1897 | 1897 | |
| 1898 | 1898 | // Create the xml cache file (a separate session is needed for xml cache) |
| 1899 | 1899 | $xml_header_buff = ''; |
| 1900 | 1900 | $xml_body_buff = $this->getXmlTree($tree[0], $tree, $module_info->site_srl, $xml_header_buff); |
| 1901 | 1901 | $xml_buff = sprintf( |
| 1902 | - '<?php '. |
|
| 1903 | - 'define(\'__XE__\', true); '. |
|
| 1904 | - 'require_once(\''.FileHandler::getRealPath('./config/config.inc.php').'\'); '. |
|
| 1905 | - '$oContext = &Context::getInstance(); '. |
|
| 1906 | - '$oContext->init(); '. |
|
| 1907 | - 'header("Content-Type: text/xml; charset=UTF-8"); '. |
|
| 1908 | - 'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); '. |
|
| 1909 | - 'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); '. |
|
| 1910 | - 'header("Cache-Control: no-store, no-cache, must-revalidate"); '. |
|
| 1911 | - 'header("Cache-Control: post-check=0, pre-check=0", false); '. |
|
| 1912 | - 'header("Pragma: no-cache"); '. |
|
| 1913 | - '%s'. |
|
| 1914 | - '%s '. |
|
| 1915 | - '$oContext->close();'. |
|
| 1916 | - '?>'. |
|
| 1902 | + '<?php ' . |
|
| 1903 | + 'define(\'__XE__\', true); ' . |
|
| 1904 | + 'require_once(\'' . FileHandler::getRealPath('./config/config.inc.php') . '\'); ' . |
|
| 1905 | + '$oContext = &Context::getInstance(); ' . |
|
| 1906 | + '$oContext->init(); ' . |
|
| 1907 | + 'header("Content-Type: text/xml; charset=UTF-8"); ' . |
|
| 1908 | + 'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); ' . |
|
| 1909 | + 'header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); ' . |
|
| 1910 | + 'header("Cache-Control: no-store, no-cache, must-revalidate"); ' . |
|
| 1911 | + 'header("Cache-Control: post-check=0, pre-check=0", false); ' . |
|
| 1912 | + 'header("Pragma: no-cache"); ' . |
|
| 1913 | + '%s' . |
|
| 1914 | + '%s ' . |
|
| 1915 | + '$oContext->close();' . |
|
| 1916 | + '?>' . |
|
| 1917 | 1917 | '<root>%s</root>', |
| 1918 | 1918 | $header_script, |
| 1919 | 1919 | $xml_header_buff, |
@@ -1924,11 +1924,11 @@ discard block |
||
| 1924 | 1924 | $php_header_buff .= '$_descriptions = array();'; |
| 1925 | 1925 | $php_output = $this->getPhpCacheCode($tree[0], $tree, $module_info->site_srl, $php_header_buff); |
| 1926 | 1926 | $php_buff = sprintf( |
| 1927 | - '<?php '. |
|
| 1928 | - 'if(!defined("__XE__")) exit(); '. |
|
| 1929 | - '%s'. |
|
| 1930 | - '%s'. |
|
| 1931 | - '$menu = new stdClass;'. |
|
| 1927 | + '<?php ' . |
|
| 1928 | + 'if(!defined("__XE__")) exit(); ' . |
|
| 1929 | + '%s' . |
|
| 1930 | + '%s' . |
|
| 1931 | + '$menu = new stdClass;' . |
|
| 1932 | 1932 | '$menu->list = array(%s); ', |
| 1933 | 1933 | $header_script, |
| 1934 | 1934 | $php_header_buff, |
@@ -1952,13 +1952,13 @@ discard block |
||
| 1952 | 1952 | */ |
| 1953 | 1953 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
| 1954 | 1954 | { |
| 1955 | - if(!$source_node) return; |
|
| 1955 | + if (!$source_node) return; |
|
| 1956 | 1956 | |
| 1957 | - foreach($source_node as $category_srl => $node) |
|
| 1957 | + foreach ($source_node as $category_srl => $node) |
|
| 1958 | 1958 | { |
| 1959 | 1959 | $child_buff = ""; |
| 1960 | 1960 | // Get data of the child nodes |
| 1961 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 1961 | + if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
| 1962 | 1962 | // List variables |
| 1963 | 1963 | $expand = $node->expand; |
| 1964 | 1964 | $group_srls = $node->group_srls; |
@@ -1968,27 +1968,27 @@ discard block |
||
| 1968 | 1968 | $color = $node->color; |
| 1969 | 1969 | $description = $node->description; |
| 1970 | 1970 | // If node->group_srls value exists |
| 1971 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
| 1971 | + if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls); |
|
| 1972 | 1972 | else $group_check_code = "true"; |
| 1973 | 1973 | |
| 1974 | 1974 | $title = $node->title; |
| 1975 | 1975 | $oModuleAdminModel = getAdminModel('module'); |
| 1976 | 1976 | |
| 1977 | 1977 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
| 1978 | - if(count($langs)) |
|
| 1978 | + if (count($langs)) |
|
| 1979 | 1979 | { |
| 1980 | - foreach($langs as $key => $val) |
|
| 1980 | + foreach ($langs as $key => $val) |
|
| 1981 | 1981 | { |
| 1982 | - $xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1982 | + $xml_header_buff .= sprintf('$_titles[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1983 | 1983 | } |
| 1984 | 1984 | } |
| 1985 | 1985 | |
| 1986 | 1986 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
| 1987 | - if(count($langx)) |
|
| 1987 | + if (count($langx)) |
|
| 1988 | 1988 | { |
| 1989 | - foreach($langx as $key => $val) |
|
| 1989 | + foreach ($langx as $key => $val) |
|
| 1990 | 1990 | { |
| 1991 | - $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1991 | + $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = "%s"; ', $category_srl, $key, str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false))); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | } |
| 1994 | 1994 | |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | $category_srl, |
| 2002 | 2002 | $group_check_code, |
| 2003 | 2003 | $category_srl, |
| 2004 | - getUrl('','mid',$node->mid,'category',$category_srl), |
|
| 2004 | + getUrl('', 'mid', $node->mid, 'category', $category_srl), |
|
| 2005 | 2005 | $expand, |
| 2006 | 2006 | htmlspecialchars($color, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), |
| 2007 | 2007 | $group_check_code, |
@@ -2009,8 +2009,8 @@ discard block |
||
| 2009 | 2009 | $node->document_count |
| 2010 | 2010 | ); |
| 2011 | 2011 | |
| 2012 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2013 | - else $buff .= sprintf('<node %s />', $attribute); |
|
| 2012 | + if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
| 2013 | + else $buff .= sprintf('<node %s />', $attribute); |
|
| 2014 | 2014 | } |
| 2015 | 2015 | return $buff; |
| 2016 | 2016 | } |
@@ -2029,13 +2029,13 @@ discard block |
||
| 2029 | 2029 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
| 2030 | 2030 | { |
| 2031 | 2031 | $output = array("buff"=>"", "category_srl_list"=>array()); |
| 2032 | - if(!$source_node) return $output; |
|
| 2032 | + if (!$source_node) return $output; |
|
| 2033 | 2033 | |
| 2034 | 2034 | // Set to an arraty for looping and then generate php script codes to be included |
| 2035 | - foreach($source_node as $category_srl => $node) |
|
| 2035 | + foreach ($source_node as $category_srl => $node) |
|
| 2036 | 2036 | { |
| 2037 | 2037 | // Get data from child nodes first if exist. |
| 2038 | - if($category_srl && $tree[$category_srl]){ |
|
| 2038 | + if ($category_srl && $tree[$category_srl]) { |
|
| 2039 | 2039 | $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff); |
| 2040 | 2040 | } else { |
| 2041 | 2041 | $child_output = array("buff"=>"", "category_srl_list"=>array()); |
@@ -2046,8 +2046,8 @@ discard block |
||
| 2046 | 2046 | $output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']); |
| 2047 | 2047 | |
| 2048 | 2048 | // If node->group_srls value exists |
| 2049 | - if($node->group_srls) { |
|
| 2050 | - $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls); |
|
| 2049 | + if ($node->group_srls) { |
|
| 2050 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls); |
|
| 2051 | 2051 | } else { |
| 2052 | 2052 | $group_check_code = "true"; |
| 2053 | 2053 | } |
@@ -2062,32 +2062,32 @@ discard block |
||
| 2062 | 2062 | $oModuleAdminModel = getAdminModel('module'); |
| 2063 | 2063 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
| 2064 | 2064 | |
| 2065 | - if(count($langs)) |
|
| 2065 | + if (count($langs)) |
|
| 2066 | 2066 | { |
| 2067 | - foreach($langs as $key => $val) |
|
| 2067 | + foreach ($langs as $key => $val) |
|
| 2068 | 2068 | { |
| 2069 | 2069 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 2070 | 2070 | $php_header_buff .= sprintf( |
| 2071 | 2071 | '$_titles[%d]["%s"] = "%s"; ', |
| 2072 | 2072 | $category_srl, |
| 2073 | 2073 | $key, |
| 2074 | - str_replace('"','\\"', $val) |
|
| 2074 | + str_replace('"', '\\"', $val) |
|
| 2075 | 2075 | ); |
| 2076 | 2076 | } |
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | 2079 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
| 2080 | 2080 | |
| 2081 | - if(count($langx)) |
|
| 2081 | + if (count($langx)) |
|
| 2082 | 2082 | { |
| 2083 | - foreach($langx as $key => $val) |
|
| 2083 | + foreach ($langx as $key => $val) |
|
| 2084 | 2084 | { |
| 2085 | 2085 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 2086 | 2086 | $php_header_buff .= sprintf( |
| 2087 | 2087 | '$_descriptions[%d]["%s"] = "%s"; ', |
| 2088 | 2088 | $category_srl, |
| 2089 | 2089 | $key, |
| 2090 | - str_replace('"','\\"', $val) |
|
| 2090 | + str_replace('"', '\\"', $val) |
|
| 2091 | 2091 | ); |
| 2092 | 2092 | } |
| 2093 | 2093 | } |
@@ -2111,7 +2111,7 @@ discard block |
||
| 2111 | 2111 | ); |
| 2112 | 2112 | |
| 2113 | 2113 | // Generate buff data |
| 2114 | - $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
| 2114 | + $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | 2117 | return $output; |
@@ -2128,7 +2128,7 @@ discard block |
||
| 2128 | 2128 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
| 2129 | 2129 | { |
| 2130 | 2130 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
| 2131 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2131 | + if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
| 2132 | 2132 | |
| 2133 | 2133 | $obj = new stdClass(); |
| 2134 | 2134 | $obj->url = $url; |
@@ -2146,68 +2146,68 @@ discard block |
||
| 2146 | 2146 | */ |
| 2147 | 2147 | function procDocumentAddCart() |
| 2148 | 2148 | { |
| 2149 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2149 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2150 | 2150 | |
| 2151 | 2151 | // Get document_srl |
| 2152 | - $srls = explode(',',Context::get('srls')); |
|
| 2153 | - for($i = 0; $i < count($srls); $i++) |
|
| 2152 | + $srls = explode(',', Context::get('srls')); |
|
| 2153 | + for ($i = 0; $i < count($srls); $i++) |
|
| 2154 | 2154 | { |
| 2155 | 2155 | $srl = trim($srls[$i]); |
| 2156 | 2156 | |
| 2157 | - if(!$srl) continue; |
|
| 2157 | + if (!$srl) continue; |
|
| 2158 | 2158 | |
| 2159 | 2159 | $document_srls[] = $srl; |
| 2160 | 2160 | } |
| 2161 | - if(!count($document_srls)) return; |
|
| 2161 | + if (!count($document_srls)) return; |
|
| 2162 | 2162 | |
| 2163 | 2163 | // Get module_srl of the documents |
| 2164 | 2164 | $args = new stdClass; |
| 2165 | 2165 | $args->list_count = count($document_srls); |
| 2166 | - $args->document_srls = implode(',',$document_srls); |
|
| 2166 | + $args->document_srls = implode(',', $document_srls); |
|
| 2167 | 2167 | $args->order_type = 'asc'; |
| 2168 | 2168 | $output = executeQueryArray('document.getDocuments', $args); |
| 2169 | - if(!$output->data) return new Object(); |
|
| 2169 | + if (!$output->data) return new Object(); |
|
| 2170 | 2170 | |
| 2171 | 2171 | unset($document_srls); |
| 2172 | - foreach($output->data as $key => $val) |
|
| 2172 | + foreach ($output->data as $key => $val) |
|
| 2173 | 2173 | { |
| 2174 | 2174 | $document_srls[$val->module_srl][] = $val->document_srl; |
| 2175 | 2175 | } |
| 2176 | - if(!$document_srls || !count($document_srls)) return new Object(); |
|
| 2176 | + if (!$document_srls || !count($document_srls)) return new Object(); |
|
| 2177 | 2177 | |
| 2178 | 2178 | // 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) |
| 2179 | 2179 | $oModuleModel = getModel('module'); |
| 2180 | 2180 | $module_srls = array_keys($document_srls); |
| 2181 | - for($i=0;$i<count($module_srls);$i++) |
|
| 2181 | + for ($i = 0; $i < count($module_srls); $i++) |
|
| 2182 | 2182 | { |
| 2183 | 2183 | $module_srl = $module_srls[$i]; |
| 2184 | 2184 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
| 2185 | 2185 | $logged_info = Context::get('logged_info'); |
| 2186 | - if($logged_info->is_admin != 'Y') |
|
| 2186 | + if ($logged_info->is_admin != 'Y') |
|
| 2187 | 2187 | { |
| 2188 | - if(!$module_info) |
|
| 2188 | + if (!$module_info) |
|
| 2189 | 2189 | { |
| 2190 | 2190 | unset($document_srls[$module_srl]); |
| 2191 | 2191 | continue; |
| 2192 | 2192 | } |
| 2193 | 2193 | $grant = $oModuleModel->getGrant($module_info, $logged_info); |
| 2194 | - if(!$grant->manager) |
|
| 2194 | + if (!$grant->manager) |
|
| 2195 | 2195 | { |
| 2196 | 2196 | unset($document_srls[$module_srl]); |
| 2197 | 2197 | continue; |
| 2198 | 2198 | } |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
| 2201 | - if(!count($document_srls)) return new Object(); |
|
| 2201 | + if (!count($document_srls)) return new Object(); |
|
| 2202 | 2202 | |
| 2203 | - foreach($document_srls as $module_srl => $documents) |
|
| 2203 | + foreach ($document_srls as $module_srl => $documents) |
|
| 2204 | 2204 | { |
| 2205 | 2205 | $cnt = count($documents); |
| 2206 | - for($i=0;$i<$cnt;$i++) |
|
| 2206 | + for ($i = 0; $i < $cnt; $i++) |
|
| 2207 | 2207 | { |
| 2208 | - $document_srl = (int)trim($documents[$i]); |
|
| 2209 | - if(!$document_srls) continue; |
|
| 2210 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2208 | + $document_srl = (int) trim($documents[$i]); |
|
| 2209 | + if (!$document_srls) continue; |
|
| 2210 | + if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
| 2211 | 2211 | else $_SESSION['document_management'][$document_srl] = true; |
| 2212 | 2212 | } |
| 2213 | 2213 | } |
@@ -2220,9 +2220,9 @@ discard block |
||
| 2220 | 2220 | function procDocumentManageCheckedDocument() |
| 2221 | 2221 | { |
| 2222 | 2222 | @set_time_limit(0); |
| 2223 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 2223 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2224 | 2224 | |
| 2225 | - if(!checkCSRF()) |
|
| 2225 | + if (!checkCSRF()) |
|
| 2226 | 2226 | { |
| 2227 | 2227 | return new Object(-1, 'msg_invalid_request'); |
| 2228 | 2228 | } |
@@ -2230,44 +2230,44 @@ discard block |
||
| 2230 | 2230 | $type = Context::get('type'); |
| 2231 | 2231 | $target_module = Context::get('target_module'); |
| 2232 | 2232 | $module_srl = Context::get('module_srl'); |
| 2233 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2233 | + if ($target_module && !$module_srl) $module_srl = $target_module; |
|
| 2234 | 2234 | $category_srl = Context::get('target_category'); |
| 2235 | 2235 | $message_content = Context::get('message_content'); |
| 2236 | - if($message_content) $message_content = nl2br($message_content); |
|
| 2236 | + if ($message_content) $message_content = nl2br($message_content); |
|
| 2237 | 2237 | |
| 2238 | 2238 | $cart = Context::get('cart'); |
| 2239 | - if(!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2239 | + if (!is_array($cart)) $document_srl_list = explode('|@|', $cart); |
|
| 2240 | 2240 | else $document_srl_list = $cart; |
| 2241 | 2241 | |
| 2242 | 2242 | $document_srl_count = count($document_srl_list); |
| 2243 | 2243 | |
| 2244 | 2244 | $oDocumentModel = getModel('document'); |
| 2245 | 2245 | $document_items = array(); |
| 2246 | - foreach($document_srl_list as $document_srl) |
|
| 2246 | + foreach ($document_srl_list as $document_srl) |
|
| 2247 | 2247 | { |
| 2248 | 2248 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 2249 | 2249 | $document_items[] = $oDocument; |
| 2250 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2250 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | // Send a message |
| 2254 | - if($message_content) |
|
| 2254 | + if ($message_content) |
|
| 2255 | 2255 | { |
| 2256 | 2256 | |
| 2257 | 2257 | $oCommunicationController = getController('communication'); |
| 2258 | 2258 | |
| 2259 | 2259 | $logged_info = Context::get('logged_info'); |
| 2260 | 2260 | |
| 2261 | - $title = cut_str($message_content,10,'...'); |
|
| 2261 | + $title = cut_str($message_content, 10, '...'); |
|
| 2262 | 2262 | $sender_member_srl = $logged_info->member_srl; |
| 2263 | 2263 | |
| 2264 | - foreach($document_items as $oDocument) |
|
| 2264 | + foreach ($document_items as $oDocument) |
|
| 2265 | 2265 | { |
| 2266 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
| 2266 | + if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue; |
|
| 2267 | 2267 | |
| 2268 | - if($type=='move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2268 | + if ($type == 'move') $purl = sprintf("<a href=\"%s\" onclick=\"window.open(this.href);return false;\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
| 2269 | 2269 | else $purl = ""; |
| 2270 | - $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)); |
|
| 2270 | + $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
| 2271 | 2271 | |
| 2272 | 2272 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
| 2273 | 2273 | } |
@@ -2277,54 +2277,54 @@ discard block |
||
| 2277 | 2277 | $oSpamController->setAvoidLog(); |
| 2278 | 2278 | |
| 2279 | 2279 | $oDocumentAdminController = getAdminController('document'); |
| 2280 | - if($type == 'move') |
|
| 2280 | + if ($type == 'move') |
|
| 2281 | 2281 | { |
| 2282 | - if(!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2282 | + if (!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2283 | 2283 | |
| 2284 | 2284 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2285 | - if(!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2285 | + if (!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2286 | 2286 | |
| 2287 | 2287 | $msg_code = 'success_moved'; |
| 2288 | 2288 | |
| 2289 | 2289 | } |
| 2290 | - else if($type == 'copy') |
|
| 2290 | + else if ($type == 'copy') |
|
| 2291 | 2291 | { |
| 2292 | - if(!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2292 | + if (!$module_srl) return new Object(-1, 'fail_to_move'); |
|
| 2293 | 2293 | |
| 2294 | 2294 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
| 2295 | - if(!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2295 | + if (!$output->toBool()) return new Object(-1, 'fail_to_move'); |
|
| 2296 | 2296 | |
| 2297 | 2297 | $msg_code = 'success_copied'; |
| 2298 | 2298 | } |
| 2299 | - else if($type =='delete') |
|
| 2299 | + else if ($type == 'delete') |
|
| 2300 | 2300 | { |
| 2301 | 2301 | $oDB = &DB::getInstance(); |
| 2302 | 2302 | $oDB->begin(); |
| 2303 | - for($i=0;$i<$document_srl_count;$i++) |
|
| 2303 | + for ($i = 0; $i < $document_srl_count; $i++) |
|
| 2304 | 2304 | { |
| 2305 | 2305 | $document_srl = $document_srl_list[$i]; |
| 2306 | 2306 | $output = $this->deleteDocument($document_srl, true); |
| 2307 | - if(!$output->toBool()) return new Object(-1, 'fail_to_delete'); |
|
| 2307 | + if (!$output->toBool()) return new Object(-1, 'fail_to_delete'); |
|
| 2308 | 2308 | } |
| 2309 | 2309 | $oDB->commit(); |
| 2310 | 2310 | $msg_code = 'success_deleted'; |
| 2311 | 2311 | } |
| 2312 | - else if($type == 'trash') |
|
| 2312 | + else if ($type == 'trash') |
|
| 2313 | 2313 | { |
| 2314 | 2314 | $args = new stdClass(); |
| 2315 | 2315 | $args->description = $message_content; |
| 2316 | 2316 | |
| 2317 | 2317 | $oDB = &DB::getInstance(); |
| 2318 | 2318 | $oDB->begin(); |
| 2319 | - for($i=0;$i<$document_srl_count;$i++) { |
|
| 2319 | + for ($i = 0; $i < $document_srl_count; $i++) { |
|
| 2320 | 2320 | $args->document_srl = $document_srl_list[$i]; |
| 2321 | 2321 | $output = $this->moveDocumentToTrash($args); |
| 2322 | - if(!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash'); |
|
| 2322 | + if (!$output || !$output->toBool()) return new Object(-1, 'fail_to_trash'); |
|
| 2323 | 2323 | } |
| 2324 | 2324 | $oDB->commit(); |
| 2325 | 2325 | $msg_code = 'success_trashed'; |
| 2326 | 2326 | } |
| 2327 | - else if($type == 'cancelDeclare') |
|
| 2327 | + else if ($type == 'cancelDeclare') |
|
| 2328 | 2328 | { |
| 2329 | 2329 | $args->document_srl = $document_srl_list; |
| 2330 | 2330 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2346,27 +2346,27 @@ discard block |
||
| 2346 | 2346 | function procDocumentInsertModuleConfig() |
| 2347 | 2347 | { |
| 2348 | 2348 | $module_srl = Context::get('target_module_srl'); |
| 2349 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 2349 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
| 2350 | 2350 | else $module_srl = array($module_srl); |
| 2351 | 2351 | |
| 2352 | 2352 | $document_config = new stdClass(); |
| 2353 | 2353 | $document_config->use_history = Context::get('use_history'); |
| 2354 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2354 | + if (!$document_config->use_history) $document_config->use_history = 'N'; |
|
| 2355 | 2355 | |
| 2356 | 2356 | $document_config->use_vote_up = Context::get('use_vote_up'); |
| 2357 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2357 | + if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
| 2358 | 2358 | |
| 2359 | 2359 | $document_config->use_vote_down = Context::get('use_vote_down'); |
| 2360 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2360 | + if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
| 2361 | 2361 | |
| 2362 | 2362 | $document_config->use_status = Context::get('use_status'); |
| 2363 | 2363 | |
| 2364 | 2364 | $oModuleController = getController('module'); |
| 2365 | - for($i=0;$i<count($module_srl);$i++) |
|
| 2365 | + for ($i = 0; $i < count($module_srl); $i++) |
|
| 2366 | 2366 | { |
| 2367 | 2367 | $srl = trim($module_srl[$i]); |
| 2368 | - if(!$srl) continue; |
|
| 2369 | - $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
|
| 2368 | + if (!$srl) continue; |
|
| 2369 | + $output = $oModuleController->insertModulePartConfig('document', $srl, $document_config); |
|
| 2370 | 2370 | } |
| 2371 | 2371 | $this->setError(-1); |
| 2372 | 2372 | $this->setMessage('success_updated', 'info'); |
@@ -2382,7 +2382,7 @@ discard block |
||
| 2382 | 2382 | function procDocumentTempSave() |
| 2383 | 2383 | { |
| 2384 | 2384 | // Check login information |
| 2385 | - if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); |
|
| 2385 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_logged'); |
|
| 2386 | 2386 | $module_info = Context::get('module_info'); |
| 2387 | 2387 | $logged_info = Context::get('logged_info'); |
| 2388 | 2388 | |
@@ -2394,7 +2394,7 @@ discard block |
||
| 2394 | 2394 | unset($obj->is_notice); |
| 2395 | 2395 | |
| 2396 | 2396 | // Extract from beginning part of contents in the guestbook |
| 2397 | - if(!$obj->title) |
|
| 2397 | + if (!$obj->title) |
|
| 2398 | 2398 | { |
| 2399 | 2399 | $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
| 2400 | 2400 | } |
@@ -2405,13 +2405,13 @@ discard block |
||
| 2405 | 2405 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
| 2406 | 2406 | |
| 2407 | 2407 | // Update if already exists |
| 2408 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 2408 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 2409 | 2409 | { |
| 2410 | - if($oDocument->get('module_srl') != $obj->module_srl) |
|
| 2410 | + if ($oDocument->get('module_srl') != $obj->module_srl) |
|
| 2411 | 2411 | { |
| 2412 | 2412 | return new Object(-1, 'msg_invalid_request'); |
| 2413 | 2413 | } |
| 2414 | - if(!$oDocument->isGranted()) |
|
| 2414 | + if (!$oDocument->isGranted()) |
|
| 2415 | 2415 | { |
| 2416 | 2416 | return new Object(-1, 'msg_invalid_request'); |
| 2417 | 2417 | } |
@@ -2429,7 +2429,7 @@ discard block |
||
| 2429 | 2429 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
| 2430 | 2430 | } |
| 2431 | 2431 | // Set the attachment to be invalid state |
| 2432 | - if($oDocument->hasUploadedFiles()) |
|
| 2432 | + if ($oDocument->hasUploadedFiles()) |
|
| 2433 | 2433 | { |
| 2434 | 2434 | $args = new stdClass; |
| 2435 | 2435 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -2447,11 +2447,11 @@ discard block |
||
| 2447 | 2447 | */ |
| 2448 | 2448 | function procDocumentGetList() |
| 2449 | 2449 | { |
| 2450 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 2450 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 2451 | 2451 | $documentSrls = Context::get('document_srls'); |
| 2452 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2452 | + if ($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
| 2453 | 2453 | |
| 2454 | - if(count($documentSrlList) > 0) |
|
| 2454 | + if (count($documentSrlList) > 0) |
|
| 2455 | 2455 | { |
| 2456 | 2456 | $oDocumentModel = getModel('document'); |
| 2457 | 2457 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
@@ -2475,10 +2475,10 @@ discard block |
||
| 2475 | 2475 | */ |
| 2476 | 2476 | function _checkCommentStatusForOldVersion(&$obj) |
| 2477 | 2477 | { |
| 2478 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2479 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2478 | + if (!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
| 2479 | + if (!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
| 2480 | 2480 | |
| 2481 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2481 | + if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
| 2482 | 2482 | else $obj->commentStatus = 'DENY'; |
| 2483 | 2483 | } |
| 2484 | 2484 | |
@@ -2489,8 +2489,8 @@ discard block |
||
| 2489 | 2489 | */ |
| 2490 | 2490 | function _checkDocumentStatusForOldVersion(&$obj) |
| 2491 | 2491 | { |
| 2492 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2493 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2492 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
| 2493 | + if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
| 2494 | 2494 | } |
| 2495 | 2495 | |
| 2496 | 2496 | public function updateUploaedCount($documentSrlList) |
@@ -2498,10 +2498,10 @@ discard block |
||
| 2498 | 2498 | $oDocumentModel = getModel('document'); |
| 2499 | 2499 | $oFileModel = getModel('file'); |
| 2500 | 2500 | |
| 2501 | - if(is_array($documentSrlList)) |
|
| 2501 | + if (is_array($documentSrlList)) |
|
| 2502 | 2502 | { |
| 2503 | 2503 | $documentSrlList = array_unique($documentSrlList); |
| 2504 | - foreach($documentSrlList AS $key => $documentSrl) |
|
| 2504 | + foreach ($documentSrlList AS $key => $documentSrl) |
|
| 2505 | 2505 | { |
| 2506 | 2506 | $fileCount = $oFileModel->getFilesCount($documentSrl); |
| 2507 | 2507 | $args = new stdClass(); |
@@ -2522,14 +2522,14 @@ discard block |
||
| 2522 | 2522 | $oDocumentModel = getModel('document'); |
| 2523 | 2523 | $documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl); |
| 2524 | 2524 | |
| 2525 | - if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
| 2525 | + if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
| 2526 | 2526 | { |
| 2527 | - $oDocumentController=getController('document'); |
|
| 2528 | - foreach($obj->moduleSrlList AS $key=>$value) |
|
| 2527 | + $oDocumentController = getController('document'); |
|
| 2528 | + foreach ($obj->moduleSrlList AS $key=>$value) |
|
| 2529 | 2529 | { |
| 2530 | - foreach($documentExtraKeys AS $extraItem) |
|
| 2530 | + foreach ($documentExtraKeys AS $extraItem) |
|
| 2531 | 2531 | { |
| 2532 | - $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ; |
|
| 2532 | + $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid); |
|
| 2533 | 2533 | } |
| 2534 | 2534 | } |
| 2535 | 2535 | } |
@@ -2541,9 +2541,9 @@ discard block |
||
| 2541 | 2541 | $documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl); |
| 2542 | 2542 | |
| 2543 | 2543 | $oModuleController = getController('module'); |
| 2544 | - if(is_array($obj->moduleSrlList)) |
|
| 2544 | + if (is_array($obj->moduleSrlList)) |
|
| 2545 | 2545 | { |
| 2546 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 2546 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 2547 | 2547 | { |
| 2548 | 2548 | $oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig); |
| 2549 | 2549 | } |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | function procBoardInsertDocument() |
| 24 | 24 | { |
| 25 | 25 | // check grant |
| 26 | - if($this->module_info->module != "board") |
|
| 26 | + if ($this->module_info->module != "board") |
|
| 27 | 27 | { |
| 28 | 28 | return new Object(-1, "msg_invalid_request"); |
| 29 | 29 | } |
| 30 | - if(!$this->grant->write_document) |
|
| 30 | + if (!$this->grant->write_document) |
|
| 31 | 31 | { |
| 32 | 32 | return new Object(-1, 'msg_not_permitted'); |
| 33 | 33 | } |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | // setup variables |
| 37 | 37 | $obj = Context::getRequestVars(); |
| 38 | 38 | $obj->module_srl = $this->module_srl; |
| 39 | - if($obj->is_notice!='Y'||!$this->grant->manager) $obj->is_notice = 'N'; |
|
| 39 | + if ($obj->is_notice != 'Y' || !$this->grant->manager) $obj->is_notice = 'N'; |
|
| 40 | 40 | $obj->commentStatus = $obj->comment_status; |
| 41 | 41 | |
| 42 | 42 | settype($obj->title, "string"); |
| 43 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
| 43 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
| 44 | 44 | //setup dpcument title tp 'Untitled' |
| 45 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
| 45 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
| 46 | 46 | |
| 47 | 47 | // unset document style if the user is not the document manager |
| 48 | - if(!$this->grant->manager) |
|
| 48 | + if (!$this->grant->manager) |
|
| 49 | 49 | { |
| 50 | 50 | unset($obj->title_color); |
| 51 | 51 | unset($obj->title_bold); |
@@ -62,24 +62,24 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // update the document if it is existed |
| 64 | 64 | $is_update = false; |
| 65 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 65 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
| 66 | 66 | { |
| 67 | 67 | $is_update = true; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // if use anonymous is true |
| 71 | - if($this->module_info->use_anonymous == 'Y') |
|
| 71 | + if ($this->module_info->use_anonymous == 'Y') |
|
| 72 | 72 | { |
| 73 | 73 | $this->module_info->admin_mail = ''; |
| 74 | 74 | $obj->notify_message = 'N'; |
| 75 | - if($is_update===false) |
|
| 75 | + if ($is_update === false) |
|
| 76 | 76 | { |
| 77 | - $obj->member_srl = -1*$logged_info->member_srl; |
|
| 77 | + $obj->member_srl = -1 * $logged_info->member_srl; |
|
| 78 | 78 | } |
| 79 | 79 | $obj->email_address = $obj->homepage = $obj->user_id = ''; |
| 80 | 80 | $obj->user_name = $obj->nick_name = 'anonymous'; |
| 81 | 81 | $bAnonymous = true; |
| 82 | - if($is_update===false) |
|
| 82 | + if ($is_update === false) |
|
| 83 | 83 | { |
| 84 | 84 | $oDocument->add('member_srl', $obj->member_srl); |
| 85 | 85 | } |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | $bAnonymous = false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if($obj->is_secret == 'Y' || strtoupper($obj->status == 'SECRET')) |
|
| 92 | + if ($obj->is_secret == 'Y' || strtoupper($obj->status == 'SECRET')) |
|
| 93 | 93 | { |
| 94 | 94 | $use_status = explode('|@|', $this->module_info->use_status); |
| 95 | - if(!is_array($use_status) || !in_array('SECRET', $use_status)) |
|
| 95 | + if (!is_array($use_status) || !in_array('SECRET', $use_status)) |
|
| 96 | 96 | { |
| 97 | 97 | unset($obj->is_secret); |
| 98 | 98 | $obj->status = 'PUBLIC'; |
@@ -100,24 +100,24 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // update the document if it is existed |
| 103 | - if($is_update) |
|
| 103 | + if ($is_update) |
|
| 104 | 104 | { |
| 105 | - if(!$oDocument->isGranted()) |
|
| 105 | + if (!$oDocument->isGranted()) |
|
| 106 | 106 | { |
| 107 | - return new Object(-1,'msg_not_permitted'); |
|
| 107 | + return new Object(-1, 'msg_not_permitted'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if($this->module_info->use_anonymous == 'Y') { |
|
| 110 | + if ($this->module_info->use_anonymous == 'Y') { |
|
| 111 | 111 | $obj->member_srl = $oDocument->get('member_srl') * -1; |
| 112 | 112 | $oDocument->add('member_srl', $obj->member_srl); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false) |
|
| 115 | + if ($this->module_info->protect_content == "Y" && $oDocument->get('comment_count') > 0 && $this->grant->manager == false) |
|
| 116 | 116 | { |
| 117 | - return new Object(-1,'msg_protect_content'); |
|
| 117 | + return new Object(-1, 'msg_protect_content'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if(!$this->grant->manager) |
|
| 120 | + if (!$this->grant->manager) |
|
| 121 | 121 | { |
| 122 | 122 | // notice & document style same as before if not manager |
| 123 | 123 | $obj->is_notice = $oDocument->get('is_notice'); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // modify list_order if document status is temp |
| 129 | - if($oDocument->get('status') == 'TEMP') |
|
| 129 | + if ($oDocument->get('status') == 'TEMP') |
|
| 130 | 130 | { |
| 131 | 131 | $obj->last_update = $obj->regdate = date('YmdHis'); |
| 132 | 132 | $obj->update_order = $obj->list_order = (getNextSequence() * -1); |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | $obj->document_srl = $output->get('document_srl'); |
| 143 | 143 | |
| 144 | 144 | // send an email to admin user |
| 145 | - if($output->toBool() && $this->module_info->admin_mail) |
|
| 145 | + if ($output->toBool() && $this->module_info->admin_mail) |
|
| 146 | 146 | { |
| 147 | 147 | $oMail = new Mail(); |
| 148 | 148 | $oMail->setTitle($obj->title); |
| 149 | - $oMail->setContent( sprintf("From : <a href=\"%s\">%s</a><br/>\r\n%s", getFullUrl('','document_srl',$obj->document_srl), getFullUrl('','document_srl',$obj->document_srl), $obj->content)); |
|
| 149 | + $oMail->setContent(sprintf("From : <a href=\"%s\">%s</a><br/>\r\n%s", getFullUrl('', 'document_srl', $obj->document_srl), getFullUrl('', 'document_srl', $obj->document_srl), $obj->content)); |
|
| 150 | 150 | $oMail->setSender($obj->user_name, $obj->email_address); |
| 151 | 151 | |
| 152 | - $target_mail = explode(',',$this->module_info->admin_mail); |
|
| 153 | - for($i=0;$i<count($target_mail);$i++) |
|
| 152 | + $target_mail = explode(',', $this->module_info->admin_mail); |
|
| 153 | + for ($i = 0; $i < count($target_mail); $i++) |
|
| 154 | 154 | { |
| 155 | 155 | $email_address = trim($target_mail[$i]); |
| 156 | - if(!$email_address) continue; |
|
| 156 | + if (!$email_address) continue; |
|
| 157 | 157 | $oMail->setReceiptor($email_address, $email_address); |
| 158 | 158 | $oMail->send(); |
| 159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // if there is an error |
| 164 | - if(!$output->toBool()) |
|
| 164 | + if (!$output->toBool()) |
|
| 165 | 165 | { |
| 166 | 166 | return $output; |
| 167 | 167 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $document_srl = Context::get('document_srl'); |
| 184 | 184 | |
| 185 | 185 | // if the document is not existed |
| 186 | - if(!$document_srl) |
|
| 186 | + if (!$document_srl) |
|
| 187 | 187 | { |
| 188 | 188 | return $this->doError('msg_invalid_document'); |
| 189 | 189 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $oDocumentModel = &getModel('document'); |
| 192 | 192 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 193 | 193 | // check protect content |
| 194 | - if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false) |
|
| 194 | + if ($this->module_info->protect_content == "Y" && $oDocument->get('comment_count') > 0 && $this->grant->manager == false) |
|
| 195 | 195 | { |
| 196 | 196 | return new Object(-1, 'msg_protect_content'); |
| 197 | 197 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | // delete the document |
| 203 | 203 | $output = $oDocumentController->deleteDocument($document_srl, $this->grant->manager); |
| 204 | - if(!$output->toBool()) |
|
| 204 | + if (!$output->toBool()) |
|
| 205 | 205 | { |
| 206 | 206 | return $output; |
| 207 | 207 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | function procBoardInsertComment() |
| 232 | 232 | { |
| 233 | 233 | // check grant |
| 234 | - if(!$this->grant->write_comment) |
|
| 234 | + if (!$this->grant->write_comment) |
|
| 235 | 235 | { |
| 236 | 236 | return new Object(-1, 'msg_not_permitted'); |
| 237 | 237 | } |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | $obj = Context::getRequestVars(); |
| 242 | 242 | $obj->module_srl = $this->module_srl; |
| 243 | 243 | |
| 244 | - if(!$this->module_info->use_status) $this->module_info->use_status = 'PUBLIC'; |
|
| 245 | - if(!is_array($this->module_info->use_status)) |
|
| 244 | + if (!$this->module_info->use_status) $this->module_info->use_status = 'PUBLIC'; |
|
| 245 | + if (!is_array($this->module_info->use_status)) |
|
| 246 | 246 | { |
| 247 | 247 | $this->module_info->use_status = explode('|@|', $this->module_info->use_status); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if(in_array('SECRET', $this->module_info->use_status)) |
|
| 250 | + if (in_array('SECRET', $this->module_info->use_status)) |
|
| 251 | 251 | { |
| 252 | 252 | $this->module_info->secret = 'Y'; |
| 253 | 253 | } |
@@ -260,17 +260,17 @@ discard block |
||
| 260 | 260 | // check if the doument is existed |
| 261 | 261 | $oDocumentModel = getModel('document'); |
| 262 | 262 | $oDocument = $oDocumentModel->getDocument($obj->document_srl); |
| 263 | - if(!$oDocument->isExists()) |
|
| 263 | + if (!$oDocument->isExists()) |
|
| 264 | 264 | { |
| 265 | - return new Object(-1,'msg_not_founded'); |
|
| 265 | + return new Object(-1, 'msg_not_founded'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // For anonymous use, remove writer's information and notifying information |
| 269 | - if($this->module_info->use_anonymous == 'Y') |
|
| 269 | + if ($this->module_info->use_anonymous == 'Y') |
|
| 270 | 270 | { |
| 271 | 271 | $this->module_info->admin_mail = ''; |
| 272 | 272 | $obj->notify_message = 'N'; |
| 273 | - $obj->member_srl = -1*$logged_info->member_srl; |
|
| 273 | + $obj->member_srl = -1 * $logged_info->member_srl; |
|
| 274 | 274 | $obj->email_address = $obj->homepage = $obj->user_id = ''; |
| 275 | 275 | $obj->user_name = $obj->nick_name = 'anonymous'; |
| 276 | 276 | $bAnonymous = true; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | // check the comment is existed |
| 290 | 290 | // if the comment is not existed, then generate a new sequence |
| 291 | - if(!$obj->comment_srl) |
|
| 291 | + if (!$obj->comment_srl) |
|
| 292 | 292 | { |
| 293 | 293 | $obj->comment_srl = getNextSequence(); |
| 294 | 294 | } else { |
@@ -296,14 +296,14 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // if comment_srl is not existed, then insert the comment |
| 299 | - if($comment->comment_srl != $obj->comment_srl) |
|
| 299 | + if ($comment->comment_srl != $obj->comment_srl) |
|
| 300 | 300 | { |
| 301 | 301 | |
| 302 | 302 | // parent_srl is existed |
| 303 | - if($obj->parent_srl) |
|
| 303 | + if ($obj->parent_srl) |
|
| 304 | 304 | { |
| 305 | 305 | $parent_comment = $oCommentModel->getComment($obj->parent_srl); |
| 306 | - if(!$parent_comment->comment_srl) |
|
| 306 | + if (!$parent_comment->comment_srl) |
|
| 307 | 307 | { |
| 308 | 308 | return new Object(-1, 'msg_invalid_request'); |
| 309 | 309 | } |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | // update the comment if it is not existed |
| 318 | 318 | } else { |
| 319 | 319 | // check the grant |
| 320 | - if(!$comment->isGranted()) |
|
| 320 | + if (!$comment->isGranted()) |
|
| 321 | 321 | { |
| 322 | - return new Object(-1,'msg_not_permitted'); |
|
| 322 | + return new Object(-1, 'msg_not_permitted'); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | $obj->parent_srl = $comment->parent_srl; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $comment_srl = $obj->comment_srl; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if(!$output->toBool()) |
|
| 330 | + if (!$output->toBool()) |
|
| 331 | 331 | { |
| 332 | 332 | return $output; |
| 333 | 333 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | { |
| 346 | 346 | // get the comment_srl |
| 347 | 347 | $comment_srl = Context::get('comment_srl'); |
| 348 | - if(!$comment_srl) |
|
| 348 | + if (!$comment_srl) |
|
| 349 | 349 | { |
| 350 | 350 | return $this->doError('msg_invalid_request'); |
| 351 | 351 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | $oCommentController = getController('comment'); |
| 355 | 355 | |
| 356 | 356 | $output = $oCommentController->deleteComment($comment_srl, $this->grant->manager); |
| 357 | - if(!$output->toBool()) |
|
| 357 | + if (!$output->toBool()) |
|
| 358 | 358 | { |
| 359 | 359 | return $output; |
| 360 | 360 | } |
@@ -375,10 +375,10 @@ discard block |
||
| 375 | 375 | // generate trackback module controller object |
| 376 | 376 | $oTrackbackController = getController('trackback'); |
| 377 | 377 | |
| 378 | - if(!$oTrackbackController) return; |
|
| 378 | + if (!$oTrackbackController) return; |
|
| 379 | 379 | |
| 380 | 380 | $output = $oTrackbackController->deleteTrackback($trackback_srl, $this->grant->manager); |
| 381 | - if(!$output->toBool()) |
|
| 381 | + if (!$output->toBool()) |
|
| 382 | 382 | { |
| 383 | 383 | return $output; |
| 384 | 384 | } |
@@ -402,18 +402,18 @@ discard block |
||
| 402 | 402 | $oMemberModel = getModel('member'); |
| 403 | 403 | |
| 404 | 404 | // if the comment exists |
| 405 | - if($comment_srl) |
|
| 405 | + if ($comment_srl) |
|
| 406 | 406 | { |
| 407 | 407 | // get the comment information |
| 408 | 408 | $oCommentModel = getModel('comment'); |
| 409 | 409 | $oComment = $oCommentModel->getComment($comment_srl); |
| 410 | - if(!$oComment->isExists()) |
|
| 410 | + if (!$oComment->isExists()) |
|
| 411 | 411 | { |
| 412 | 412 | return new Object(-1, 'msg_invalid_request'); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // compare the comment password and the user input password |
| 416 | - if(!$oMemberModel->isValidPassword($oComment->get('password'),$password)) |
|
| 416 | + if (!$oMemberModel->isValidPassword($oComment->get('password'), $password)) |
|
| 417 | 417 | { |
| 418 | 418 | return new Object(-1, 'msg_invalid_password'); |
| 419 | 419 | } |
@@ -423,13 +423,13 @@ discard block |
||
| 423 | 423 | // get the document information |
| 424 | 424 | $oDocumentModel = getModel('document'); |
| 425 | 425 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 426 | - if(!$oDocument->isExists()) |
|
| 426 | + if (!$oDocument->isExists()) |
|
| 427 | 427 | { |
| 428 | 428 | return new Object(-1, 'msg_invalid_request'); |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | // compare the document password and the user input password |
| 432 | - if(!$oMemberModel->isValidPassword($oDocument->get('password'),$password)) |
|
| 432 | + if (!$oMemberModel->isValidPassword($oDocument->get('password'), $password)) |
|
| 433 | 433 | { |
| 434 | 434 | return new Object(-1, 'msg_invalid_password'); |
| 435 | 435 | } |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | $member_srl = Context::get('target_srl'); |
| 447 | 447 | $mid = Context::get('cur_mid'); |
| 448 | 448 | |
| 449 | - if(!$member_srl || !$mid) |
|
| 449 | + if (!$member_srl || !$mid) |
|
| 450 | 450 | { |
| 451 | 451 | return new Object(); |
| 452 | 452 | } |
@@ -458,13 +458,13 @@ discard block |
||
| 458 | 458 | $columnList = array('module'); |
| 459 | 459 | $cur_module_info = $oModuleModel->getModuleInfoByMid($mid, 0, $columnList); |
| 460 | 460 | |
| 461 | - if($cur_module_info->module != 'board') |
|
| 461 | + if ($cur_module_info->module != 'board') |
|
| 462 | 462 | { |
| 463 | 463 | return new Object(); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // get the member information |
| 467 | - if($member_srl == $logged_info->member_srl) |
|
| 467 | + if ($member_srl == $logged_info->member_srl) |
|
| 468 | 468 | { |
| 469 | 469 | $member_info = $logged_info; |
| 470 | 470 | } else { |
@@ -472,13 +472,13 @@ discard block |
||
| 472 | 472 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if(!$member_info->user_id) |
|
| 475 | + if (!$member_info->user_id) |
|
| 476 | 476 | { |
| 477 | 477 | return new Object(); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | //search |
| 481 | - $url = getUrl('','mid',$mid,'search_target','nick_name','search_keyword',$member_info->nick_name); |
|
| 481 | + $url = getUrl('', 'mid', $mid, 'search_target', 'nick_name', 'search_keyword', $member_info->nick_name); |
|
| 482 | 482 | $oMemberController = getController('member'); |
| 483 | 483 | $oMemberController->addMemberPopupMenu($url, 'cmd_view_own_document', ''); |
| 484 | 484 | |