39 if($document_config->use_vote_up==
'N')
return new BaseObject(-1,
'msg_invalid_request');
43 $this->
add(
'voted_count',
$output->get(
'voted_count'));
60 $args->alias_title = urldecode($alias_title);
61 $query =
"document.insertAlias";
84 if($document_config->use_vote_down==
'N')
return new BaseObject(-1,
'msg_invalid_request');
88 $this->
add(
'blamed_count',
$output->get(
'blamed_count'));
113 $args =
new stdClass();
125 $args =
new stdClass();
139 $args =
new stdClass();
140 $args->history_srl = $history_srl;
143 if(!
$args->history_srl && !
$args->module_srl && !
$args->document_srl)
return;
198 return new BaseObject(-1,
'msg_invalid_request');
205 if(
$obj->comment_status)
$obj->commentStatus =
$obj->comment_status;
206 if(!
$obj->commentStatus)
$obj->commentStatus =
'DENY';
208 if(
$obj->allow_trackback!=
'Y')
$obj->allow_trackback =
'N';
212 if(!preg_match(
'/^[a-z]+:\/\//i',
$obj->homepage))
214 $obj->homepage =
'http://'.$obj->homepage;
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'];
226 unset(
$obj->regdate);
230 if(!is_string(
$obj->extra_vars))
$obj->extra_vars = serialize(
$obj->extra_vars);
232 unset(
$obj->_saved_doc_srl);
233 unset(
$obj->_saved_doc_title);
234 unset(
$obj->_saved_doc_content);
235 unset(
$obj->_saved_doc_message);
245 if(
$obj->category_srl)
248 if(count($category_list) > 0 && !$category_list[
$obj->category_srl]->grant)
250 return new BaseObject(-1,
'msg_not_permitted');
252 if(count($category_list) > 0 && !$category_list[
$obj->category_srl])
$obj->category_srl = 0;
255 if(!
$obj->readed_count)
$obj->readed_count = 0;
256 if($isLatest)
$obj->update_order =
$obj->list_order =
$obj->document_srl * -1;
257 else $obj->update_order =
$obj->list_order;
259 if(
$obj->password && !
$obj->password_is_hashed)
265 if(
Context::get(
'is_logged') && !$manual_inserted && !$isRestore)
277 $obj->title = htmlspecialchars(
$obj->title, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false);
278 settype(
$obj->title,
"string");
279 if(
$obj->title ==
'')
$obj->title =
cut_str(trim(strip_tags(nl2br(
$obj->content))),20,
'...');
281 if(
$obj->title ==
'')
$obj->title =
'Untitled';
283 $obj->content = preg_replace(
'!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is',
'',
$obj->content);
286 if(
$obj->use_html !=
'Y')
288 $obj->content = htmlspecialchars(
$obj->content, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false);
290 $obj->content = nl2br(
$obj->content);
308 if(count($extra_keys))
310 foreach($extra_keys as $idx => $extra_item)
313 if(isset(
$obj->{
'extra_vars'.$idx}))
315 $tmp =
$obj->{
'extra_vars'.$idx};
317 $value = implode(
'|@|', $tmp);
321 else if(isset(
$obj->{$extra_item->name})) $value = trim(
$obj->{$extra_item->name});
322 if($value == NULL)
continue;
324 $this->insertDocumentExtraVar(
$obj->module_srl,
$obj->document_srl, $idx, $value, $extra_item->eid);
328 if(
$obj->category_srl) $this->updateCategoryCount(
$obj->module_srl,
$obj->category_srl);
333 if(!$trigger_output->toBool())
336 return $trigger_output;
344 if(!$manual_inserted)
346 $this->addGrant(
$obj->document_srl);
367 return new BaseObject(-1,
'msg_invalid_request');
370 if(!$source_obj->document_srl || !
$obj->document_srl)
return new BaseObject(-1,
'msg_invalied_request');
371 if(!
$obj->status &&
$obj->is_secret ==
'Y')
$obj->status =
'SECRET';
372 if(!
$obj->status)
$obj->status =
'PUBLIC';
383 if(!
$obj->module_srl)
$obj->module_srl = $source_obj->get(
'module_srl');
386 if(!$document_config)
388 $document_config =
new stdClass();
390 if(!isset($document_config->use_history)) $document_config->use_history =
'N';
391 $bUseHistory = $document_config->use_history ==
'Y' || $document_config->use_history ==
'Trace';
395 $args =
new stdClass;
397 $args->document_srl =
$obj->document_srl;
399 if($document_config->use_history ==
'Y')
$args->content = $source_obj->get(
'content');
402 $args->regdate = $source_obj->get(
'last_update');
403 $args->ipaddress = $_SERVER[
'REMOTE_ADDR'];
408 $obj->ipaddress = $source_obj->get(
'ipaddress');
411 if(
$obj->comment_status)
$obj->commentStatus =
$obj->comment_status;
412 if(!
$obj->commentStatus)
$obj->commentStatus =
'DENY';
413 if(
$obj->commentStatus ==
'DENY') $this->_checkCommentStatusForOldVersion(
$obj);
414 if(
$obj->allow_trackback!=
'Y')
$obj->allow_trackback =
'N';
418 if(!preg_match(
'/^[a-z]+:\/\//i',
$obj->homepage))
420 $obj->homepage =
'http://'.$obj->homepage;
424 if(
$obj->notify_message !=
'Y')
$obj->notify_message =
'N';
430 unset(
$obj->regdate);
434 if(!is_string(
$obj->extra_vars))
$obj->extra_vars = serialize(
$obj->extra_vars);
436 unset(
$obj->_saved_doc_srl);
437 unset(
$obj->_saved_doc_title);
438 unset(
$obj->_saved_doc_content);
439 unset(
$obj->_saved_doc_message);
443 if($source_obj->get(
'category_srl')!=
$obj->category_srl)
446 if(!$category_list[
$obj->category_srl])
$obj->category_srl = 0;
459 if($source_obj->get(
'member_srl')==
$logged_info->member_srl)
470 if($source_obj->get(
'member_srl')&& !
$obj->nick_name)
472 $obj->member_srl = $source_obj->get(
'member_srl');
473 $obj->user_name = $source_obj->get(
'user_name');
474 $obj->nick_name = $source_obj->get(
'nick_name');
475 $obj->email_address = $source_obj->get(
'email_address');
476 $obj->homepage = $source_obj->get(
'homepage');
479 $obj->title = htmlspecialchars(
$obj->title, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false);
480 settype(
$obj->title,
"string");
483 if(
$obj->title ==
'')
$obj->title =
'Untitled';
485 $obj->content = preg_replace(
'!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is',
'',
$obj->content);
488 if(
$obj->use_html !=
'Y')
490 $obj->content = htmlspecialchars(
$obj->content, ENT_COMPAT | ENT_HTML401,
'UTF-8',
false);
492 $obj->content = nl2br(
$obj->content);
498 if(!$source_obj->get(
'lang_code'))
500 $lang_code_args->document_srl = $source_obj->get(
'document_srl');
506 $extra_content =
new stdClass;
507 $extra_content->title =
$obj->title;
508 $extra_content->content =
$obj->content;
510 $document_args =
new stdClass;
511 $document_args->document_srl = $source_obj->get(
'document_srl');
512 $document_output =
executeQuery(
'document.getDocument', $document_args);
513 $obj->title = $document_output->data->title;
514 $obj->content = $document_output->data->content;
523 if($source_obj->get(
'status') == $this->getConfigStatus(
'temp'))
$obj->regdate = date(
'YmdHis');
538 if(count($extra_keys))
540 foreach($extra_keys as $idx => $extra_item)
543 if(isset(
$obj->{
'extra_vars'.$idx}))
545 $tmp =
$obj->{
'extra_vars'.$idx};
547 $value = implode(
'|@|', $tmp);
551 else if(isset(
$obj->{$extra_item->name})) $value = trim(
$obj->{$extra_item->name});
552 if($value == NULL)
continue;
553 $this->insertDocumentExtraVar(
$obj->module_srl,
$obj->document_srl, $idx, $value, $extra_item->eid);
557 if($extra_content->title) $this->insertDocumentExtraVar(
$obj->module_srl,
$obj->document_srl, -1, $extra_content->title,
'title_'.Context::getLangType());
558 if($extra_content->content) $this->insertDocumentExtraVar(
$obj->module_srl,
$obj->document_srl, -2, $extra_content->content,
'content_'.Context::getLangType());
561 if($source_obj->get(
'category_srl') !=
$obj->category_srl || $source_obj->get(
'module_srl') ==
$logged_info->member_srl)
563 if($source_obj->get(
'category_srl') !=
$obj->category_srl) $this->updateCategoryCount(
$obj->module_srl, $source_obj->get(
'category_srl'));
564 if(
$obj->category_srl) $this->updateCategoryCount(
$obj->module_srl,
$obj->category_srl);
570 if(!$trigger_output->toBool())
573 return $trigger_output;
585 if($oCacheHandler->isSupport())
589 $oCacheHandler->delete($cache_key);
606 $trigger_obj =
new stdClass();
622 else if($isEmptyTrash && $oDocument == null)
return new BaseObject(-1,
'document is not exists');
624 if(!$oDocument->isExists() || $oDocument->document_srl !=
$document_srl)
return new BaseObject(-1,
'msg_invalid_document');
626 if(!$oDocument->isGranted())
return new BaseObject(-1,
'msg_not_permitted');
629 $args =
new stdClass();
646 if($oDocument->get(
'category_srl')) $this->updateCategoryCount($oDocument->get(
'module_srl'),$oDocument->get(
'category_srl'));
650 $this->deleteDocumentExtraVars($oDocument->get(
'module_srl'), $oDocument->document_srl);
656 $trigger_obj = $oDocument->getObjectVars();
658 if(!$trigger_output->toBool())
661 return $trigger_output;
665 $this->_deleteDeclaredDocuments(
$args);
666 $this->_deleteDocumentReadedLog(
$args);
667 $this->_deleteDocumentVotedLog(
$args);
677 if($oCacheHandler->isSupport())
680 $oCacheHandler->delete($cache_key);
693 executeQuery(
'document.deleteDeclaredDocuments', $documentSrls);
694 executeQuery(
'document.deleteDocumentDeclaredLog', $documentSrls);
704 executeQuery(
'document.deleteDocumentReadedLog', $documentSrls);
714 executeQuery(
'document.deleteDocumentVotedLog', $documentSrls);
724 $trash_args =
new stdClass();
727 else $trash_args->trash_srl =
$obj->trash_srl;
732 $trash_args->module_srl = $oDocument->get(
'module_srl');
733 $obj->module_srl = $oDocument->get(
'module_srl');
735 if($trash_args->module_srl == 0)
return false;
737 $trash_args->document_srl =
$obj->document_srl;
738 $trash_args->description =
$obj->description;
746 $trash_args->user_id = htmlspecialchars_decode(
$logged_info->user_id);
747 $trash_args->user_name = htmlspecialchars_decode(
$logged_info->user_name);
748 $trash_args->nick_name = htmlspecialchars_decode(
$logged_info->nick_name);
751 $document_args =
new stdClass;
752 $document_args->module_srl = 0;
753 $document_args->document_srl =
$obj->document_srl;
766 require_once(
_XE_PATH_.
'modules/trash/model/TrashVO.php');
769 $oTrashVO->setTitle($oDocument->variables[
'title']);
770 $oTrashVO->setOriginModule(
'document');
771 $oTrashVO->setSerializedObject(serialize($oDocument->variables));
772 $oTrashVO->setDescription(
$obj->description);
775 $output = $oTrashAdminController->insertTrash($oTrashVO);
796 if($oDocument->get(
'category_srl')) $this->updateCategoryCount($oDocument->get(
'module_srl'),$oDocument->get(
'category_srl'));
801 if($oDocument->hasUploadedFiles())
803 $args =
new stdClass();
804 $args->upload_target_srl = $oDocument->document_srl;
805 $args->isvalid =
'N';
812 if(!$trigger_output->toBool())
815 return $trigger_output;
824 if($oCacheHandler->isSupport())
826 $cache_key =
'document_item:'.
getNumberingPath($oDocument->document_srl) . $oDocument->document_srl;
827 $oCacheHandler->delete($cache_key);
844 $member_srl = $oDocument->get(
'member_srl');
849 if(!$trigger_output->toBool())
return $trigger_output;
852 if($_SESSION[
'readed_document'][
$document_srl])
return false;
855 if($oDocument->get(
'ipaddress') == $_SERVER[
'REMOTE_ADDR'])
861 if($member_srl &&
$logged_info->member_srl == $member_srl)
871 $args =
new stdClass;
877 if(!$trigger_output->toBool())
880 return $trigger_output;
886 if($oCacheHandler->isSupport())
890 $oCacheHandler->delete($cache_key);
894 if(!$_SESSION[
'banned_document'][$document_srl])
917 if(!
$module_srl || !$var_idx || !$var_name || !$var_type || !$eid)
return new BaseObject(-1,
'msg_invalid_request');
919 $obj =
new stdClass();
921 $obj->var_idx = $var_idx;
922 $obj->var_name = $var_name;
923 $obj->var_type = $var_type;
924 $obj->var_is_required = $var_is_required==
'Y'?
'Y':
'N';
925 $obj->var_search = $var_search==
'Y'?
'Y':
'N';
926 $obj->var_default = $var_default;
927 $obj->var_desc = $var_desc;
943 if($oCacheHandler->isSupport())
945 $object_key =
'module_document_extra_keys:'.$module_srl;
946 $cache_key = $oCacheHandler->getGroupKey(
'site_and_module', $object_key);
947 $oCacheHandler->delete($cache_key);
962 $obj =
new stdClass();
964 if(!is_null($var_idx))
$obj->var_idx = $var_idx;
969 $output = $oDB->executeQuery(
'document.deleteDocumentExtraKeys',
$obj);
978 $output = $oDB->executeQuery(
'document.updateDocumentExtraKeyIdxOrder',
$obj);
995 $output = $oDB->executeQuery(
'document.updateDocumentExtraVarIdxOrder',
$obj);
1006 if($oCacheHandler->isSupport())
1008 $object_key =
'module_document_extra_keys:'.$module_srl;
1009 $cache_key = $oCacheHandler->getGroupKey(
'site_and_module', $object_key);
1010 $oCacheHandler->delete($cache_key);
1031 $obj =
new stdClass;
1034 $obj->var_idx = $var_idx;
1035 $obj->value = $value;
1036 $obj->lang_code = $lang_code;
1053 $obj =
new stdClass();
1056 if(!is_null($var_idx))
$obj->var_idx = $var_idx;
1057 if(!is_null($lang_code))
$obj->lang_code = $lang_code;
1058 if(!is_null($eid))
$obj->eid = $eid;
1072 if($point > 0) $failed_voted =
'failed_voted';
1073 else $failed_voted =
'failed_blamed';
1081 $oDocument =
$oDocumentModel->getDocument($document_srl,
false,
false);
1083 if($oDocument->get(
'ipaddress') == $_SERVER[
'REMOTE_ADDR'])
1090 $oMemberModel =
getModel(
'member');
1091 $member_srl = $oMemberModel->getLoggedMemberSrl();
1094 if($oDocument->get(
'member_srl'))
1097 if($member_srl && $member_srl == abs($oDocument->get(
'member_srl')))
1105 $args =
new stdClass;
1108 $args->member_srl = $member_srl;
1112 $args->ipaddress = $_SERVER[
'REMOTE_ADDR'];
1124 $trigger_obj =
new stdClass;
1125 $trigger_obj->member_srl = $oDocument->get(
'member_srl');
1126 $trigger_obj->module_srl = $oDocument->get(
'module_srl');
1127 $trigger_obj->document_srl = $oDocument->get(
'document_srl');
1128 $trigger_obj->update_target = ($point < 0) ?
'blamed_count' :
'voted_count';
1129 $trigger_obj->point = $point;
1130 $trigger_obj->before_point = ($point < 0) ? $oDocument->get(
'blamed_count') : $oDocument->get(
'voted_count');
1131 $trigger_obj->after_point = $trigger_obj->before_point + $point;
1133 if(!$trigger_output->toBool())
1135 return $trigger_output;
1143 if($trigger_obj->update_target ===
'blamed_count')
1145 $args->blamed_count = $trigger_obj->after_point;
1150 $args->voted_count = $trigger_obj->after_point;
1156 $args->point = $trigger_obj->point;
1162 if(!$trigger_output->toBool())
1165 return $trigger_output;
1171 if($oCacheHandler->isSupport())
1175 $oCacheHandler->delete($cache_key);
1183 if($trigger_obj->update_target ===
'voted_count')
1185 $output->setMessage(
'success_voted');
1186 $output->add(
'voted_count', $trigger_obj->after_point);
1190 $output->setMessage(
'success_blamed');
1191 $output->add(
'blamed_count', $trigger_obj->after_point);
1208 $args =
new stdClass();
1213 $declared_count = (
$output->data->declared_count) ?
$output->data->declared_count : 0;
1215 $trigger_obj =
new stdClass();
1217 $trigger_obj->declared_count = $declared_count;
1221 if(!$trigger_output->toBool())
1223 return $trigger_output;
1228 $oDocument =
$oDocumentModel->getDocument($document_srl,
false,
false);
1231 if($oDocument->get(
'ipaddress') == $_SERVER[
'REMOTE_ADDR']) {
1233 return new BaseObject(-1,
'failed_declared');
1237 if($oDocument->get(
'member_srl'))
1240 $oMemberModel =
getModel(
'member');
1241 $member_srl = $oMemberModel->getLoggedMemberSrl();
1243 if($member_srl && $member_srl == abs($oDocument->get(
'member_srl')))
1246 return new BaseObject(-1,
'failed_declared');
1251 $args =
new stdClass;
1254 $args->member_srl = $member_srl;
1258 $args->ipaddress = $_SERVER[
'REMOTE_ADDR'];
1268 return new BaseObject(-1,
'failed_declared');
1287 $this->add(
'declared_count', $declared_count+1);
1290 $trigger_obj->declared_count = $declared_count + 1;
1292 if(!$trigger_output->toBool())
1295 return $trigger_output;
1304 $this->setMessage(
'success_declared');
1318 $args =
new stdClass();
1320 $args->comment_count = $comment_count;
1322 if($comment_inserted)
1325 $args->last_updater = $last_updater;
1328 if($oCacheHandler->isSupport())
1332 $oCacheHandler->delete($cache_key);
1347 $args =
new stdClass;
1349 $args->trackback_count = $trackback_count;
1352 if($oCacheHandler->isSupport())
1356 $oCacheHandler->delete($cache_key);
1370 if(
$obj->parent_srl)
1375 $obj->list_order = $parent_category->list_order;
1376 $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1388 $this->makeCategoryFile(
$obj->module_srl);
1402 $args =
new stdClass;
1404 $args->list_order = $list_order;
1421 $args =
new stdClass;
1422 $args->category_srl = $category_srl;
1423 $args->document_count = $document_count;
1438 if(
$output->toBool()) $this->makeCategoryFile(
$obj->module_srl);
1449 $args =
new stdClass();
1450 $args->category_srl = $category_srl;
1456 if(
$output->data->count>0)
return new BaseObject(-1,
'msg_cannot_delete_for_child');
1461 $this->makeCategoryFile($category_info->module_srl);
1464 if($oCacheHandler->isSupport())
1468 $args =
new stdClass();
1469 $args->category_srl = $category_srl;
1470 $args->list_count = 100;
1471 $args->page = ++$page;
1477 foreach(
$output->data as $val)
1480 $cache_key =
'document_item:'.
getNumberingPath($val->document_srl) . $val->document_srl;
1481 $oCacheHandler->delete($cache_key);
1487 $args =
new stdClass();
1488 $args->target_category_srl = 0;
1489 $args->source_category_srl = $category_srl;
1502 $args =
new stdClass();
1517 $args =
new stdClass;
1518 $args->category_srl = $category_srl;
1522 $list_order = $category->list_order;
1526 $category_srl_list = array_keys($category_list);
1527 if(count($category_srl_list)<2)
return new BaseObject();
1529 $prev_category = NULL;
1530 foreach($category_list as $key => $val)
1532 if($key==$category_srl)
break;
1533 $prev_category = $val;
1540 $cur_args =
new stdClass;
1541 $cur_args->category_srl = $category_srl;
1542 $cur_args->list_order = $prev_category->list_order;
1543 $cur_args->title = $category->title;
1544 $this->updateCategory($cur_args);
1546 $prev_args =
new stdClass;
1547 $prev_args->category_srl = $prev_category->category_srl;
1548 $prev_args->list_order = $list_order;
1549 $prev_args->title = $prev_category->title;
1550 $this->updateCategory($prev_args);
1564 $args =
new stdClass;
1565 $args->category_srl = $category_srl;
1569 $list_order = $category->list_order;
1573 $category_srl_list = array_keys($category_list);
1574 if(count($category_srl_list)<2)
return new BaseObject();
1576 for($i=0;$i<count($category_srl_list);$i++)
1578 if($category_srl_list[$i]==$category_srl)
break;
1581 $next_category_srl = $category_srl_list[$i+1];
1583 $next_category = $category_list[$next_category_srl];
1585 $cur_args =
new stdClass;
1586 $cur_args->category_srl = $category_srl;
1587 $cur_args->list_order = $next_category->list_order;
1588 $cur_args->title = $category->title;
1589 $this->updateCategory($cur_args);
1591 $next_args =
new stdClass;
1592 $next_args->category_srl = $next_category->category_srl;
1593 $next_args->list_order = $list_order;
1594 $next_args->title = $next_category->title;
1595 $this->updateCategory($next_args);
1609 if(!count($extra_keys))
return;
1612 $js_code[] =
'<script>//<![CDATA[';
1613 $js_code[] =
'(function($){';
1614 $js_code[] =
'var validator = xe.getApp("validator")[0];';
1615 $js_code[] =
'if(!validator) return false;';
1619 foreach($extra_keys as $idx => $val)
1622 if($val->type ==
'kr_zip')
1626 $name = str_ireplace(array(
'<script',
'</script'), array(
'<scr" + "ipt',
'</scr" + "ipt'), $val->name);
1627 $js_code[] = sprintf(
'validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1628 if($val->is_required ==
'Y') $js_code[] = sprintf(
'validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1631 $js_code[] =
'})(jQuery);';
1632 $js_code[] =
'//]]></script>';
1633 $js_code = implode(
"\n", $js_code);
1646 if(!
$args)
$args =
Context::gets(
'module_srl',
'category_srl',
'parent_srl',
'category_title',
'category_description',
'expand',
'group_srls',
'category_color',
'mid');
1648 $args->description =
$args->category_description;
1659 $columnList = array(
'module_srl',
'module');
1662 if(!$grant->manager)
return new BaseObject(-1,
'msg_not_permitted');
1665 if(!is_array(
$args->group_srls))
$args->group_srls = str_replace(
'|@|',
',',
$args->group_srls);
1666 else $args->group_srls = implode(
',',
$args->group_srls);
1674 if(
$args->category_srl)
1677 if($category_info->category_srl !=
$args->category_srl)
$args->category_srl = null;
1680 if(
$args->category_srl)
1700 $xml_file = $this->makeCategoryFile(
$args->module_srl);
1704 $this->add(
'xml_file', $xml_file);
1705 $this->add(
'module_srl',
$args->module_srl);
1706 $this->add(
'category_srl',
$args->category_srl);
1707 $this->add(
'parent_srl',
$args->parent_srl);
1710 $this->setRedirectUrl($returnUrl);
1726 $source_category =
$oDocumentModel->getCategory($source_category_srl);
1729 $columnList = array(
'module_srl',
'module');
1732 if(!$grant->manager)
return new BaseObject(-1,
'msg_not_permitted');
1735 $source_args =
new stdClass;
1736 if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1738 $parent_category =
$oDocumentModel->getCategory($parent_category_srl);
1740 $args =
new stdClass;
1741 $args->module_srl = $source_category->module_srl;
1742 $args->parent_srl = $parent_category_srl;
1747 if(!
$args->list_order)
$args->list_order = 0;
1748 $args->list_order--;
1750 $source_args->category_srl = $source_category_srl;
1751 $source_args->parent_srl = $parent_category_srl;
1752 $source_args->list_order =
$args->list_order;
1753 $output = $this->updateCategory($source_args);
1757 else if($target_category_srl > 0)
1759 $target_category =
$oDocumentModel->getCategory($target_category_srl);
1761 $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1764 $source_args->category_srl = $source_category_srl;
1765 $source_args->parent_srl = $target_category->parent_srl;
1766 $source_args->list_order = $target_category->list_order+1;
1767 $output = $this->updateCategory($source_args);
1771 $xml_file = $this->makeCategoryFile($source_category->module_srl);
1773 $this->add(
'xml_file', $xml_file);
1774 $this->add(
'source_category_srl', $source_category_srl);
1790 $columnList = array(
'module_srl',
'module');
1793 if(!$grant->manager)
return new BaseObject(-1,
'msg_not_permitted');
1798 if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1809 $xml_file = $this->makeCategoryFile(
$args->module_srl);
1813 $this->add(
'xml_file', $xml_file);
1814 $this->add(
'category_srl', $parent_srl);
1815 $this->setMessage(
'success_deleted');
1831 $columnList = array(
'module_srl',
'module');
1834 if(!$grant->manager)
return new BaseObject(-1,
'msg_not_permitted');
1838 $this->add(
'xml_file',$xml_file);
1855 $columnList = array(
'module_srl',
'mid',
'site_srl');
1859 if(!is_dir(
'./files/cache/document_category'))
FileHandler::makeDir(
'./files/cache/document_category');
1861 $xml_file = sprintf(
"./files/cache/document_category/%s.xml.php",
$module_srl);
1862 $php_file = sprintf(
"./files/cache/document_category/%s.php",
$module_srl);
1864 $args =
new stdClass();
1866 $args->sort_index =
'list_order';
1869 $category_list =
$output->data;
1871 if(!is_array($category_list)) $category_list = array($category_list);
1873 $category_count = count($category_list);
1874 for($i=0;$i<$category_count;$i++)
1876 $category_srl = $category_list[$i]->category_srl;
1877 if(!preg_match(
'/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls =
'';
1878 $list[$category_srl] = $category_list[$i];
1883 $xml_buff =
"<root />";
1889 if(!is_array($list)) $list = array($list);
1891 foreach($list as $category_srl => $node)
1894 $parent_srl = (int)$node->parent_srl;
1895 $tree[$parent_srl][$category_srl] = $node;
1899 '$lang_type = Context::getLangType(); '.
1900 '$is_logged = Context::get(\'is_logged\'); '.
1901 '$logged_info = Context::get(\'logged_info\'); '.
1903 'if($logged_info->is_admin=="Y") $is_admin = true; '.
1904 'else $is_admin = false; '.
1905 '$group_srls = array_keys($logged_info->group_list); '.
1907 '$is_admin = false; '.
1908 '$group_srsl = array(); '.
1912 $xml_header_buff =
'';
1913 $xml_body_buff = $this->getXmlTree($tree[0], $tree,
$module_info->site_srl, $xml_header_buff);
1914 $xml_buff = sprintf(
1916 'define(\'__XE__\', true); '.
1920 'header(
"Content-Type: text/xml; charset=UTF-8");
'.
1921 'header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT");
'.
1922 'header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
'.
1923 'header(
"Cache-Control: no-store, no-cache, must-revalidate");
'.
1924 'header(
"Cache-Control: post-check=0, pre-check=0",
false);
'.
1925 'header(
"Pragma: no-cache");
'.
1935 // Create php cache file
1936 $php_header_buff = '$_titles = array();
';
1937 $php_header_buff .= '$_descriptions = array();
';
1938 $php_output = $this->getPhpCacheCode($tree[0], $tree, $module_info->site_srl, $php_header_buff);
1939 $php_buff = sprintf(
1941 'if(!defined(
"__XE__")) exit();
'.
1944 '$menu =
new stdClass;
'.
1945 '$menu->list = array(%s);
',
1951 FileHandler::writeFile($xml_file, $xml_buff);
1952 FileHandler::writeFile($php_file, $php_buff);
1966 function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1968 if(!$source_node) return;
1970 foreach($source_node as $category_srl => $node)
1973 // Get data of the child nodes
1974 if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1976 $expand = ($node->expand) ? $node->expand : 'N
';
1977 $group_srls = ($node->group_srls) ? $node->group_srls : '';
1978 $mid = ($node->mid) ? $node->mid : '';
1979 $module_srl = ($node->module_srl) ? $node->parent_srl : '';
1980 $parent_srl = ($node->parent_srl) ? $node->parent_srl : '';
1981 $color = ($node->color) ? $node->color : '';
1982 $description = ($node->description) ? $node->description : '';
1983 // If node->group_srls value exists
1984 if($group_srls) $group_check_code = sprintf('($is_admin==
true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))
',$group_srls);
1985 else $group_check_code = "true";
1987 $title = $node->title;
1988 $oModuleAdminModel = getAdminModel('module');
1990 $langs = $oModuleAdminModel->getLangCode($site_srl, $title);
1993 foreach($langs as $key => $val)
1995 $xml_header_buff .= sprintf('$_titles[%d][
"%s"] = %s;
', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8
', false)), true));
1999 $langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2002 foreach($langx as $key => $val)
2004 $xml_header_buff .= sprintf('$_descriptions[%d][
"%s"] = %s;
', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8
', false)), true));
2008 $attribute = sprintf(
2009 'mid=
"%s" module_srl=
"%d" node_srl=
"%d" parent_srl=
"%d" category_srl=
"%d" text=
"<?php echo (%s?($_titles[%d][$lang_type]):"")?>" url=%s expand=%s color=%s description=
"<?php echo (%s?($_descriptions[%d][$lang_type]):"")?>" document_count=
"%d" ',
2017 var_export(getUrl('','mid
',$node->mid,'category
',$category_srl), true),
2018 var_export($expand, true),
2019 var_export($color, true),
2022 $node->document_count
2025 if($child_buff) $buff .= sprintf('<node %s>%s</node>
', $attribute, $child_buff);
2026 else $buff .= sprintf('<node %s />
', $attribute);
2042 function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2044 $output = array("buff"=>"", "category_srl_list"=>array());
2045 if(!$source_node) return $output;
2047 // Set to an arraty for looping and then generate php script codes to be included
2048 foreach($source_node as $category_srl => $node)
2050 // Get data from child nodes first if exist.
2051 if($category_srl && $tree[$category_srl]){
2052 $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff);
2054 $child_output = array("buff"=>"", "category_srl_list"=>array());
2057 // Set values into category_srl_list arrary if url of the current node is not empty
2058 $child_output['category_srl_list
'][] = $node->category_srl;
2059 $output['category_srl_list
'] = array_merge($output['category_srl_list
'], $child_output['category_srl_list
']);
2061 // If node->group_srls value exists
2062 if($node->group_srls) {
2063 $group_check_code = sprintf('($is_admin==
true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))
',$node->group_srls);
2065 $group_check_code = "true";
2069 $selected = '"' . implode('",
"', $child_output['category_srl_list']) . '"';
2070 $child_buff = $child_output['buff
'];
2071 $expand = $node->expand;
2073 $title = $node->title;
2074 $description = $node->description;
2075 $oModuleAdminModel = getAdminModel('module');
2076 $langs = $oModuleAdminModel->getLangCode($site_srl, $title);
2080 foreach($langs as $key => $val)
2082 $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8
', false);
2083 $php_header_buff .= sprintf(
2084 '$_titles[%d][
"%s"] = %s;
',
2087 var_export(str_replace('"','\\"', $val), true)
2092 $langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2096 foreach($langx as $key => $val)
2098 $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8
', false);
2099 $php_header_buff .= sprintf(
2100 '$_descriptions[%d][
"%s"] = %s;
',
2103 var_export(str_replace('"','\\"', $val), true)
2108 // Create attributes(Use the category_srl_list to check whether to belong to the menu's node. It seems to be tricky but fast fast and powerful;)
2109 $attribute = sprintf(
2110 '"mid" => "%s", "module_srl" => "%d","node_srl"=>"%d","category_srl"=>"%d","parent_srl"=>"%d","text"=>$_titles[%d][$lang_type],"selected"=>(in_array(Context::get("category"),array(%s))?1:0),"expand"=>%s,"color"=>%s,"description"=>$_descriptions[%d][$lang_type],"list"=>array(%s),"document_count"=>"%d","grant"=>%s?true:false',
2113 $node->category_srl,
2114 $node->category_srl,
2116 $node->category_srl,
2118 var_export($expand,
true),
2119 var_export($node->color,
true),
2120 $node->category_srl,
2122 $node->document_count,
2127 $output[
'buff'] .= sprintf(
'%s=>array(%s),', $node->category_srl, $attribute);
2143 $document_popup_menu_list =
Context::get(
'document_popup_menu_list');
2144 if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2146 $obj =
new stdClass();
2150 $obj->target = $target;
2151 $document_popup_menu_list[] =
$obj;
2153 Context::set(
'document_popup_menu_list', $document_popup_menu_list);
2166 for($i = 0; $i < count($srls); $i++)
2168 $srl = trim($srls[$i]);
2172 $document_srls[] = $srl;
2174 if(!count($document_srls))
return;
2177 $args =
new stdClass;
2178 $args->list_count = count($document_srls);
2179 $args->document_srls = implode(
',',$document_srls);
2180 $args->order_type =
'asc';
2184 unset($document_srls);
2185 foreach(
$output->data as $key => $val)
2187 $document_srls[$val->module_srl][] = $val->document_srl;
2189 if(!$document_srls || !count($document_srls))
return new BaseObject();
2193 $module_srls = array_keys($document_srls);
2194 for($i=0;$i<count($module_srls);$i++)
2207 if(!$grant->manager)
2214 if(!count($document_srls))
return new BaseObject();
2216 foreach($document_srls as
$module_srl => $documents)
2218 $cnt = count($documents);
2219 for($i=0;$i<$cnt;$i++)
2222 if(!$document_srls)
continue;
2223 if($_SESSION[
'document_management'][
$document_srl]) unset($_SESSION[
'document_management'][$document_srl]);
2224 else $_SESSION[
'document_management'][
$document_srl] =
true;
2240 return new BaseObject(-1,
'msg_invalid_request');
2248 $message_content = strip_tags(
Context::get(
'message_content'));
2249 if($message_content) $message_content = nl2br($message_content);
2252 $document_srl_list = (!is_array($cart)) ? explode(
'|@|', $cart) : $cart;
2254 array_map(
function ($value) {
return (
int)$value; }, $document_srl_list);
2256 $document_srl_count = count($document_srl_list);
2259 $document_items = array();
2263 $document_items[] = $oDocument;
2264 if(!$oDocument->isGranted())
return $this->stop(
'msg_not_permitted');
2268 if($message_content)
2275 $title =
cut_str($message_content,10,
'...');
2278 foreach($document_items as $oDocument)
2280 if(!$oDocument->get(
'member_srl') || $oDocument->get(
'member_srl')==$sender_member_srl)
continue;
2282 if($type==
'move') $purl = sprintf(
"<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2284 $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));
2286 $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get(
'member_srl'), $title, $content,
false);
2291 $oSpamController->setAvoidLog();
2298 $output = $oDocumentAdminController->moveDocumentModule($document_srl_list,
$module_srl, $category_srl);
2301 $msg_code =
'success_moved';
2304 else if($type ==
'copy')
2308 $output = $oDocumentAdminController->copyDocumentModule($document_srl_list,
$module_srl, $category_srl);
2311 $msg_code =
'success_copied';
2313 else if($type ==
'delete')
2317 for($i=0;$i<$document_srl_count;$i++)
2319 $document_srl = $document_srl_list[$i];
2320 $output = $this->deleteDocument($document_srl,
true);
2324 $msg_code =
'success_deleted';
2326 else if($type ==
'trash')
2328 $args =
new stdClass();
2329 $args->description = $message_content;
2333 for($i=0;$i<$document_srl_count;$i++) {
2334 $args->document_srl = $document_srl_list[$i];
2339 $msg_code =
'success_trashed';
2341 else if($type ==
'cancelDeclare')
2343 $args->document_srl = $document_srl_list;
2345 $msg_code =
'success_declare_canceled';
2348 $_SESSION[
'document_management'] = array();
2350 $this->setMessage($msg_code);
2353 $this->setRedirectUrl($returnUrl);
2366 $document_config =
new stdClass();
2367 $document_config->use_history =
Context::get(
'use_history');
2368 if(!$document_config->use_history) $document_config->use_history =
'N';
2370 $document_config->use_vote_up =
Context::get(
'use_vote_up');
2371 if(!$document_config->use_vote_up) $document_config->use_vote_up =
'Y';
2373 $document_config->use_vote_down =
Context::get(
'use_vote_down');
2374 if(!$document_config->use_vote_down) $document_config->use_vote_down =
'Y';
2376 $document_config->use_status =
Context::get(
'use_status');
2385 $this->setError(-1);
2386 $this->setMessage(
'success_updated',
'info');
2389 $this->setRedirectUrl($returnUrl);
2407 $obj->status = $this->getConfigStatus(
'temp');
2408 unset(
$obj->is_notice);
2422 if($oDocument->isExists() && $oDocument->document_srl ==
$obj->document_srl)
2424 if($oDocument->get(
'module_srl') !=
$obj->module_srl)
2426 return new BaseObject(-1,
'msg_invalid_request');
2428 if(!$oDocument->isGranted())
2430 return new BaseObject(-1,
'msg_invalid_request');
2433 $obj->status = $oDocument->get(
'status');
2435 $msg_code =
'success_updated';
2441 $msg_code =
'success_registed';
2442 $obj->document_srl =
$output->get(
'document_srl');
2446 if($oDocument->hasUploadedFiles())
2448 $args =
new stdClass;
2449 $args->upload_target_srl = $oDocument->document_srl;
2450 $args->isvalid =
'N';
2454 $this->setMessage(
'success_saved');
2455 $this->add(
'document_srl',
$obj->document_srl);
2466 if($documentSrls) $documentSrlList = explode(
',', $documentSrls);
2468 if(count($documentSrlList) > 0)
2471 $columnList = array(
'document_srl',
'title',
'nick_name',
'status');
2472 $documentList =
$oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin,
false, $columnList);
2477 $documentList = array();
2478 $this->setMessage($lang->no_documents);
2480 $oSecurity =
new Security($documentList);
2481 $oSecurity->encodeHTML(
'..variables.');
2482 $this->add(
'document_list', $documentList);
2492 if(!isset(
$obj->allow_comment))
$obj->allow_comment =
'N';
2493 if(!isset(
$obj->lock_comment))
$obj->lock_comment =
'N';
2495 if(
$obj->allow_comment ==
'Y' &&
$obj->lock_comment ==
'N')
$obj->commentStatus =
'ALLOW';
2496 else $obj->commentStatus =
'DENY';
2506 if(!
$obj->status &&
$obj->is_secret ==
'Y')
$obj->status = $this->getConfigStatus(
'secret');
2507 if(!
$obj->status &&
$obj->is_secret !=
'Y')
$obj->status = $this->getConfigStatus(
'public');
2515 if(is_array($documentSrlList))
2517 $documentSrlList = array_unique($documentSrlList);
2518 foreach($documentSrlList AS $key => $documentSrl)
2520 $fileCount = $oFileModel->getFilesCount($documentSrl);
2521 $args =
new stdClass();
2522 $args->document_srl = $documentSrl;
2523 $args->uploaded_count = $fileCount;
2539 if(is_array($documentExtraKeys) && is_array(
$obj->moduleSrlList))
2542 foreach(
$obj->moduleSrlList AS $key=>$value)
2544 foreach($documentExtraKeys AS $extraItem)
2546 $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ;
2555 $documentConfig =
$oModuleModel->getModulePartConfig(
'document',
$obj->originModuleSrl);
2558 if(is_array(
$obj->moduleSrlList))
2560 foreach(
$obj->moduleSrlList AS $key=>$moduleSrl)
triggerDeleteModuleDocuments(&$obj)
getController($module_name)
getNumberingPath($no, $size=3)
moveCategoryUp($category_srl)
updateTrackbackCount($document_srl, $trackback_count)
moveCategoryDown($category_srl)
updateVotedCount($document_srl, $point=1)
& getInstance($target= 'object', $info=null, $always_use_file=false)
procDocumentManageCheckedDocument()
deleteDocumentHistory($history_srl, $document_srl, $module_srl)
procDocumentDeleteCategory()
_deleteDocumentVotedLog($documentSrls)
moveDocumentToTrash($obj)
insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required= 'N', $var_search= 'N', $var_default= '', $var_desc= '', $eid)
declaredDocument($document_srl)
set($key, $val, $set_to_get_vars=0)
writeFile($filename, $buff, $mode="w")
deleteModuleCategory($module_srl)
deleteDocumentAliasByModule($module_srl)
updateReadedCount(&$oDocument)
deleteDocumentAliasByDocument($document_srl)
$oContext
Include the necessary configuration files.
procDocumentMakeXmlFile()
procDocumentInsertCategory($args=null)
$module_srl
integer value to represent a run-time instance of Module (XE Module)
updateUploaedCount($documentSrlList)
updateCategoryCount($module_srl, $category_srl, $document_count=0)
_deleteDocumentReadedLog($documentSrls)
deleteDocument($document_srl, $is_admin=false, $isEmptyTrash=false, $oDocument=null)
_checkCommentStatusForOldVersion(&$obj)
procDocumentInsertModuleConfig()
insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid=null, $lang_code= '')
deleteDocumentExtraVars($module_srl, $document_srl=null, $var_idx=null, $lang_code=null, $eid=null)
deleteCategory($category_srl)
getInstance($db_type=NULL)
insertDocument($obj, $manual_inserted=false, $isRestore=false, $isLatest=true)
_deleteDeclaredDocuments($documentSrls)
document the module's high class {
insertAlias($module_srl, $document_srl, $alias_title)
updateCategoryListOrder($module_srl, $list_order)
addDocumentPopupMenu($url, $str, $icon= '', $target= 'self')
updateDocument($source_obj, $obj, $manual_updated=FALSE)
updateCommentCount($document_srl, $comment_count, $last_updater, $comment_inserted=false)
deleteDocumentExtraKeys($module_srl, $var_idx=null)
addXmlJsFilter($module_srl)
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
_checkDocumentStatusForOldVersion(&$obj)
getAdminController($module_name)
cut_str($string, $cut_size=0, $tail= '...')
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
triggerCopyModuleExtraKeys(&$obj)
triggerCall($trigger_name, $called_position, &$obj)
makeCategoryFile($module_srl)
high class of the module module
procDocumentMoveCategory()
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
controller class of the document module