mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
Caching implementation for objects
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8745 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
1b47a294d3
commit
70a69ff4fe
18 changed files with 709 additions and 322 deletions
2
classes/cache/CacheApc.class.php
vendored
2
classes/cache/CacheApc.class.php
vendored
|
|
@ -62,7 +62,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($key) {
|
function delete($key) {
|
||||||
$this->_delete(md5(_XE_PATH_.$key));
|
$this->_delete($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate() {
|
function truncate() {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$truncated = array();
|
$truncated = array();
|
||||||
$oObjectCacheHandler = &CacheHandler::getInstance();
|
$oObjectCacheHandler = &CacheHandler::getInstance('object');
|
||||||
$oTemplateCacheHandler = &CacheHandler::getInstance('template');
|
$oTemplateCacheHandler = &CacheHandler::getInstance('template');
|
||||||
|
|
||||||
if($oObjectCacheHandler->isSupport()){
|
if($oObjectCacheHandler->isSupport()){
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key = $object;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('comment_list_document_pages');
|
||||||
|
}
|
||||||
|
|
||||||
$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
|
$this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $deleted_count) );
|
||||||
|
|
||||||
|
|
@ -158,6 +170,17 @@
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
$output = executeQuery('comment.deleteModuleCommentsList', $args);
|
$output = executeQuery('comment.deleteModuleCommentsList', $args);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key = $object;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('comment_list_document_pages');
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,17 @@
|
||||||
|
|
||||||
|
|
||||||
$output->add('comment_srl', $obj->comment_srl);
|
$output->add('comment_srl', $obj->comment_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key = $object;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('comment_list_document_pages');
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,6 +327,17 @@
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
$output->add('comment_srl', $obj->comment_srl);
|
$output->add('comment_srl', $obj->comment_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key = $object;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('comment_list_document_pages');
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,6 +401,17 @@
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
$output->add('document_srl', $document_srl);
|
$output->add('document_srl', $document_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key = $object;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('comment_list_document_pages');
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,6 +464,17 @@
|
||||||
$this->_deleteDeclaredComments($args);
|
$this->_deleteDeclaredComments($args);
|
||||||
$this->_deleteVotedComments($args);
|
$this->_deleteVotedComments($args);
|
||||||
}
|
}
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key = $object;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('comment_list_document_pages');
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,41 +200,63 @@
|
||||||
* @brief get a comment list of the doc in corresponding woth document_srl.
|
* @brief get a comment list of the doc in corresponding woth document_srl.
|
||||||
**/
|
**/
|
||||||
function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0) {
|
function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0) {
|
||||||
// get the number of comments on the document module
|
// cache controll
|
||||||
$oDocumentModel = &getModel('document');
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
$columnList = array('document_srl', 'module_srl', 'comment_count');
|
if($oCacheHandler->isSupport()){
|
||||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, true, $columnList);
|
$cache_key = 'object:'.$document_srl.'_'.$page;
|
||||||
// return if no doc exists.
|
$output = $oCacheHandler->get($cache_key);
|
||||||
if(!$oDocument->isExists()) return;
|
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||||
// return if no comment exists
|
if($cache_object) {
|
||||||
if($oDocument->getCommentCount()<1) return;
|
if(!in_array($cache_key, $cache_object)) {
|
||||||
// get a list of comments
|
$cache_object[]=$cache_key;
|
||||||
$module_srl = $oDocument->get('module_srl');
|
$oCacheHandler->put('comment_list_document_pages',$cache_object);
|
||||||
|
}
|
||||||
if(!$count) {
|
} else {
|
||||||
$comment_config = $this->getCommentConfig($module_srl);
|
$cache_object = array();
|
||||||
$comment_count = $comment_config->comment_count;
|
$cache_object[] = $cache_key;
|
||||||
if(!$comment_count) $comment_count = 50;
|
$oCacheHandler->put('comment_list_document_pages',$cache_object);
|
||||||
} else {
|
}
|
||||||
$comment_count = $count;
|
}
|
||||||
}
|
if(!$output){
|
||||||
// get a very last page if no page exists
|
// get the number of comments on the document module
|
||||||
if(!$page) $page = (int)( ($oDocument->getCommentCount()-1) / $comment_count) + 1;
|
$oDocumentModel = &getModel('document');
|
||||||
// get a list of comments
|
$columnList = array('document_srl', 'module_srl', 'comment_count');
|
||||||
$args->document_srl = $document_srl;
|
$oDocument = $oDocumentModel->getDocument($document_srl, false, true, $columnList);
|
||||||
$args->list_count = $comment_count;
|
// return if no doc exists.
|
||||||
$args->page = $page;
|
if(!$oDocument->isExists()) return;
|
||||||
$args->page_count = 10;
|
// return if no comment exists
|
||||||
$output = executeQueryArray('comment.getCommentPageList', $args);
|
if($oDocument->getCommentCount()<1) return;
|
||||||
// return if an error occurs in the query results
|
// get a list of comments
|
||||||
if(!$output->toBool()) return;
|
$module_srl = $oDocument->get('module_srl');
|
||||||
// insert data into CommentPageList table if the number of results is different from stored comments
|
|
||||||
if(!$output->data) {
|
if(!$count) {
|
||||||
$this->fixCommentList($oDocument->get('module_srl'), $document_srl);
|
$comment_config = $this->getCommentConfig($module_srl);
|
||||||
$output = executeQueryArray('comment.getCommentPageList', $args);
|
$comment_count = $comment_config->comment_count;
|
||||||
if(!$output->toBool()) return;
|
if(!$comment_count) $comment_count = 50;
|
||||||
}
|
} else {
|
||||||
|
$comment_count = $count;
|
||||||
|
}
|
||||||
|
// get a very last page if no page exists
|
||||||
|
if(!$page) $page = (int)( ($oDocument->getCommentCount()-1) / $comment_count) + 1;
|
||||||
|
// get a list of comments
|
||||||
|
$args->document_srl = $document_srl;
|
||||||
|
$args->list_count = $comment_count;
|
||||||
|
$args->page = $page;
|
||||||
|
$args->page_count = 10;
|
||||||
|
$output = executeQueryArray('comment.getCommentPageList', $args);
|
||||||
|
// return if an error occurs in the query results
|
||||||
|
if(!$output->toBool()) return;
|
||||||
|
// insert data into CommentPageList table if the number of results is different from stored comments
|
||||||
|
if(!$output->data) {
|
||||||
|
$this->fixCommentList($oDocument->get('module_srl'), $document_srl);
|
||||||
|
$output = executeQueryArray('comment.getCommentPageList', $args);
|
||||||
|
if(!$output->toBool()) return;
|
||||||
|
}
|
||||||
|
//insert in cache
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
foreach($document_srl_list as $document_srl)
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$document_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$cache_object = $oCacheHandler->get('module_list_documents');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key_object = $object;
|
||||||
|
$oCacheHandler->delete($cache_key_object);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('module_list_documents');
|
||||||
|
}
|
||||||
return new Object();
|
return new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,7 +282,30 @@
|
||||||
**/
|
**/
|
||||||
function deleteModuleDocument($module_srl) {
|
function deleteModuleDocument($module_srl) {
|
||||||
$args->module_srl = $module_srl;
|
$args->module_srl = $module_srl;
|
||||||
|
$oDocumentModel = &getModel('document');
|
||||||
|
$args->module_srl = $module_srl;
|
||||||
|
$document_list = $oDocumentModel->getDocumentList($args);
|
||||||
|
$documents = $document_list->data;
|
||||||
$output = executeQuery('document.deleteModuleDocument', $args);
|
$output = executeQuery('document.deleteModuleDocument', $args);
|
||||||
|
foreach ($documents as $oDocument){
|
||||||
|
$document_srl_list[] = $oDocument->document_srl;
|
||||||
|
}
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
foreach($document_srl_list as $document_srl)
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$document_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
$cache_object = $oCacheHandler->get('module_list_documents');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key_object = $object;
|
||||||
|
$oCacheHandler->delete($cache_key_object);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('module_list_documents');
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,20 @@ class documentController extends document {
|
||||||
$this->addGrant($obj->document_srl);
|
$this->addGrant($obj->document_srl);
|
||||||
$output->add('document_srl',$obj->document_srl);
|
$output->add('document_srl',$obj->document_srl);
|
||||||
$output->add('category_srl',$obj->category_srl);
|
$output->add('category_srl',$obj->category_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$obj->document_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
$cache_object = $oCacheHandler->get('module_list_documents');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key_object = $object;
|
||||||
|
$oCacheHandler->delete($cache_key_object);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('module_list_documents');
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,6 +404,20 @@ class documentController extends document {
|
||||||
FileHandler::removeDir(sprintf('files/cache/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
|
FileHandler::removeDir(sprintf('files/cache/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
|
||||||
|
|
||||||
$output->add('document_srl',$obj->document_srl);
|
$output->add('document_srl',$obj->document_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$obj->document_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
$cache_object = $oCacheHandler->get('module_list_documents');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key_object = $object;
|
||||||
|
$oCacheHandler->delete($cache_key_object);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('module_list_documents');
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,6 +488,20 @@ class documentController extends document {
|
||||||
// commit
|
// commit
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$document_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
$cache_object = $oCacheHandler->get('module_list_documents');
|
||||||
|
foreach ($cache_object as $object){
|
||||||
|
$cache_key_object = $object;
|
||||||
|
$oCacheHandler->delete($cache_key_object);
|
||||||
|
}
|
||||||
|
$oCacheHandler->delete('module_list_documents');
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,204 +152,226 @@
|
||||||
* @brief module_srl value, bringing the list of documents
|
* @brief module_srl value, bringing the list of documents
|
||||||
**/
|
**/
|
||||||
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) {
|
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) {
|
||||||
$logged_info = Context::get('logged_info');
|
// cache controll
|
||||||
$sort_check = $this->_setSortIndex($obj, $load_extra_vars);
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
$obj->sort_index = $sort_check->sort_index;
|
$cache_key = 'object:'.$obj->module_srl.'_category_srl:'.$obj->category_srl.'_list_count:'.$obj->list_count.'_search_target:'.$obj->search_target.'_search_keyword:'.$obj->search_keyword.'_documents';
|
||||||
// Check the target and sequence alignment
|
$output = $oCacheHandler->get($cache_key);
|
||||||
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
|
$cache_object = $oCacheHandler->get('module_list_documents');
|
||||||
// If that came across mid module_srl instead of a direct module_srl guhaejum
|
if($cache_object) {
|
||||||
if($obj->mid) {
|
if(!in_array($cache_key, $cache_object)) {
|
||||||
$oModuleModel = &getModel('module');
|
$cache_object[]=$cache_key;
|
||||||
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
|
$oCacheHandler->put('module_list_documents',$cache_object);
|
||||||
unset($obj->mid);
|
|
||||||
}
|
|
||||||
// Module_srl passed the array may be a check whether the array
|
|
||||||
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
|
|
||||||
else $args->module_srl = $obj->module_srl;
|
|
||||||
// Except for the test module_srl
|
|
||||||
if(is_array($obj->exclude_module_srl)) $args->exclude_module_srl = implode(',', $obj->exclude_module_srl);
|
|
||||||
else $args->exclude_module_srl = $obj->exclude_module_srl;
|
|
||||||
// Variable check
|
|
||||||
$args->category_srl = $obj->category_srl?$obj->category_srl:null;
|
|
||||||
$args->sort_index = $obj->sort_index;
|
|
||||||
$args->order_type = $obj->order_type;
|
|
||||||
$args->page = $obj->page?$obj->page:1;
|
|
||||||
$args->list_count = $obj->list_count?$obj->list_count:20;
|
|
||||||
$args->page_count = $obj->page_count?$obj->page_count:10;
|
|
||||||
$args->start_date = $obj->start_date?$obj->start_date:null;
|
|
||||||
$args->end_date = $obj->end_date?$obj->end_date:null;
|
|
||||||
$args->member_srl = $obj->member_srl;
|
|
||||||
$args->statusList = $obj->statusList?$obj->statusList:array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
|
|
||||||
if($logged_info->is_admin == 'Y') $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
|
|
||||||
// Category is selected, further sub-categories until all conditions
|
|
||||||
if($args->category_srl) {
|
|
||||||
$category_list = $this->getCategoryList($args->module_srl);
|
|
||||||
$category_info = $category_list[$args->category_srl];
|
|
||||||
$category_info->childs[] = $args->category_srl;
|
|
||||||
$args->category_srl = implode(',',$category_info->childs);
|
|
||||||
}
|
|
||||||
// Used to specify the default query id (based on several search options to query id modified)
|
|
||||||
$query_id = 'document.getDocumentList';
|
|
||||||
// If the search by specifying the document division naeyonggeomsaekil processed for
|
|
||||||
$use_division = false;
|
|
||||||
|
|
||||||
// Search options
|
|
||||||
$searchOpt->search_target = $obj->search_target;
|
|
||||||
$searchOpt->search_keyword = $obj->search_keyword;
|
|
||||||
$this->_setSearchOption($searchOpt, $args, $query_id, $use_division);
|
|
||||||
|
|
||||||
if ($sort_check->isExtraVars)
|
|
||||||
{
|
|
||||||
$query_id = 'document.getDocumentListExtraSort';
|
|
||||||
$output = executeQueryArray($query_id, $args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* list_order asc sort of division that can be used only when
|
|
||||||
**/
|
|
||||||
if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If it is true, use_division changed to use the document division
|
|
||||||
**/
|
|
||||||
if($use_division) {
|
|
||||||
// Division begins
|
|
||||||
$division = (int)Context::get('division');
|
|
||||||
|
|
||||||
// order by list_order and (module_srl===0 or module_srl many count), therefore case table full scan
|
|
||||||
if($args->sort_index == 'list_order' && ($args->exclude_module_srl === 0 || count($args->module_srl) > 10))
|
|
||||||
{
|
|
||||||
$listSqlID = 'document.getDocumentListUseIndex';
|
|
||||||
$divisionSqlID = 'document.getDocumentDivisionUseIndex';
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$listSqlID = 'document.getDocumentList';
|
|
||||||
$divisionSqlID = 'document.getDocumentDivision';
|
|
||||||
}
|
|
||||||
|
|
||||||
// If you do not value the best division top
|
|
||||||
if(!$division) {
|
|
||||||
$division_args->module_srl = $args->module_srl;
|
|
||||||
$division_args->exclude_module_srl = $args->exclude_module_srl;
|
|
||||||
$division_args->list_count = 1;
|
|
||||||
$division_args->sort_index = $args->sort_index;
|
|
||||||
$division_args->order_type = $args->order_type;
|
|
||||||
$division_args->statusList = $args->statusList;
|
|
||||||
$output = executeQuery($listSqlID, $division_args, $columnList);
|
|
||||||
if($output->data) {
|
|
||||||
$item = array_pop($output->data);
|
|
||||||
$division = $item->list_order;
|
|
||||||
}
|
|
||||||
$division_args = null;
|
|
||||||
}
|
|
||||||
// The last division
|
|
||||||
$last_division = (int)Context::get('last_division');
|
|
||||||
// Division after division from the 5000 value of the specified Wanted
|
|
||||||
if(!$last_division) {
|
|
||||||
$last_division_args->module_srl = $args->module_srl;
|
|
||||||
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
|
||||||
$last_division_args->list_count = 1;
|
|
||||||
$last_division_args->sort_index = $args->sort_index;
|
|
||||||
$last_division_args->order_type = $args->order_type;
|
|
||||||
$last_division_args->list_order = $division;
|
|
||||||
$last_division_args->page = 5001;
|
|
||||||
$output = executeQuery($divisionSqlID, $last_division_args, $columnList);
|
|
||||||
if($output->data) {
|
|
||||||
$item = array_pop($output->data);
|
|
||||||
$last_division = $item->list_order;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Make sure that after last_division article
|
|
||||||
if($last_division) {
|
|
||||||
$last_division_args = null;
|
|
||||||
$last_division_args->module_srl = $args->module_srl;
|
|
||||||
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
|
||||||
$last_division_args->list_order = $last_division;
|
|
||||||
$output = executeQuery("document.getDocumentDivisionCount", $last_division_args);
|
|
||||||
if($output->data->count<1) $last_division = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$args->division = $division;
|
|
||||||
$args->last_division = $last_division;
|
|
||||||
Context::set('division', $division);
|
|
||||||
Context::set('last_division', $last_division);
|
|
||||||
}
|
|
||||||
// document.getDocumentList query execution
|
|
||||||
// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
|
|
||||||
if(in_array($query_id, array('document.getDocumentListWithinComment', 'document.getDocumentListWithinTag'))) {
|
|
||||||
$group_args = clone($args);
|
|
||||||
$group_args->sort_index = 'documents.'.$args->sort_index;
|
|
||||||
$output = executeQueryArray($query_id, $group_args);
|
|
||||||
if(!$output->toBool()||!count($output->data)) return $output;
|
|
||||||
|
|
||||||
foreach($output->data as $key => $val) {
|
|
||||||
if($val->document_srl) $target_srls[] = $val->document_srl;
|
|
||||||
}
|
|
||||||
|
|
||||||
$page_navigation = $output->page_navigation;
|
|
||||||
$keys = array_keys($output->data);
|
|
||||||
$virtual_number = $keys[0];
|
|
||||||
|
|
||||||
$target_args->document_srls = implode(',',$target_srls);
|
|
||||||
$target_args->list_order = $args->sort_index;
|
|
||||||
$target_args->order_type = $args->order_type;
|
|
||||||
$target_args->list_count = $args->list_count;
|
|
||||||
$target_args->page = 1;
|
|
||||||
$output = executeQueryArray('document.getDocuments', $target_args);
|
|
||||||
$output->page_navigation = $page_navigation;
|
|
||||||
$output->total_count = $page_navigation->total_count;
|
|
||||||
$output->total_page = $page_navigation->total_page;
|
|
||||||
$output->page = $page_navigation->cur_page;
|
|
||||||
} else {
|
} else {
|
||||||
$output = executeQueryArray($query_id, $args, $columnList);
|
$cache_object = array();
|
||||||
|
$cache_object[] = $cache_key;
|
||||||
|
$oCacheHandler->put('module_list_documents',$cache_object);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Return if no result or an error occurs
|
|
||||||
if(!$output->toBool()||!count($output->data)) return $output;
|
|
||||||
|
|
||||||
$idx = 0;
|
|
||||||
$data = $output->data;
|
|
||||||
unset($output->data);
|
|
||||||
|
|
||||||
if(!isset($virtual_number))
|
|
||||||
{
|
|
||||||
$keys = array_keys($data);
|
|
||||||
$virtual_number = $keys[0];
|
|
||||||
}
|
}
|
||||||
|
if(!$output){
|
||||||
|
|
||||||
|
$logged_info = Context::get('logged_info');
|
||||||
|
$sort_check = $this->_setSortIndex($obj, $load_extra_vars);
|
||||||
|
|
||||||
|
$obj->sort_index = $sort_check->sort_index;
|
||||||
|
// Check the target and sequence alignment
|
||||||
|
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
|
||||||
|
// If that came across mid module_srl instead of a direct module_srl guhaejum
|
||||||
|
if($obj->mid) {
|
||||||
|
$oModuleModel = &getModel('module');
|
||||||
|
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
|
||||||
|
unset($obj->mid);
|
||||||
|
}
|
||||||
|
// Module_srl passed the array may be a check whether the array
|
||||||
|
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
|
||||||
|
else $args->module_srl = $obj->module_srl;
|
||||||
|
// Except for the test module_srl
|
||||||
|
if(is_array($obj->exclude_module_srl)) $args->exclude_module_srl = implode(',', $obj->exclude_module_srl);
|
||||||
|
else $args->exclude_module_srl = $obj->exclude_module_srl;
|
||||||
|
// Variable check
|
||||||
|
$args->category_srl = $obj->category_srl?$obj->category_srl:null;
|
||||||
|
$args->sort_index = $obj->sort_index;
|
||||||
|
$args->order_type = $obj->order_type;
|
||||||
|
$args->page = $obj->page?$obj->page:1;
|
||||||
|
$args->list_count = $obj->list_count?$obj->list_count:20;
|
||||||
|
$args->page_count = $obj->page_count?$obj->page_count:10;
|
||||||
|
$args->start_date = $obj->start_date?$obj->start_date:null;
|
||||||
|
$args->end_date = $obj->end_date?$obj->end_date:null;
|
||||||
|
$args->member_srl = $obj->member_srl;
|
||||||
|
$args->statusList = $obj->statusList?$obj->statusList:array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
|
||||||
|
if($logged_info->is_admin == 'Y') $args->statusList = array($this->getConfigStatus('secret'), $this->getConfigStatus('public'));
|
||||||
|
// Category is selected, further sub-categories until all conditions
|
||||||
|
if($args->category_srl) {
|
||||||
|
$category_list = $this->getCategoryList($args->module_srl);
|
||||||
|
$category_info = $category_list[$args->category_srl];
|
||||||
|
$category_info->childs[] = $args->category_srl;
|
||||||
|
$args->category_srl = implode(',',$category_info->childs);
|
||||||
|
}
|
||||||
|
// Used to specify the default query id (based on several search options to query id modified)
|
||||||
|
$query_id = 'document.getDocumentList';
|
||||||
|
// If the search by specifying the document division naeyonggeomsaekil processed for
|
||||||
|
$use_division = false;
|
||||||
|
|
||||||
|
// Search options
|
||||||
|
$searchOpt->search_target = $obj->search_target;
|
||||||
|
$searchOpt->search_keyword = $obj->search_keyword;
|
||||||
|
$this->_setSearchOption($searchOpt, $args, $query_id, $use_division);
|
||||||
|
|
||||||
|
if ($sort_check->isExtraVars)
|
||||||
|
{
|
||||||
|
$query_id = 'document.getDocumentListExtraSort';
|
||||||
|
$output = executeQueryArray($query_id, $args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* list_order asc sort of division that can be used only when
|
||||||
|
**/
|
||||||
|
if($args->sort_index != 'list_order' || $args->order_type != 'asc') $use_division = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If it is true, use_division changed to use the document division
|
||||||
|
**/
|
||||||
|
if($use_division) {
|
||||||
|
// Division begins
|
||||||
|
$division = (int)Context::get('division');
|
||||||
|
|
||||||
|
// order by list_order and (module_srl===0 or module_srl many count), therefore case table full scan
|
||||||
|
if($args->sort_index == 'list_order' && ($args->exclude_module_srl === 0 || count($args->module_srl) > 10))
|
||||||
|
{
|
||||||
|
$listSqlID = 'document.getDocumentListUseIndex';
|
||||||
|
$divisionSqlID = 'document.getDocumentDivisionUseIndex';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$listSqlID = 'document.getDocumentList';
|
||||||
|
$divisionSqlID = 'document.getDocumentDivision';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If you do not value the best division top
|
||||||
|
if(!$division) {
|
||||||
|
$division_args->module_srl = $args->module_srl;
|
||||||
|
$division_args->exclude_module_srl = $args->exclude_module_srl;
|
||||||
|
$division_args->list_count = 1;
|
||||||
|
$division_args->sort_index = $args->sort_index;
|
||||||
|
$division_args->order_type = $args->order_type;
|
||||||
|
$division_args->statusList = $args->statusList;
|
||||||
|
$output = executeQuery($listSqlID, $division_args, $columnList);
|
||||||
|
if($output->data) {
|
||||||
|
$item = array_pop($output->data);
|
||||||
|
$division = $item->list_order;
|
||||||
|
}
|
||||||
|
$division_args = null;
|
||||||
|
}
|
||||||
|
// The last division
|
||||||
|
$last_division = (int)Context::get('last_division');
|
||||||
|
// Division after division from the 5000 value of the specified Wanted
|
||||||
|
if(!$last_division) {
|
||||||
|
$last_division_args->module_srl = $args->module_srl;
|
||||||
|
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
||||||
|
$last_division_args->list_count = 1;
|
||||||
|
$last_division_args->sort_index = $args->sort_index;
|
||||||
|
$last_division_args->order_type = $args->order_type;
|
||||||
|
$last_division_args->list_order = $division;
|
||||||
|
$last_division_args->page = 5001;
|
||||||
|
$output = executeQuery($divisionSqlID, $last_division_args, $columnList);
|
||||||
|
if($output->data) {
|
||||||
|
$item = array_pop($output->data);
|
||||||
|
$last_division = $item->list_order;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Make sure that after last_division article
|
||||||
|
if($last_division) {
|
||||||
|
$last_division_args = null;
|
||||||
|
$last_division_args->module_srl = $args->module_srl;
|
||||||
|
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
|
||||||
|
$last_division_args->list_order = $last_division;
|
||||||
|
$output = executeQuery("document.getDocumentDivisionCount", $last_division_args);
|
||||||
|
if($output->data->count<1) $last_division = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args->division = $division;
|
||||||
|
$args->last_division = $last_division;
|
||||||
|
Context::set('division', $division);
|
||||||
|
Context::set('last_division', $last_division);
|
||||||
|
}
|
||||||
|
// document.getDocumentList query execution
|
||||||
|
// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
|
||||||
|
if(in_array($query_id, array('document.getDocumentListWithinComment', 'document.getDocumentListWithinTag'))) {
|
||||||
|
$group_args = clone($args);
|
||||||
|
$group_args->sort_index = 'documents.'.$args->sort_index;
|
||||||
|
$output = executeQueryArray($query_id, $group_args);
|
||||||
|
if(!$output->toBool()||!count($output->data)) return $output;
|
||||||
|
|
||||||
|
foreach($output->data as $key => $val) {
|
||||||
|
if($val->document_srl) $target_srls[] = $val->document_srl;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page_navigation = $output->page_navigation;
|
||||||
|
$keys = array_keys($output->data);
|
||||||
|
$virtual_number = $keys[0];
|
||||||
|
|
||||||
|
$target_args->document_srls = implode(',',$target_srls);
|
||||||
|
$target_args->list_order = $args->sort_index;
|
||||||
|
$target_args->order_type = $args->order_type;
|
||||||
|
$target_args->list_count = $args->list_count;
|
||||||
|
$target_args->page = 1;
|
||||||
|
$output = executeQueryArray('document.getDocuments', $target_args);
|
||||||
|
$output->page_navigation = $page_navigation;
|
||||||
|
$output->total_count = $page_navigation->total_count;
|
||||||
|
$output->total_page = $page_navigation->total_page;
|
||||||
|
$output->page = $page_navigation->cur_page;
|
||||||
|
} else {
|
||||||
|
$output = executeQueryArray($query_id, $args, $columnList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Return if no result or an error occurs
|
||||||
|
if(!$output->toBool()||!count($output->data)) return $output;
|
||||||
|
|
||||||
|
$idx = 0;
|
||||||
|
$data = $output->data;
|
||||||
|
unset($output->data);
|
||||||
|
|
||||||
|
if(!isset($virtual_number))
|
||||||
|
{
|
||||||
|
$keys = array_keys($data);
|
||||||
|
$virtual_number = $keys[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($except_notice) {
|
||||||
|
foreach($data as $key => $attribute) {
|
||||||
|
if($attribute->is_notice == 'Y') $virtual_number --;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($except_notice) {
|
|
||||||
foreach($data as $key => $attribute) {
|
foreach($data as $key => $attribute) {
|
||||||
if($attribute->is_notice == 'Y') $virtual_number --;
|
if($except_notice && $attribute->is_notice == 'Y') continue;
|
||||||
}
|
$document_srl = $attribute->document_srl;
|
||||||
}
|
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
|
||||||
|
$oDocument = null;
|
||||||
|
$oDocument = new documentItem();
|
||||||
|
$oDocument->setAttribute($attribute, false);
|
||||||
|
if($is_admin) $oDocument->setGrant();
|
||||||
|
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||||
|
$virtual_number --;
|
||||||
|
|
||||||
foreach($data as $key => $attribute) {
|
|
||||||
if($except_notice && $attribute->is_notice == 'Y') continue;
|
|
||||||
$document_srl = $attribute->document_srl;
|
|
||||||
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
|
|
||||||
$oDocument = null;
|
|
||||||
$oDocument = new documentItem();
|
|
||||||
$oDocument->setAttribute($attribute, false);
|
|
||||||
if($is_admin) $oDocument->setGrant();
|
|
||||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
||||||
$virtual_number --;
|
|
||||||
|
|
||||||
|
if(count($output->data)) {
|
||||||
|
foreach($output->data as $number => $document) {
|
||||||
|
$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//insert in cache
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
|
||||||
|
|
||||||
if(count($output->data)) {
|
|
||||||
foreach($output->data as $number => $document) {
|
|
||||||
$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,13 @@
|
||||||
$oLayoutModel = &getModel('layout');
|
$oLayoutModel = &getModel('layout');
|
||||||
$cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType());
|
$cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType());
|
||||||
FileHandler::removeFile($cache_file);
|
FileHandler::removeFile($cache_file);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$args->layout_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +218,13 @@
|
||||||
// Delete Layout
|
// Delete Layout
|
||||||
$args->layout_srl = $layout_srl;
|
$args->layout_srl = $layout_srl;
|
||||||
$output = executeQuery("layout.deleteLayout", $args);
|
$output = executeQuery("layout.deleteLayout", $args);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport())
|
||||||
|
{
|
||||||
|
$cache_key = 'object:'.$layout_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
return new Object(0,'success_deleted');
|
return new Object(0,'success_deleted');
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,25 @@
|
||||||
* @brief Get one of layout information created in the DB
|
* @brief Get one of layout information created in the DB
|
||||||
* Return DB info + XML info of the generated layout
|
* Return DB info + XML info of the generated layout
|
||||||
**/
|
**/
|
||||||
function getLayout($layout_srl) {
|
function getLayout($layout_srl) {
|
||||||
// Get information from the DB
|
// cache controll
|
||||||
$args->layout_srl = $layout_srl;
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
$output = executeQuery('layout.getLayout', $args);
|
if($oCacheHandler->isSupport()){
|
||||||
if(!$output->data) return;
|
$cache_key = 'object:'.$layout_srl;
|
||||||
// Return xml file informaton after listing up the layout and extra_vars
|
$layout_info = $oCacheHandler->get($cache_key);
|
||||||
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
|
}
|
||||||
return $layout_info;
|
if(!$layout_info) {
|
||||||
|
// Get information from the DB
|
||||||
|
$args->layout_srl = $layout_srl;
|
||||||
|
$output = executeQuery('layout.getLayout', $args);
|
||||||
|
if(!$output->data) return;
|
||||||
|
// Return xml file informaton after listing up the layout and extra_vars
|
||||||
|
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
|
||||||
|
//insert in cache
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$layout_info);
|
||||||
|
}
|
||||||
|
return $layout_info;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1698,7 +1698,12 @@
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
// Save Session
|
// Save Session
|
||||||
if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
|
if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$args->member_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
$logged_info = Context::get('logged_info');
|
$logged_info = Context::get('logged_info');
|
||||||
|
|
||||||
$output->add('member_srl', $args->member_srl);
|
$output->add('member_srl', $args->member_srl);
|
||||||
|
|
@ -1710,6 +1715,12 @@
|
||||||
**/
|
**/
|
||||||
function updateMemberPassword($args) {
|
function updateMemberPassword($args) {
|
||||||
$output = executeQuery('member.updateChangePasswordDate', $args);
|
$output = executeQuery('member.updateChangePasswordDate', $args);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$args->member_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
$args->password = md5($args->password);
|
$args->password = md5($args->password);
|
||||||
return executeQuery('member.updateMemberPassword', $args);
|
return executeQuery('member.updateMemberPassword', $args);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -182,11 +182,21 @@
|
||||||
//columnList size zero... get full member info
|
//columnList size zero... get full member info
|
||||||
if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0) {
|
if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0) {
|
||||||
//if(true) {
|
//if(true) {
|
||||||
$args->member_srl = $member_srl;
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
$output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList);
|
if($oCacheHandler->isSupport()){
|
||||||
if(!$output->data) return;
|
$cache_key = 'object:'.$member_srl;
|
||||||
|
$output = $oCacheHandler->get($cache_key);
|
||||||
$this->arrangeMemberInfo($output->data, $site_srl);
|
}
|
||||||
|
if(!$output){
|
||||||
|
$args->member_srl = $member_srl;
|
||||||
|
$output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList);
|
||||||
|
if(!$output->data) return;
|
||||||
|
//insert in cache
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->arrangeMemberInfo($output->data, $site_srl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $GLOBALS['__member_info__'][$member_srl];
|
return $GLOBALS['__member_info__'][$member_srl];
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,12 @@
|
||||||
// Register
|
// Register
|
||||||
$oModuleController->insertModuleSkinVars($module_srl, $obj);
|
$oModuleController->insertModuleSkinVars($module_srl, $obj);
|
||||||
}
|
}
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$module_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
|
||||||
$this->setLayoutPath('./common/tpl');
|
$this->setLayoutPath('./common/tpl');
|
||||||
$this->setLayoutFile('default_layout.html');
|
$this->setLayoutFile('default_layout.html');
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,12 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
$output = executeQuery('module.updateSite', $args);
|
$output = executeQuery('module.updateSite', $args);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.'default_mid';
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,6 +315,14 @@
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
|
||||||
$output->add('module_srl',$args->module_srl);
|
$output->add('module_srl',$args->module_srl);
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$args->module_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
$cache_key = 'object:'.$args->mid;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -364,7 +378,14 @@
|
||||||
|
|
||||||
// commit
|
// commit
|
||||||
$oDB->commit();
|
$oDB->commit();
|
||||||
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$args->module_srl;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
$cache_key = 'object:'.$args->mid;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,7 +407,13 @@
|
||||||
**/
|
**/
|
||||||
function clearDefaultModule() {
|
function clearDefaultModule() {
|
||||||
$output = executeQuery('module.clearDefaultModule');
|
$output = executeQuery('module.clearDefaultModule');
|
||||||
if(!$output->toBool()) return $output;
|
//remove from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.'default_mid';
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,60 +68,68 @@
|
||||||
* @brief Get the defaul mid according to the domain
|
* @brief Get the defaul mid according to the domain
|
||||||
**/
|
**/
|
||||||
function getDefaultMid() {
|
function getDefaultMid() {
|
||||||
$default_url = preg_replace('/\/$/','',Context::getDefaultUrl());
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
$request_url = preg_replace('/\/$/','',Context::getRequestUri());
|
if($oCacheHandler->isSupport()){
|
||||||
$vid = Context::get('vid');
|
$cache_key = 'object:'.'default_mid';
|
||||||
$mid = Context::get('mid');
|
$output = $oCacheHandler->get($cache_key);
|
||||||
// Check a virtual site if the default URL is already set and is is defferent from a requested URL
|
}
|
||||||
if($default_url && $default_url != $request_url) {
|
if(!$output){
|
||||||
$url_info = parse_url($request_url);
|
$default_url = preg_replace('/\/$/','',Context::getDefaultUrl());
|
||||||
$hostname = $url_info['host'];
|
$request_url = preg_replace('/\/$/','',Context::getRequestUri());
|
||||||
$path = preg_replace('/\/$/','',$url_info['path']);
|
$vid = Context::get('vid');
|
||||||
$sites_args->domain = sprintf('%s%s%s', $hostname, $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$path);
|
$mid = Context::get('mid');
|
||||||
$output = executeQuery('module.getSiteInfoByDomain', $sites_args);
|
// Check a virtual site if the default URL is already set and is is defferent from a requested URL
|
||||||
}
|
if($default_url && $default_url != $request_url) {
|
||||||
if(!$output || !$output->data)
|
$url_info = parse_url($request_url);
|
||||||
{
|
$hostname = $url_info['host'];
|
||||||
if(!$vid) $vid = $mid;
|
$path = preg_replace('/\/$/','',$url_info['path']);
|
||||||
if($vid) {
|
$sites_args->domain = sprintf('%s%s%s', $hostname, $url_info['port']&&$url_info['port']!=80?':'.$url_info['port']:'',$path);
|
||||||
$vid_args->domain = $vid;
|
$output = executeQuery('module.getSiteInfoByDomain', $sites_args);
|
||||||
$output = executeQuery('module.getSiteInfoByDomain', $vid_args);
|
}
|
||||||
if($output->toBool() && $output->data) {
|
if(!$output || !$output->data)
|
||||||
Context::set('vid', $output->data->domain, true);
|
{
|
||||||
if($mid==$output->data->domain) Context::set('mid',$output->data->mid,true);
|
if(!$vid) $vid = $mid;
|
||||||
}
|
if($vid) {
|
||||||
}
|
$vid_args->domain = $vid;
|
||||||
}
|
$output = executeQuery('module.getSiteInfoByDomain', $vid_args);
|
||||||
// If it is not a virtual site, get a default site information
|
if($output->toBool() && $output->data) {
|
||||||
if(!$output->data) {
|
Context::set('vid', $output->data->domain, true);
|
||||||
$args->site_srl = 0;
|
if($mid==$output->data->domain) Context::set('mid',$output->data->mid,true);
|
||||||
$output = executeQuery('module.getSiteInfo', $args);
|
}
|
||||||
// Update the related informaion if there is no default site info
|
}
|
||||||
if(!$output->data) {
|
}
|
||||||
// Create a table if sites table doesn't exist
|
// If it is not a virtual site, get a default site information
|
||||||
$oDB = &DB::getInstance();
|
if(!$output->data) {
|
||||||
if(!$oDB->isTableExists('sites')) $oDB->createTableByXmlFile(_XE_PATH_.'modules/module/schemas/sites.xml');
|
$args->site_srl = 0;
|
||||||
if(!$oDB->isTableExists('sites')) return;
|
$output = executeQuery('module.getSiteInfo', $args);
|
||||||
// Get mid, language
|
// Update the related informaion if there is no default site info
|
||||||
$mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args);
|
if(!$output->data) {
|
||||||
$db_info = Context::getDBInfo();
|
// Create a table if sites table doesn't exist
|
||||||
$domain = Context::getDefaultUrl();
|
$oDB = &DB::getInstance();
|
||||||
$url_info = parse_url($domain);
|
if(!$oDB->isTableExists('sites')) $oDB->createTableByXmlFile(_XE_PATH_.'modules/module/schemas/sites.xml');
|
||||||
$domain = $url_info['host'].( (!empty($url_info['port'])&&$url_info['port']!=80)?':'.$url_info['port']:'').$url_info['path'];
|
if(!$oDB->isTableExists('sites')) return;
|
||||||
$site_args->site_srl = 0;
|
// Get mid, language
|
||||||
$site_args->index_module_srl = $mid_output->data->module_srl;
|
$mid_output = $oDB->executeQuery('module.getDefaultMidInfo', $args);
|
||||||
$site_args->domain = $domain;
|
$db_info = Context::getDBInfo();
|
||||||
$site_args->default_language = $db_info->lang_type;
|
$domain = Context::getDefaultUrl();
|
||||||
|
$url_info = parse_url($domain);
|
||||||
if($output->data && !$output->data->index_module_srl) {
|
$domain = $url_info['host'].( (!empty($url_info['port'])&&$url_info['port']!=80)?':'.$url_info['port']:'').$url_info['path'];
|
||||||
$output = executeQuery('module.updateSite', $site_args);
|
$site_args->site_srl = 0;
|
||||||
} else {
|
$site_args->index_module_srl = $mid_output->data->module_srl;
|
||||||
$output = executeQuery('module.insertSite', $site_args);
|
$site_args->domain = $domain;
|
||||||
if(!$output->toBool()) return $output;
|
$site_args->default_language = $db_info->lang_type;
|
||||||
}
|
|
||||||
$output = executeQuery('module.getSiteInfo', $args);
|
if($output->data && !$output->data->index_module_srl) {
|
||||||
}
|
$output = executeQuery('module.updateSite', $site_args);
|
||||||
}
|
} else {
|
||||||
|
$output = executeQuery('module.insertSite', $site_args);
|
||||||
|
if(!$output->toBool()) return $output;
|
||||||
|
}
|
||||||
|
$output = executeQuery('module.getSiteInfo', $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
|
||||||
|
}
|
||||||
$module_info = $output->data;
|
$module_info = $output->data;
|
||||||
if(!$module_info->module_srl) return $module_info;
|
if(!$module_info->module_srl) return $module_info;
|
||||||
if(is_array($module_info) && $module_info->data[0]) $module_info = $module_info[0];
|
if(is_array($module_info) && $module_info->data[0]) $module_info = $module_info[0];
|
||||||
|
|
@ -134,7 +142,23 @@
|
||||||
function getModuleInfoByMid($mid, $site_srl = 0, $columnList = array()) {
|
function getModuleInfoByMid($mid, $site_srl = 0, $columnList = array()) {
|
||||||
$args->mid = $mid;
|
$args->mid = $mid;
|
||||||
$args->site_srl = (int)$site_srl;
|
$args->site_srl = (int)$site_srl;
|
||||||
$output = executeQuery('module.getMidInfo', $args, $columnList);
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$mid;
|
||||||
|
$module_srl = $oCacheHandler->get($cache_key);
|
||||||
|
if($module_srl){
|
||||||
|
$cache_key = 'object:'.$module_srl;
|
||||||
|
$output = $oCacheHandler->get($cache_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$output){
|
||||||
|
$output = executeQuery('module.getMidInfo', $args);
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$mid;
|
||||||
|
$oCacheHandler->put($cache_key,$output->data->module_srl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$module_info = $output->data;
|
$module_info = $output->data;
|
||||||
if(!$module_info->module_srl && $module_info->data[0]) $module_info = $module_info->data[0];
|
if(!$module_info->module_srl && $module_info->data[0]) $module_info = $module_info->data[0];
|
||||||
return $this->addModuleExtraVars($module_info);
|
return $this->addModuleExtraVars($module_info);
|
||||||
|
|
@ -146,10 +170,24 @@
|
||||||
function getModuleInfoByModuleSrl($module_srl, $columnList = array()) {
|
function getModuleInfoByModuleSrl($module_srl, $columnList = array()) {
|
||||||
// Get data
|
// Get data
|
||||||
$args->module_srl = $module_srl;
|
$args->module_srl = $module_srl;
|
||||||
$output = executeQuery('module.getMidInfo', $args, $columnList);
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
if(!$output->data) return;
|
if($oCacheHandler->isSupport()){
|
||||||
$module_info = $this->addModuleExtraVars($output->data);
|
$cache_key = 'object:'.$module_srl;
|
||||||
return $module_info;
|
$output = $oCacheHandler->get($cache_key);
|
||||||
|
}
|
||||||
|
if(!$output){
|
||||||
|
$output = executeQuery('module.getMidInfo', $args );
|
||||||
|
if(!$output->data) return;
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key,$output);
|
||||||
|
}
|
||||||
|
if(count($columnList)){
|
||||||
|
foreach ($output->data as $key => $item) {
|
||||||
|
if (in_array($key, $columnList)){
|
||||||
|
$module_info->$key = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else $module_info = $output->data;
|
||||||
|
return $this->addModuleExtraVars($module_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
12
modules/session/queries/getExpiredSessions.xml
Normal file
12
modules/session/queries/getExpiredSessions.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<query id="getExpiredSession" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="session" />
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="session_key" />
|
||||||
|
</columns>
|
||||||
|
<conditions>
|
||||||
|
<condition operation="less" column="expired" default="curdate()" notnull="notnull" />
|
||||||
|
</conditions>
|
||||||
|
</query>
|
||||||
|
|
||||||
|
|
@ -23,11 +23,21 @@
|
||||||
|
|
||||||
function write($session_key, $val) {
|
function write($session_key, $val) {
|
||||||
if(!$session_key || !$this->session_started) return;
|
if(!$session_key || !$this->session_started) return;
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$cache_vars = $oCacheHandler->get($cache_key);
|
||||||
|
}
|
||||||
|
|
||||||
$args->session_key = $session_key;
|
$args->session_key = $session_key;
|
||||||
$output = executeQuery('session.getSession', $args);
|
if($cache_vars) $session_info = $cache_vars;
|
||||||
$session_info = $output->data;
|
else {
|
||||||
|
$output = executeQuery('session.getSession', $args);
|
||||||
|
$session_info = $output->data;
|
||||||
|
}
|
||||||
|
//if ip has changed delete the session from cache and db
|
||||||
if($session_info->session_key == $session_key && $session_info->ipaddress != $_SERVER['REMOTE_ADDR']) {
|
if($session_info->session_key == $session_key && $session_info->ipaddress != $_SERVER['REMOTE_ADDR']) {
|
||||||
|
if($oCacheHandler->isSupport()) $oCacheHandler->delete($cache_key);
|
||||||
executeQuery('session.deleteSession', $args);
|
executeQuery('session.deleteSession', $args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -46,16 +56,53 @@
|
||||||
} else {
|
} else {
|
||||||
$args->member_srl = 0;
|
$args->member_srl = 0;
|
||||||
}
|
}
|
||||||
|
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||||
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
|
$args->last_update = date("YmdHis", time());
|
||||||
else $output = executeQuery('session.insertSession', $args);
|
$diff = $args->last_update - $cache_vars->last_update;
|
||||||
|
//verify if session values have changed
|
||||||
|
if($val == $cache_vars->val){
|
||||||
|
// if more than 5 minutes passed than modify the db session also
|
||||||
|
if($diff > 300){
|
||||||
|
//put session into cache
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$oCacheHandler->put($cache_key,$args);
|
||||||
|
}
|
||||||
|
//put session into db
|
||||||
|
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//put session into cache
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$oCacheHandler->put($cache_key,$args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//put session into cache
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$oCacheHandler->put($cache_key,$args);
|
||||||
|
}
|
||||||
|
//put session into db
|
||||||
|
if($session_info->session_key) $output = executeQuery('session.updateSession', $args);
|
||||||
|
else $output = executeQuery('session.insertSession', $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy($session_key) {
|
function destroy($session_key) {
|
||||||
if(!$session_key || !$this->session_started) return;
|
if(!$session_key || !$this->session_started) return;
|
||||||
|
//remove session from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
//remove session from db
|
||||||
$args->session_key = $session_key;
|
$args->session_key = $session_key;
|
||||||
executeQuery('session.deleteSession', $args);
|
executeQuery('session.deleteSession', $args);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -63,6 +110,17 @@
|
||||||
|
|
||||||
function gc($maxlifetime) {
|
function gc($maxlifetime) {
|
||||||
if(!$this->session_started) return;
|
if(!$this->session_started) return;
|
||||||
|
$expired_sessions = executeQueryArray('session.getExpiredSessions');
|
||||||
|
if($expired_session){
|
||||||
|
foreach ($expired_sessions as $session_key){
|
||||||
|
//remove session from cache
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()) {
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$oCacheHandler->delete($cache_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
executeQuery('session.gcSession');
|
executeQuery('session.gcSession');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,23 +19,31 @@
|
||||||
|
|
||||||
function read($session_key) {
|
function read($session_key) {
|
||||||
if(!$session_key || !$this->session_started) return;
|
if(!$session_key || !$this->session_started) return;
|
||||||
|
|
||||||
|
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||||
|
if($oCacheHandler->isSupport()){
|
||||||
|
$cache_key = 'object:'.$session_key;
|
||||||
|
$output->data = $oCacheHandler->get($cache_key);
|
||||||
|
}
|
||||||
|
if(!$output->data) {
|
||||||
|
|
||||||
$args->session_key = $session_key;
|
$args->session_key = $session_key;
|
||||||
$columnList = array('session_key', 'cur_mid', 'val');
|
$columnList = array('session_key', 'cur_mid', 'val');
|
||||||
$output = executeQuery('session.getSession', $args, $columnList);
|
$output = executeQuery('session.getSession', $args, $columnList);
|
||||||
// Confirm there is a table created if read error occurs
|
// Confirm there is a table created if read error occurs
|
||||||
if(!$output->toBool()) {
|
if(!$output->toBool()) {
|
||||||
$oDB = &DB::getInstance();
|
$oDB = &DB::getInstance();
|
||||||
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
|
if(!$oDB->isTableExists('session')) $oDB->createTableByXmlFile($this->module_path.'schemas/session.xml');
|
||||||
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
||||||
$output = executeQuery('session.getSession', $args);
|
$output = executeQuery('session.getSession', $args);
|
||||||
}
|
}
|
||||||
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
|
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
|
||||||
if(!isset($output->data->cur_mid)) {
|
if(!isset($output->data->cur_mid)) {
|
||||||
$oDB = &DB::getInstance();
|
$oDB = &DB::getInstance();
|
||||||
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
if(!$oDB->isColumnExists("session","cur_mid")) $oDB->addColumn('session',"cur_mid","varchar",128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return $output->data->val;
|
return $output->data->val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue