mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-11 22:42:14 +09:00
Merge pull request #996 from conory/pr/move_document
문서 이동 / 첨부 파일 삭제 기능 개선
This commit is contained in:
commit
8d812992e7
26 changed files with 743 additions and 782 deletions
|
|
@ -114,6 +114,15 @@ class comment extends ModuleObject
|
|||
return true;
|
||||
}
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'comment', 'controller', 'triggerMoveDocument', 'after'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('document.copyDocumentModule', 'comment', 'controller', 'triggerAddCopyDocument', 'add'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -204,6 +213,15 @@ class comment extends ModuleObject
|
|||
{
|
||||
$oDB->addIndex('comments', 'idx_nick_name', array('nick_name'));
|
||||
}
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'comment', 'controller', 'triggerMoveDocument', 'after'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.moveDocumentModule', 'comment', 'controller', 'triggerMoveDocument', 'after');
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('document.copyDocumentModule', 'comment', 'controller', 'triggerAddCopyDocument', 'add'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.copyDocumentModule', 'comment', 'controller', 'triggerAddCopyDocument', 'add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1726,7 +1726,45 @@ class commentController extends comment
|
|||
|
||||
$this->add('comment_list', $commentList);
|
||||
}
|
||||
|
||||
|
||||
function triggerMoveDocument($obj)
|
||||
{
|
||||
executeQuery('comment.updateCommentModule', $obj);
|
||||
executeQuery('comment.updateCommentListModule', $obj);
|
||||
}
|
||||
|
||||
function triggerAddCopyDocument(&$obj)
|
||||
{
|
||||
$args = new stdClass;
|
||||
$args->document_srls = $obj->source->document_srl;
|
||||
$comment_list = executeQueryArray('comment.getCommentsByDocumentSrls', $args)->data;
|
||||
|
||||
$copied_comments = array();
|
||||
foreach($comment_list as $comment)
|
||||
{
|
||||
$copy = clone $comment;
|
||||
$copy->comment_srl = getNextSequence();
|
||||
$copy->module_srl = $obj->copied->module_srl;
|
||||
$copy->document_srl = $obj->copied->document_srl;
|
||||
$copy->parent_srl = $comment->parent_srl ? $copied_comments[$comment->parent_srl] : 0;
|
||||
|
||||
// call a trigger (add)
|
||||
$args = new stdClass;
|
||||
$args->source = $comment;
|
||||
$args->copied = $copy;
|
||||
ModuleHandler::triggerCall('comment.copyCommentByDocument', 'add', $args);
|
||||
|
||||
// insert a copied comment
|
||||
$this->insertComment($copy, true);
|
||||
|
||||
$copied_comments[$comment->comment_srl] = $copy->comment_srl;
|
||||
}
|
||||
|
||||
// update
|
||||
$obj->copied->last_updater = $copy->nick_name;
|
||||
$obj->copied->comment_count = count($copied_comments);
|
||||
}
|
||||
|
||||
function triggerCopyModule(&$obj)
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
|
|
@ -1741,7 +1779,6 @@ class commentController extends comment
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file comment.controller.php */
|
||||
/* Location: ./modules/comment/comment.controller.php */
|
||||
|
|
|
|||
14
modules/comment/queries/getCommentsByDocumentSrls.xml
Normal file
14
modules/comment/queries/getCommentsByDocumentSrls.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<query id="getCommentsByDocumentSrls" action="select">
|
||||
<tables>
|
||||
<table name="comments" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="document_srl" var="document_srls" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="sort_index" default="comment_srl" order="asc" />
|
||||
</navigation>
|
||||
</query>
|
||||
|
|
@ -43,402 +43,7 @@ class documentAdminController extends document
|
|||
|
||||
$this->setMessage(sprintf(lang('msg_checked_document_is_deleted'), $document_count) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the module to move a specific article
|
||||
* @param array $document_srl_list
|
||||
* @param int $module_srl
|
||||
* @param int $category_srl
|
||||
* @return Object
|
||||
*/
|
||||
function moveDocumentModule($document_srl_list, $module_srl, $category_srl)
|
||||
{
|
||||
if(!count($document_srl_list)) return;
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocumentController = getController('document');
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$triggerObj = new stdClass();
|
||||
$triggerObj->document_srls = implode(',',$document_srl_list);
|
||||
$triggerObj->module_srl = $module_srl;
|
||||
$triggerObj->category_srl = $category_srl;
|
||||
// Call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $triggerObj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
for($i=count($document_srl_list)-1;$i>=0;$i--)
|
||||
{
|
||||
$document_srl = $document_srl_list[$i];
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
if(!$oDocument->isExists()) continue;
|
||||
|
||||
$source_category_srl = $oDocument->get('category_srl');
|
||||
|
||||
unset($obj);
|
||||
$obj = $oDocument->getObjectVars();
|
||||
|
||||
// ISSUE https://github.com/xpressengine/xe-core/issues/32
|
||||
$args_doc_origin = new stdClass();
|
||||
$args_doc_origin->document_srl = $document_srl;
|
||||
$output_ori = executeQuery('document.getDocument', $args_doc_origin, array('content'));
|
||||
$obj->content = $output_ori->data->content;
|
||||
|
||||
// Move the attached file if the target module is different
|
||||
if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
|
||||
{
|
||||
$args = new stdClass;
|
||||
$args->module_srl = $module_srl;
|
||||
$args->upload_target_srl = $oDocument->get('document_srl');
|
||||
$output = executeQuery('file.updateFileModule', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if($module_srl != $obj->module_srl)
|
||||
{
|
||||
$oDocumentController->deleteDocumentAliasByDocument($obj->document_srl);
|
||||
}
|
||||
|
||||
// Move a module of the article
|
||||
$obj->module_srl = $module_srl;
|
||||
$obj->category_srl = $category_srl;
|
||||
$output = executeQuery('document.updateDocumentModule', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
$update_output = $oDocumentController->insertDocumentUpdateLog($obj);
|
||||
if(!$update_output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $update_output;
|
||||
}
|
||||
}
|
||||
|
||||
// Move a module of the extra vars
|
||||
$output = executeQuery('document.moveDocumentExtraVars', $obj);
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Set 0 if a new category doesn't exist after catergory change
|
||||
if($source_category_srl != $category_srl)
|
||||
{
|
||||
if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
|
||||
if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
|
||||
}
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
$args->document_srls = implode(',',$document_srl_list);
|
||||
$args->module_srl = $module_srl;
|
||||
|
||||
// move the comment
|
||||
$output = executeQuery('comment.updateCommentModule', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output = executeQuery('comment.updateCommentListModule', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// move the trackback
|
||||
if(getClass('trackback'))
|
||||
{
|
||||
$output = executeQuery('trackback.updateTrackbackModule', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Tags
|
||||
$output = executeQuery('tag.updateTagModule', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Call a trigger (after)
|
||||
ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $triggerObj);
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
//remove from cache
|
||||
foreach ($document_srl_list as $document_srl)
|
||||
{
|
||||
Rhymix\Framework\Cache::delete('document_item:'. getNumberingPath($document_srl) . $document_srl);
|
||||
}
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the post
|
||||
* @param array $document_srl_list
|
||||
* @param int $module_srl
|
||||
* @param int $category_srl
|
||||
* @return object
|
||||
*/
|
||||
function copyDocumentModule($document_srl_list, $module_srl, $category_srl)
|
||||
{
|
||||
if(count($document_srl_list) < 1) return;
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocumentController = getController('document');
|
||||
|
||||
$oFileModel = getModel('file');
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$triggerObj = new stdClass();
|
||||
$triggerObj->document_srls = implode(',',$document_srl_list);
|
||||
$triggerObj->module_srl = $module_srl;
|
||||
$triggerObj->category_srl = $category_srl;
|
||||
// Call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$extraVarsList = $oDocumentModel->getDocumentExtraVarsFromDB($document_srl_list);
|
||||
$extraVarsListByDocumentSrl = array();
|
||||
if(is_array($extraVarsList->data))
|
||||
{
|
||||
foreach($extraVarsList->data as $value)
|
||||
{
|
||||
if(!isset($extraVarsListByDocumentSrl[$value->document_srl]))
|
||||
{
|
||||
$extraVarsListByDocumentSrl[$value->document_srl] = array();
|
||||
}
|
||||
|
||||
$extraVarsListByDocumentSrl[$value->document_srl][] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
for($i=count($document_srl_list)-1;$i>=0;$i--)
|
||||
{
|
||||
$document_srl = $document_srl_list[$i];
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
if(!$oDocument->isExists()) continue;
|
||||
|
||||
$obj = $oDocument->getObjectVars();
|
||||
|
||||
$extraVars = $extraVarsListByDocumentSrl[$document_srl];
|
||||
if($module_srl == $obj->module_srl)
|
||||
{
|
||||
if(is_array($extraVars))
|
||||
{
|
||||
foreach($extraVars as $extraItem)
|
||||
{
|
||||
if($extraItem->var_idx >= 0) $obj->{'extra_vars'.$extraItem->var_idx} = $extraItem->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$obj->module_srl = $module_srl;
|
||||
$obj->document_srl = getNextSequence();
|
||||
$obj->category_srl = $category_srl;
|
||||
$obj->password_is_hashed = true;
|
||||
$obj->comment_count = 0;
|
||||
$obj->trackback_count = 0;
|
||||
|
||||
// Pre-register the attachment
|
||||
if($oDocument->hasUploadedFiles())
|
||||
{
|
||||
$files = $oDocument->getUploadedFiles();
|
||||
foreach($files as $val)
|
||||
{
|
||||
$file_info = array();
|
||||
$file_info['tmp_name'] = $val->uploaded_filename;
|
||||
$file_info['name'] = $val->source_filename;
|
||||
$oFileController = getController('file');
|
||||
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
|
||||
// if image/video files
|
||||
if($val->direct_download == 'Y')
|
||||
{
|
||||
$source_filename = substr($val->uploaded_filename,2);
|
||||
$target_filename = substr($inserted_file->get('uploaded_filename'),2);
|
||||
$obj->content = str_replace($source_filename, $target_filename, $obj->content);
|
||||
// If binary file
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
|
||||
$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write a post
|
||||
$output = $oDocumentController->insertDocument($obj, true, true);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// copy multi language contents
|
||||
if(is_array($extraVars))
|
||||
{
|
||||
foreach($extraVars as $value)
|
||||
{
|
||||
if($value->idx >= 0 && $value->lang_code == Context::getLangType())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( $value->var_idx < 0 || ($module_srl == $value->module_srl && $value->var_idx >= 0) )
|
||||
{
|
||||
$oDocumentController->insertDocumentExtraVar($value->module_srl, $obj->document_srl, $value->var_idx, $value->value, $value->eid, $value->lang_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move the comments
|
||||
if($oDocument->getCommentCount())
|
||||
{
|
||||
$oCommentModel = getModel('comment');
|
||||
$comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999);
|
||||
$comments = $comment_output->data;
|
||||
if(count($comments) > 0)
|
||||
{
|
||||
$oCommentController = getController('comment');
|
||||
$success_count = 0;
|
||||
$p_comment_srl = array();
|
||||
foreach($comments as $comment_obj)
|
||||
{
|
||||
$comment_srl = getNextSequence();
|
||||
$p_comment_srl[$comment_obj->comment_srl] = $comment_srl;
|
||||
|
||||
// Pre-register the attachment
|
||||
if($comment_obj->uploaded_count)
|
||||
{
|
||||
$files = $oFileModel->getFiles($comment_obj->comment_srl, true);
|
||||
foreach($files as $val)
|
||||
{
|
||||
$file_info = array();
|
||||
$file_info['tmp_name'] = $val->uploaded_filename;
|
||||
$file_info['name'] = $val->source_filename;
|
||||
$oFileController = getController('file');
|
||||
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true);
|
||||
// if image/video files
|
||||
if($val->direct_download == 'Y')
|
||||
{
|
||||
$source_filename = substr($val->uploaded_filename,2);
|
||||
$target_filename = substr($inserted_file->get('uploaded_filename'),2);
|
||||
$comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content);
|
||||
// If binary file
|
||||
}
|
||||
else
|
||||
{
|
||||
$comment_obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $comment_obj->content);
|
||||
$comment_obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $comment_obj->content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$comment_obj->module_srl = $obj->module_srl;
|
||||
$comment_obj->document_srl = $obj->document_srl;
|
||||
$comment_obj->comment_srl = $comment_srl;
|
||||
|
||||
if($comment_obj->parent_srl) $comment_obj->parent_srl = $p_comment_srl[$comment_obj->parent_srl];
|
||||
|
||||
$output = $oCommentController->insertComment($comment_obj, true);
|
||||
if($output->toBool()) $success_count ++;
|
||||
}
|
||||
$oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Move the trackbacks
|
||||
$oTrackbackModel = getModel('trackback');
|
||||
if($oTrackbackModel && $oDocument->getTrackbackCount())
|
||||
{
|
||||
$trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl);
|
||||
if(count($trackbacks))
|
||||
{
|
||||
$success_count = 0;
|
||||
foreach($trackbacks as $trackback_obj)
|
||||
{
|
||||
$trackback_obj->trackback_srl = getNextSequence();
|
||||
$trackback_obj->module_srl = $obj->module_srl;
|
||||
$trackback_obj->document_srl = $obj->document_srl;
|
||||
$output = executeQuery('trackback.insertTrackback', $trackback_obj);
|
||||
if($output->toBool()) $success_count++;
|
||||
}
|
||||
// Update the number of trackbacks
|
||||
$oDocumentController->updateTrackbackCount($obj->document_srl, $success_count);
|
||||
}
|
||||
}
|
||||
|
||||
$copied_srls[$document_srl] = $obj->document_srl;
|
||||
}
|
||||
|
||||
// Call a trigger (before)
|
||||
$triggerObj->copied_srls = $copied_srls;
|
||||
ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj);
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
$output = new BaseObject();
|
||||
$output->add('copied_srls', $copied_srls);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all documents of the module
|
||||
* @param int $module_srl
|
||||
* @return object
|
||||
*/
|
||||
function deleteModuleDocument($module_srl)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$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);
|
||||
if(is_array($documents))
|
||||
{
|
||||
foreach ($documents as $oDocument)
|
||||
{
|
||||
$document_srl_list[] = $oDocument->document_srl;
|
||||
}
|
||||
}
|
||||
|
||||
//remove from cache
|
||||
foreach ($document_srl_list as $document_srl)
|
||||
{
|
||||
Rhymix\Framework\Cache::delete('document_item:'. getNumberingPath($document_srl) . $document_srl);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the default settings of the document module
|
||||
* @return object
|
||||
|
|
@ -788,60 +393,222 @@ class documentAdminController extends document
|
|||
$trash_srl = Context::get('trash_srl');
|
||||
$this->restoreTrash($trash_srl);
|
||||
}
|
||||
|
||||
/*function restoreTrash($trash_srl){
|
||||
$oDB = &DB::getInstance();
|
||||
$oDocumentModel = getModel('document');
|
||||
|
||||
$trash_args->trash_srl = $trash_srl;
|
||||
|
||||
$output = executeQuery('document.getTrash', $trash_args);
|
||||
if (!$output->toBool()) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$document_args->document_srl = $output->data->document_srl;
|
||||
$document_args->module_srl = $output->data->module_srl;
|
||||
$document_args->member_srl = $output->data->member_srl;
|
||||
$document_args->ipaddress = $output->data->ipaddress;
|
||||
$document_args->update_order = $output->data->update_order;
|
||||
|
||||
$oDocument = $oDocumentModel->getDocument($document_args->document_srl);
|
||||
|
||||
// begin transaction
|
||||
$oDB->begin();
|
||||
|
||||
$output = executeQuery('document.updateDocument', $document_args);
|
||||
if (!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
|
||||
/**
|
||||
* Move module of the documents
|
||||
* @param array $document_srl_list
|
||||
* @param int $target_module_srl
|
||||
* @param int $target_category_srl
|
||||
* @return Object
|
||||
*/
|
||||
function moveDocumentModule($document_srl_list, $target_module_srl, $target_category_srl)
|
||||
{
|
||||
if(empty($document_srl_list))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$obj = new stdClass;
|
||||
$obj->document_srls = implode(',', $document_srl_list);
|
||||
$obj->list_count = count($document_srl_list);
|
||||
$obj->document_list = executeQueryArray('document.getDocuments', $obj)->data;
|
||||
$obj->module_srl = $target_module_srl;
|
||||
$obj->category_srl = $target_category_srl;
|
||||
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
// call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$origin_category = array();
|
||||
$oDocumentController = getController('document');
|
||||
|
||||
foreach($obj->document_list as $document)
|
||||
{
|
||||
// if the target module is different
|
||||
if($document->module_srl != $obj->module_srl)
|
||||
{
|
||||
$oDocumentController->deleteDocumentAliasByDocument($document->document_srl);
|
||||
}
|
||||
|
||||
// if the target category is different
|
||||
if($document->category_srl != $obj->category_srl && $document->category_srl)
|
||||
{
|
||||
$origin_category[$document->category_srl] = $document->module_srl;
|
||||
}
|
||||
|
||||
$oDocumentController->insertDocumentUpdateLog($document);
|
||||
}
|
||||
|
||||
// update documents
|
||||
$output = executeQuery('document.updateDocumentsModule', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// update extra vars
|
||||
$output = executeQuery('document.updateDocumentExtraVarsModule', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// call a trigger (after)
|
||||
ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $obj);
|
||||
|
||||
// update category count
|
||||
foreach($origin_category as $category_srl => $module_srl)
|
||||
{
|
||||
$oDocumentController->updateCategoryCount($module_srl, $category_srl);
|
||||
}
|
||||
if($obj->category_srl)
|
||||
{
|
||||
$oDocumentController->updateCategoryCount($obj->module_srl, $obj->category_srl);
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
// remove from cache
|
||||
foreach ($document_srl_list as $document_srl)
|
||||
{
|
||||
Rhymix\Framework\Cache::delete('document_item:'. getNumberingPath($document_srl) . $document_srl);
|
||||
}
|
||||
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
$output = executeQuery('document.deleteTrash', $trash_args);
|
||||
if (!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
/**
|
||||
* Copy the documents
|
||||
* @param array $document_srl_list
|
||||
* @param int $target_module_srl
|
||||
* @param int $target_category_srl
|
||||
* @return object
|
||||
*/
|
||||
function copyDocumentModule($document_srl_list, $target_module_srl, $target_category_srl)
|
||||
{
|
||||
if(empty($document_srl_list))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$obj = new stdClass;
|
||||
$obj->document_srls = implode(',', $document_srl_list);
|
||||
$obj->list_count = count($document_srl_list);
|
||||
$obj->document_list = executeQueryArray('document.getDocuments', $obj)->data;
|
||||
$obj->module_srl = $target_module_srl;
|
||||
$obj->category_srl = $target_category_srl;
|
||||
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
// call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$oDocumentController = getController('document');
|
||||
$extra_vars_list = getModel('document')->getDocumentExtraVarsFromDB($document_srl_list)->data;
|
||||
|
||||
$extra_vars = array();
|
||||
foreach($extra_vars_list as $extra)
|
||||
{
|
||||
if(!isset($extra_vars[$extra->document_srl]))
|
||||
{
|
||||
$extra_vars[$extra->document_srl] = array();
|
||||
}
|
||||
|
||||
$extra_vars[$extra->document_srl][] = $extra;
|
||||
}
|
||||
|
||||
$copied_srls = array();
|
||||
foreach($obj->document_list as $document)
|
||||
{
|
||||
$copy = clone $document;
|
||||
$copy->document_srl = getNextSequence();
|
||||
$copy->module_srl = $obj->module_srl;
|
||||
$copy->category_srl = $obj->category_srl;
|
||||
$copy->comment_count = 0;
|
||||
$copy->trackback_count = 0;
|
||||
$copy->password_is_hashed = true;
|
||||
|
||||
// call a trigger (add)
|
||||
$args = new stdClass;
|
||||
$args->source = $document;
|
||||
$args->copied = $copy;
|
||||
ModuleHandler::triggerCall('document.copyDocumentModule', 'add', $args);
|
||||
|
||||
// insert a copied document
|
||||
$output = $oDocumentController->insertDocument($copy, true, true);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
// insert copied extra vars of the document
|
||||
if(isset($extra_vars[$document->document_srl]))
|
||||
{
|
||||
foreach($extra_vars[$document->document_srl] as $extra)
|
||||
{
|
||||
$oDocumentController->insertDocumentExtraVar($copy->module_srl, $copy->document_srl, $extra->var_idx, $extra->value, $extra->eid, $extra->lang_code);
|
||||
}
|
||||
}
|
||||
|
||||
$copied_srls[$document->document_srl] = $copy->document_srl;
|
||||
}
|
||||
|
||||
// call a trigger (after)
|
||||
$obj->copied_srls = $copied_srls;
|
||||
ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $obj);
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
// return copied document_srls
|
||||
$output = new BaseObject();
|
||||
$output->add('copied_srls', $copied_srls);
|
||||
return $output;
|
||||
}
|
||||
// If the post was not temorarily saved, set the attachment's status to be valid
|
||||
if($oDocument->hasUploadedFiles() && $document_args->member_srl != $document_args->module_srl) {
|
||||
$args->upload_target_srl = $oDocument->document_srl;
|
||||
$args->isvalid = 'Y';
|
||||
executeQuery('file.updateFileValid', $args);
|
||||
|
||||
/**
|
||||
* Delete all documents of the module
|
||||
* @param int $module_srl
|
||||
* @return object
|
||||
*/
|
||||
function deleteModuleDocument($module_srl)
|
||||
{
|
||||
$args = new stdClass;
|
||||
$args->page = 0;
|
||||
$args->module_srl = $module_srl;
|
||||
$document_list = executeQueryArray('document.getDocumentList', $args, array('document_srl'))->data;
|
||||
|
||||
// delete documents
|
||||
$output = executeQuery('document.deleteModuleDocument', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
// remove from cache
|
||||
foreach ($document_list as $document)
|
||||
{
|
||||
Rhymix\Framework\Cache::delete('document_item:'. getNumberingPath($document->document_srl) . $document->document_srl);
|
||||
}
|
||||
|
||||
return new BaseObject();
|
||||
}
|
||||
// call a trigger (after)
|
||||
if($output->toBool()) {
|
||||
$trigger_output = ModuleHandler::triggerCall('document.restoreTrash', 'after', $document_args);
|
||||
if(!$trigger_output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return $trigger_output;
|
||||
}
|
||||
}
|
||||
|
||||
// commit
|
||||
$oDB->commit();
|
||||
return $output;
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* Restore document from trash module, called by trash module
|
||||
* This method is passived
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ class document extends ModuleObject
|
|||
|
||||
// 2017.12.21 Add an index for nick_name
|
||||
if(!$oDB->isIndexExists('documents', 'idx_nick_name')) return true;
|
||||
|
||||
|
||||
if(!$oModuleModel->getTrigger('file.deleteFile', 'document', 'controller', 'triggerAfterDeleteFile', 'after')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -356,6 +358,11 @@ class document extends ModuleObject
|
|||
{
|
||||
$oDB->addIndex('documents', 'idx_nick_name', array('nick_name'));
|
||||
}
|
||||
|
||||
if(!$oModuleModel->getTrigger('file.deleteFile', 'document', 'controller', 'triggerAfterDeleteFile', 'after'))
|
||||
{
|
||||
$oModuleController->insertTrigger('file.deleteFile', 'document', 'controller', 'triggerAfterDeleteFile', 'after');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1049,7 +1049,10 @@ class documentController extends document
|
|||
$trash_args->module_srl = $oDocument->get('module_srl');
|
||||
$obj->module_srl = $oDocument->get('module_srl');
|
||||
// Cannot throw data from the trash to the trash
|
||||
if($trash_args->module_srl == 0) return false;
|
||||
if($trash_args->module_srl == 0)
|
||||
{
|
||||
return new BaseObject(-1, 'Cannot throw data from the trash to the trash');
|
||||
}
|
||||
// Data setting
|
||||
$trash_args->document_srl = $obj->document_srl;
|
||||
$trash_args->description = $obj->description;
|
||||
|
|
@ -2538,158 +2541,181 @@ class documentController extends document
|
|||
function procDocumentManageCheckedDocument()
|
||||
{
|
||||
@set_time_limit(0);
|
||||
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
// Get request parameters.
|
||||
$cart = Context::get('cart');
|
||||
if(!is_array($cart)) $cart = explode('|@|', $cart);
|
||||
$cart = array_unique(array_map('intval', $cart));
|
||||
$type = Context::get('type');
|
||||
$target_module_srl = intval(Context::get('module_srl') ?: Context::get('target_module'));
|
||||
$target_category_srl = Context::get('target_category');
|
||||
|
||||
// send default message - misol 2015-07-23
|
||||
$send_default_message = Context::get('send_default_message');
|
||||
if($send_default_message === 'Y')
|
||||
{
|
||||
$message_content = '';
|
||||
$default_message_verbs = lang('default_message_verbs');
|
||||
if(isset($default_message_verbs[$type]) && is_string($default_message_verbs[$type]))
|
||||
{
|
||||
$message_content = sprintf(lang('default_message_format'), $logged_info->nick_name, $default_message_verbs[$type]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message_content = Context::get('message_content');
|
||||
if($message_content) $message_content = nl2br($message_content);
|
||||
}
|
||||
|
||||
// Check permissions on all documents.
|
||||
$document_items = array();
|
||||
$document_srl_list = array();
|
||||
$module_srl_list = array();
|
||||
$oDocumentModel = getModel('document');
|
||||
foreach ($cart as $document_srl)
|
||||
{
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
$document_items[] = $oDocument;
|
||||
$document_srl_list[] = $document_srl;
|
||||
$module_srl_list[] = $oDocument->get('module_srl');
|
||||
if (!$oDocument->isGranted())
|
||||
{
|
||||
return $this->stop('msg_not_permitted');
|
||||
}
|
||||
}
|
||||
$obj = new stdClass;
|
||||
$obj->type = Context::get('type');
|
||||
$obj->document_list = array();
|
||||
$obj->document_srl_list = array();
|
||||
$obj->target_module_srl = intval(Context::get('module_srl') ?: Context::get('target_module'));
|
||||
$obj->target_category_srl = Context::get('target_category');
|
||||
$obj->manager_message = Context::get('message_content') ? nl2br(escape(strip_tags(Context::get('message_content')))) : '';
|
||||
$obj->send_message = $obj->manager_message || Context::get('send_default_message') == 'Y';
|
||||
$obj->return_message = '';
|
||||
|
||||
// Check permissions on all modules.
|
||||
$oModuleModel = getModel('module');
|
||||
if ($target_module_srl && !in_array($target_module_srl, $module_srl_list))
|
||||
// Check permission of target module
|
||||
if($obj->target_module_srl)
|
||||
{
|
||||
$module_srl_list[] = $target_module_srl;
|
||||
}
|
||||
foreach ($module_srl_list as $module_srl)
|
||||
{
|
||||
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
|
||||
$module_info = getModel('module')->getModuleInfoByModuleSrl($obj->target_module_srl);
|
||||
if (!$module_info->module_srl)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
}
|
||||
|
||||
$module_grant = $oModuleModel->getGrant($module_info, $logged_info);
|
||||
$module_grant = getModel('module')->getGrant($module_info, $logged_info);
|
||||
if (!$module_grant->manager)
|
||||
{
|
||||
return $this->setError('msg_not_permitted');
|
||||
}
|
||||
}
|
||||
|
||||
// Set a spam-filer not to be filtered to spams
|
||||
$oSpamController = getController('spamfilter');
|
||||
$oSpamController->setAvoidLog();
|
||||
|
||||
if($type == 'move')
|
||||
// Set Cart
|
||||
$cart = Context::get('cart');
|
||||
if(!is_array($cart))
|
||||
{
|
||||
if(!$target_module_srl) return $this->setError('fail_to_move');
|
||||
|
||||
$oDocumentAdminController = getAdminController('document');
|
||||
$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $target_module_srl, $target_category_srl);
|
||||
if(!$output->toBool()) return $this->setError('fail_to_move');
|
||||
|
||||
$msg_code = 'success_moved';
|
||||
|
||||
$cart = explode('|@|', $cart);
|
||||
}
|
||||
else if($type == 'copy')
|
||||
$obj->document_srl_list = array_unique(array_map('intval', $cart));
|
||||
|
||||
// Set document list
|
||||
$obj->document_list = getModel('document')->getDocuments($obj->document_srl_list, false, false);
|
||||
if(empty($obj->document_list))
|
||||
{
|
||||
if(!$target_module_srl) return $this->setError('fail_to_move');
|
||||
|
||||
$oDocumentAdminController = getAdminController('document');
|
||||
$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $target_module_srl, $target_category_srl);
|
||||
if(!$output->toBool()) return $this->setError('fail_to_move');
|
||||
|
||||
$msg_code = 'success_copied';
|
||||
return $this->setError('msg_invalid_request');
|
||||
}
|
||||
else if($type =='delete')
|
||||
|
||||
// Call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('document.manage', 'before', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
foreach ($document_srl_list as $document_srl)
|
||||
return $output;
|
||||
}
|
||||
|
||||
$oController = getAdminController('document');
|
||||
if($obj->type == 'move')
|
||||
{
|
||||
if(!$obj->target_module_srl)
|
||||
{
|
||||
return $this->setError('fail_to_move');
|
||||
}
|
||||
|
||||
$output = $oController->moveDocumentModule($obj->document_srl_list, $obj->target_module_srl, $obj->target_category_srl);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$obj->return_message = 'success_moved';
|
||||
}
|
||||
else if($obj->type == 'copy')
|
||||
{
|
||||
if(!$obj->target_module_srl)
|
||||
{
|
||||
return $this->setError('fail_to_move');
|
||||
}
|
||||
|
||||
$output = $oController->copyDocumentModule($obj->document_srl_list, $obj->target_module_srl, $obj->target_category_srl);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$obj->return_message = 'success_copied';
|
||||
}
|
||||
else if($obj->type == 'delete')
|
||||
{
|
||||
foreach ($obj->document_list as $document_srl => $oDocument)
|
||||
{
|
||||
$output = $this->deleteDocument($document_srl, true);
|
||||
if(!$output->toBool()) return $this->setError('fail_to_delete');
|
||||
if(!$output->toBool())
|
||||
{
|
||||
unset($obj->document_list[$document_srl]);
|
||||
$obj->return_message = $output->getMessage();
|
||||
}
|
||||
}
|
||||
$oDB->commit();
|
||||
$msg_code = 'success_deleted';
|
||||
|
||||
$obj->return_message = $obj->return_message ?: 'success_deleted';
|
||||
}
|
||||
else if($type == 'trash')
|
||||
else if($obj->type == 'trash')
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->description = $message_content;
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
foreach ($document_srl_list as $document_srl)
|
||||
$args = new stdClass;
|
||||
$args->description = $obj->manager_message;
|
||||
|
||||
foreach ($obj->document_list as $document_srl => $oDocument)
|
||||
{
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $this->moveDocumentToTrash($args);
|
||||
if(!$output || !$output->toBool()) return $this->setError('fail_to_trash');
|
||||
if(!$output->toBool())
|
||||
{
|
||||
unset($obj->document_list[$document_srl]);
|
||||
$obj->return_message = $output->getMessage();
|
||||
}
|
||||
}
|
||||
$oDB->commit();
|
||||
$msg_code = 'success_trashed';
|
||||
|
||||
$obj->return_message = $obj->return_message ?: 'success_trashed';
|
||||
}
|
||||
else if($type == 'cancelDeclare')
|
||||
else if($obj->type == 'cancelDeclare')
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->document_srl = $document_srl_list;
|
||||
$args = new stdClass;
|
||||
$args->document_srl = $obj->document_srl_list;
|
||||
$output = executeQuery('document.deleteDeclaredDocuments', $args);
|
||||
$msg_code = 'success_declare_canceled';
|
||||
}
|
||||
|
||||
// Send a message
|
||||
if($message_content)
|
||||
{
|
||||
$oCommunicationController = getController('communication');
|
||||
$title = cut_str($message_content,10,'...');
|
||||
$sender_member_srl = $logged_info->member_srl;
|
||||
|
||||
foreach($document_items as $oDocument)
|
||||
if(!$output->toBool())
|
||||
{
|
||||
if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
|
||||
|
||||
if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\" style=\"padding:10px 0;\">%s</a><hr />", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
|
||||
else $purl = "";
|
||||
$content = sprintf("<div style=\"padding:10px 0;\"><p>%s</p></div><hr />%s<div style=\"padding:10px 0;font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false));
|
||||
|
||||
$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
|
||||
return $output;
|
||||
}
|
||||
|
||||
$obj->return_message = 'success_declare_canceled';
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
}
|
||||
|
||||
// Call a trigger (after)
|
||||
ModuleHandler::triggerCall('document.manage', 'after', $obj);
|
||||
|
||||
// Send a message
|
||||
$actions = lang('default_message_verbs');
|
||||
if(isset($actions[$obj->type]) && $obj->send_message)
|
||||
{
|
||||
// Set message
|
||||
$title = sprintf(lang('default_message_format'), $actions[$obj->type]);
|
||||
$content = <<< Content
|
||||
<div style="padding:10px 0;"><strong>{$title}</strong></div>
|
||||
<p>{$obj->manager_message}</p>
|
||||
<hr>
|
||||
<ul>%1\$s</ul>
|
||||
Content;
|
||||
$document_item = '<li><a href="%1$s">%2$s</a></li>';
|
||||
|
||||
// Set recipient
|
||||
$recipients = array();
|
||||
foreach ($obj->document_list as $document_srl => $oDocument)
|
||||
{
|
||||
if(!($member_srl = abs($oDocument->get('member_srl'))) || $logged_info->member_srl == $member_srl)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!isset($recipients[$member_srl]))
|
||||
{
|
||||
$recipients[$member_srl] = array();
|
||||
}
|
||||
|
||||
$recipients[$member_srl][] = sprintf($document_item, $oDocument->getPermanentUrl(), $oDocument->getTitleText());
|
||||
}
|
||||
|
||||
// Send
|
||||
$oCommunicationController = getController('communication');
|
||||
foreach ($recipients as $member_srl => $items)
|
||||
{
|
||||
$oCommunicationController->sendMessage($member_srl, $member_srl, $title, sprintf($content, implode('', $items)), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$_SESSION['document_management'] = array();
|
||||
|
||||
$this->setMessage($msg_code);
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
|
||||
$this->setMessage($obj->return_message);
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2869,26 +2895,47 @@ class documentController extends document
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateUploaedCount($documentSrlList)
|
||||
|
||||
public function updateUploaedCount($document_srl_list)
|
||||
{
|
||||
$oDocumentModel = getModel('document');
|
||||
$oFileModel = getModel('file');
|
||||
|
||||
if(is_array($documentSrlList))
|
||||
if(!is_array($document_srl_list))
|
||||
{
|
||||
$documentSrlList = array_unique($documentSrlList);
|
||||
foreach($documentSrlList AS $key => $documentSrl)
|
||||
$document_srl_list = array($document_srl_list);
|
||||
}
|
||||
|
||||
if(empty($document_srl_list))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$oFileModel = getModel('file');
|
||||
$document_srl_list = array_unique($document_srl_list);
|
||||
|
||||
foreach($document_srl_list as $document_srl)
|
||||
{
|
||||
if(!$document_srl = (int) $document_srl)
|
||||
{
|
||||
$fileCount = $oFileModel->getFilesCount($documentSrl);
|
||||
$args = new stdClass();
|
||||
$args->document_srl = $documentSrl;
|
||||
$args->uploaded_count = $fileCount;
|
||||
executeQuery('document.updateUploadedCount', $args);
|
||||
continue;
|
||||
}
|
||||
|
||||
$args = new stdClass;
|
||||
$args->document_srl = $document_srl;
|
||||
$args->uploaded_count = $oFileModel->getFilesCount($document_srl);
|
||||
executeQuery('document.updateUploadedCount', $args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function triggerAfterDeleteFile($file)
|
||||
{
|
||||
$oDocument = getModel('document')->getDocument($file->upload_target_srl, false, false);
|
||||
if(!$oDocument->isExists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateUploaedCount($file->upload_target_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy extra keys when module copied
|
||||
* @param object $obj
|
||||
|
|
|
|||
|
|
@ -29,25 +29,19 @@ class documentModel extends document
|
|||
{
|
||||
return $_SESSION['granted_document'][$document_srl];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return document extra information from database
|
||||
* @param array $documentSrls
|
||||
* @param array $document_srls
|
||||
* @return object
|
||||
*/
|
||||
function getDocumentExtraVarsFromDB($documentSrls)
|
||||
function getDocumentExtraVarsFromDB($document_srls)
|
||||
{
|
||||
if(!is_array($documentSrls) || count($documentSrls) == 0)
|
||||
{
|
||||
return $this->setError('msg_invalid_request');
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
$args->document_srl = $documentSrls;
|
||||
$output = executeQueryArray('document.getDocumentExtraVars', $args);
|
||||
return $output;
|
||||
$args = new stdClass;
|
||||
$args->document_srl = $document_srls;
|
||||
return executeQueryArray('document.getDocumentExtraVars', $args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extra variables for each article will not be processed bulk select and apply the macro city
|
||||
* @return void
|
||||
|
|
@ -167,57 +161,42 @@ class documentModel extends document
|
|||
* @param array $columnList
|
||||
* @return array value type is documentItem
|
||||
*/
|
||||
function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array())
|
||||
function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array())
|
||||
{
|
||||
if(is_array($document_srls))
|
||||
{
|
||||
$list_count = count($document_srls);
|
||||
$document_srls = implode(',',$document_srls);
|
||||
}
|
||||
else
|
||||
{
|
||||
$list_count = 1;
|
||||
}
|
||||
$args = new stdClass();
|
||||
$args->document_srls = $document_srls;
|
||||
$args->list_count = $list_count;
|
||||
$args->list_count = is_array($document_srls) ? count($document_srls) : 1;
|
||||
$args->order_type = 'asc';
|
||||
|
||||
$output = executeQuery('document.getDocuments', $args, $columnList);
|
||||
$document_list = $output->data;
|
||||
if(!$document_list) return;
|
||||
if(!is_array($document_list)) $document_list = array($document_list);
|
||||
|
||||
$document_count = count($document_list);
|
||||
foreach($document_list as $key => $attribute)
|
||||
$output = executeQueryArray('document.getDocuments', $args, $columnList);
|
||||
|
||||
$documents = array();
|
||||
foreach($output->data as $key => $attribute)
|
||||
{
|
||||
$document_srl = $attribute->document_srl;
|
||||
if(!$document_srl) continue;
|
||||
|
||||
if(!$document_srl = $attribute->document_srl)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
|
||||
{
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute, false);
|
||||
if($is_admin) $oDocument->setGrant();
|
||||
if($is_admin)
|
||||
{
|
||||
$oDocument->setGrant();
|
||||
}
|
||||
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
|
||||
}
|
||||
|
||||
$result[$attribute->document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
|
||||
$documents[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
}
|
||||
|
||||
if($load_extra_vars) $this->setToAllDocumentExtraVars();
|
||||
|
||||
$output = null;
|
||||
if(count($result))
|
||||
|
||||
if($load_extra_vars)
|
||||
{
|
||||
foreach($result as $document_srl => $val)
|
||||
{
|
||||
$output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
|
||||
}
|
||||
$this->setToAllDocumentExtraVars();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
return $documents;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ $lang->select_category = 'Select a category.';
|
|||
$lang->category_description = 'Category Description';
|
||||
$lang->no_title_document = 'No title in this document.';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
$lang->default_message_format = '%1$s the document by manager.';
|
||||
$lang->default_message_verbs['move'] = 'moved';
|
||||
$lang->default_message_verbs['copy'] = 'copied';
|
||||
$lang->default_message_verbs['delete'] = 'deleted';
|
||||
$lang->default_message_verbs['trash'] = 'deleted';
|
||||
$lang->improper_document_declare = 'Report an improper document';
|
||||
$lang->original_date = 'Original date';
|
||||
$lang->declared_count = 'Report count';
|
||||
|
|
|
|||
|
|
@ -81,9 +81,3 @@ $lang->select_module_id = 'モジュールIDを選択してください。';
|
|||
$lang->select_category = 'カテゴリを選択してください。';
|
||||
$lang->category_description = 'カテゴリー説明';
|
||||
$lang->no_title_document = 'タイトルがないドキュメントです。';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
|
|
|
|||
|
|
@ -84,10 +84,10 @@ $lang->select_category = '분류를 선택하세요.';
|
|||
$lang->category_description = '카테고리 설명';
|
||||
$lang->no_title_document = '제목이 없는 문서입니다.';
|
||||
$lang->msg_admin_document_no_move_to_trash = '최고관리자의 게시물을 휴지통으로 이동시킬 권한이 없습니다.';
|
||||
$lang->send_default_message = '기본 쪽지 내용으로 보내기';
|
||||
$lang->default_message_format = '%1$s님께서 다음 게시물을 %2$s 합니다.';
|
||||
$lang->default_message_verbs['move'] = '이동';
|
||||
$lang->default_message_verbs['copy'] = '복사';
|
||||
$lang->send_default_message = '기본 내용으로만 쪽지 보내기';
|
||||
$lang->default_message_format = '관리자에 의해 게시물이 %1$s되었습니다.';
|
||||
$lang->default_message_verbs['move'] = '다른 게시판으로 이동';
|
||||
$lang->default_message_verbs['copy'] = '다른 게시판에 복사';
|
||||
$lang->default_message_verbs['delete'] = '삭제';
|
||||
$lang->default_message_verbs['trash'] = '삭제';
|
||||
$lang->improper_document_declare = '불량 게시글 신고';
|
||||
|
|
|
|||
|
|
@ -59,9 +59,3 @@ $lang->search_target_trash_list['trash_member_srl'] = 'Номер удалите
|
|||
$lang->search_target_trash_list['trash_user_name'] = 'Имя удалителя';
|
||||
$lang->search_target_trash_list['trash_date'] = 'Дата удаления';
|
||||
$lang->search_target_trash_list['trash_ipaddress'] = 'IP адрес удалителя';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
|
|
|
|||
|
|
@ -66,9 +66,3 @@ $lang->search_target_trash_list['trash_date'] = 'Silinme Tarihi';
|
|||
$lang->search_target_trash_list['trash_ipaddress'] = 'Silici IP adresi';
|
||||
$lang->success_trashed = 'Başarıyla silindi';
|
||||
$lang->msg_not_selected_document = 'Hiçbir makale seçilmedi.';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
|
|
|
|||
|
|
@ -63,9 +63,3 @@ $lang->search_target_trash_list['trash_user_name'] = 'Tên người xóa';
|
|||
$lang->search_target_trash_list['trash_date'] = 'Ngày xóa';
|
||||
$lang->search_target_trash_list['trash_ipaddress'] = 'IP Người xóa';
|
||||
$lang->success_trashed = 'Đã chuyển tới thùng rác thành công.';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
|
|
|
|||
|
|
@ -65,9 +65,3 @@ $lang->search_target_trash_list['trash_user_name'] = '操作人用户名';
|
|||
$lang->search_target_trash_list['trash_date'] = '删除日期';
|
||||
$lang->search_target_trash_list['trash_ipaddress'] = '操作人IP地址';
|
||||
$lang->success_trashed = '已成功移除到回收箱。';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
|
|
|
|||
|
|
@ -80,9 +80,3 @@ $lang->select_module_id = '選擇模組 ID.';
|
|||
$lang->select_category = '選擇分類';
|
||||
$lang->category_description = '分類說明';
|
||||
$lang->no_title_document = '此文章無標題。';
|
||||
$lang->send_default_message = 'Send the default message';
|
||||
$lang->default_message_format = '%1$s %2$s the document below.';
|
||||
$lang->default_message_verbs['move'] = 'moves';
|
||||
$lang->default_message_verbs['copy'] = 'copies';
|
||||
$lang->default_message_verbs['delete'] = 'deletes';
|
||||
$lang->default_message_verbs['trash'] = 'deletes';
|
||||
|
|
|
|||
11
modules/document/queries/updateDocumentExtraVarsModule.xml
Normal file
11
modules/document/queries/updateDocumentExtraVarsModule.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="updateDocumentExtraVarsModule" action="update">
|
||||
<tables>
|
||||
<table name="document_extra_vars" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="module_srl" var="module_srl" filter="number" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="document_srl" var="document_srls" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
12
modules/document/queries/updateDocumentsModule.xml
Normal file
12
modules/document/queries/updateDocumentsModule.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<query id="updateDocumentsModule" action="update">
|
||||
<tables>
|
||||
<table name="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="module_srl" var="module_srl" filter="number" default="0" />
|
||||
<column name="category_srl" var="category_srl" filter="number" default="0" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="document_srl" var="document_srls" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -15,42 +15,12 @@ class fileAdminController extends file
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the attachment of a particular module
|
||||
*
|
||||
* @param int $module_srl Sequence of module to delete files
|
||||
* @deprecated move to fileController
|
||||
* @return Object
|
||||
*/
|
||||
function deleteModuleFiles($module_srl)
|
||||
{
|
||||
// Get a full list of attachments
|
||||
$args = new stdClass();
|
||||
$args->module_srl = $module_srl;
|
||||
$columnList = array('file_srl', 'uploaded_filename');
|
||||
$output = executeQueryArray('file.getModuleFiles',$args, $columnList);
|
||||
if(!$output) return $output;
|
||||
$files = $output->data;
|
||||
// Remove from the DB
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('file.deleteModuleFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
// Remove the file
|
||||
FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ;
|
||||
FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) );
|
||||
// Remove the file list obtained from the DB
|
||||
$path = array();
|
||||
$cnt = count($files);
|
||||
for($i=0;$i<$cnt;$i++)
|
||||
{
|
||||
$uploaded_filename = $files[$i]->uploaded_filename;
|
||||
FileHandler::removeFile($uploaded_filename);
|
||||
|
||||
$path_info = pathinfo($uploaded_filename);
|
||||
if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
|
||||
}
|
||||
// Remove a file directory of the document
|
||||
for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]);
|
||||
|
||||
return $output;
|
||||
return getController('file')->deleteModuleFiles($module_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -77,7 +77,20 @@ class file extends ModuleObject
|
|||
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after')) return true;
|
||||
|
||||
if(!$oDB->isColumnExists('files', 'cover_image')) return true;
|
||||
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'file', 'controller', 'triggerMoveDocument', 'after'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('document.copyDocumentModule', 'file', 'controller', 'triggerAddCopyDocument', 'add'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('comment.copyCommentByDocument', 'file', 'controller', 'triggerAddCopyCommentByDocument', 'add'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +153,19 @@ class file extends ModuleObject
|
|||
}
|
||||
|
||||
if(!$oDB->isColumnExists('files', 'cover_image')) $oDB->addColumn('files', 'cover_image', 'char', '1', 'N');
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'file', 'controller', 'triggerMoveDocument', 'after'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.moveDocumentModule', 'file', 'controller', 'triggerMoveDocument', 'after');
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('document.copyDocumentModule', 'file', 'controller', 'triggerAddCopyDocument', 'add'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.copyDocumentModule', 'file', 'controller', 'triggerAddCopyDocument', 'add');
|
||||
}
|
||||
if(!$oModuleModel->getTrigger('comment.copyCommentByDocument', 'file', 'controller', 'triggerAddCopyCommentByDocument', 'add'))
|
||||
{
|
||||
$oModuleController->insertTrigger('comment.copyCommentByDocument', 'file', 'controller', 'triggerAddCopyCommentByDocument', 'add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -694,9 +694,8 @@ class fileController extends file
|
|||
{
|
||||
$module_srl = $obj->module_srl;
|
||||
if(!$module_srl) return;
|
||||
|
||||
$oFileController = getAdminController('file');
|
||||
return $oFileController->deleteModuleFiles($module_srl);
|
||||
|
||||
return $this->deleteModuleFiles($module_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -950,70 +949,58 @@ class fileController extends file
|
|||
* - ipaddress
|
||||
* </pre>
|
||||
*
|
||||
* @param int $file_srl Sequence of file to delete
|
||||
* @param array|int $file_list or $file_srl
|
||||
* @return Object
|
||||
*/
|
||||
function deleteFile($file_srl)
|
||||
function deleteFile($file_list)
|
||||
{
|
||||
if(!$file_srl) return;
|
||||
|
||||
$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
|
||||
if(!count($srls)) return;
|
||||
|
||||
$oDocumentController = getController('document');
|
||||
$documentSrlList = array();
|
||||
|
||||
foreach($srls as $srl)
|
||||
if(!is_array($file_list))
|
||||
{
|
||||
$srl = (int)$srl;
|
||||
if(!$srl)
|
||||
$file_list = explode(',', $file_list);
|
||||
}
|
||||
|
||||
if(empty($file_list))
|
||||
{
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
foreach($file_list as $file)
|
||||
{
|
||||
if(!is_object($file))
|
||||
{
|
||||
if(!$file_srl = (int) $file)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$file = getModel('file')->getFile($file_srl);
|
||||
}
|
||||
|
||||
if(empty($file->file_srl))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
$args->file_srl = $srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
|
||||
if(!$output->toBool() || !$output->data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$file_info = $output->data;
|
||||
|
||||
if($file_info->upload_target_srl)
|
||||
{
|
||||
$documentSrlList[] = $file_info->upload_target_srl;
|
||||
}
|
||||
|
||||
$source_filename = $output->data->source_filename;
|
||||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
|
||||
|
||||
// Call a trigger (before)
|
||||
$trigger_obj = $output->data;
|
||||
$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
|
||||
$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $file);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
|
||||
// Remove from the DB
|
||||
$output = executeQuery('file.deleteFile', $args);
|
||||
$output = executeQuery('file.deleteFile', $file);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
|
||||
// If successfully deleted, remove the file
|
||||
Rhymix\Framework\Storage::delete(FileHandler::getRealPath($uploaded_filename));
|
||||
|
||||
Rhymix\Framework\Storage::delete(FileHandler::getRealPath($file->uploaded_filename));
|
||||
|
||||
// Call a trigger (after)
|
||||
ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
|
||||
ModuleHandler::triggerCall('file.deleteFile', 'after', $file);
|
||||
|
||||
// Remove empty directories
|
||||
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($uploaded_filename)), true);
|
||||
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->uploaded_filename)), true);
|
||||
}
|
||||
|
||||
$oDocumentController->updateUploaedCount($documentSrlList);
|
||||
|
||||
return $output;
|
||||
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all attachments of a particular document
|
||||
*
|
||||
|
|
@ -1024,26 +1011,39 @@ class fileController extends file
|
|||
{
|
||||
// Get a list of attachements
|
||||
$oFileModel = getModel('file');
|
||||
$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
|
||||
$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
|
||||
$file_list = $oFileModel->getFiles($upload_target_srl);
|
||||
|
||||
// Success returned if no attachement exists
|
||||
if(!is_array($file_list)||!count($file_list)) return new BaseObject();
|
||||
|
||||
// Delete the file
|
||||
foreach ($file_list as $file)
|
||||
if(empty($file_list))
|
||||
{
|
||||
$this->deleteFile($file->file_srl);
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
// Remove from the DB
|
||||
$args = new stdClass();
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
$output = executeQuery('file.deleteFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
return $output;
|
||||
|
||||
// Delete the file
|
||||
return $this->deleteFile($file_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete the attachment of a particular module
|
||||
*
|
||||
* @param int $module_srl Sequence of module to delete files
|
||||
* @return Object
|
||||
*/
|
||||
function deleteModuleFiles($module_srl)
|
||||
{
|
||||
// Get a full list of attachments
|
||||
$args = new stdClass;
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQueryArray('file.getModuleFiles', $args);
|
||||
if(!$output->toBool() || empty($file_list = $output->data))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Delete the file
|
||||
return $this->deleteFile($file_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move an attachement to the other document
|
||||
*
|
||||
|
|
@ -1095,7 +1095,47 @@ class fileController extends file
|
|||
executeQuery('file.updateFile', $args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function copyFile($source_file, $module_srl, $upload_target_srl, &$content = null)
|
||||
{
|
||||
$file_info = array();
|
||||
$file_info['name'] = $source_file->source_filename;
|
||||
$file_info['tmp_name'] = $source_file->uploaded_filename;
|
||||
$copied_file = $this->insertFile($file_info, $module_srl, $upload_target_srl, 0, true);
|
||||
|
||||
if($content)
|
||||
{
|
||||
// if image/video files
|
||||
if($source_file->direct_download == 'Y')
|
||||
{
|
||||
$source_filename = substr($source_file->uploaded_filename, 2);
|
||||
$copied_filename = substr($copied_file->get('uploaded_filename'), 2);
|
||||
$content = str_replace($source_filename, $copied_filename, $content);
|
||||
}
|
||||
// if binary file
|
||||
else
|
||||
{
|
||||
$content = str_replace('file_srl=' . $source_file->file_srl, 'file_srl=' . $copied_file->get('file_srl'), $content);
|
||||
$content = str_replace('sid=' . $source_file->sid, 'sid=' . $copied_file->get('sid'), $content);
|
||||
}
|
||||
}
|
||||
|
||||
return $copied_file;
|
||||
}
|
||||
|
||||
function copyFiles($source_file_list, $module_srl, $upload_target_srl, &$content = null)
|
||||
{
|
||||
if(!is_array($source_file_list))
|
||||
{
|
||||
$source_file_list = getModel('file')->getFiles($source_file_list, array(), 'file_srl', true);
|
||||
}
|
||||
|
||||
foreach($source_file_list as $source_file)
|
||||
{
|
||||
$this->copyFile($source_file, $module_srl, $upload_target_srl, $content);
|
||||
}
|
||||
}
|
||||
|
||||
public function procFileSetCoverImage()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
|
@ -1123,8 +1163,8 @@ class fileController extends file
|
|||
$output = executeQuery('file.updateClearCoverImage', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
if($file_info->cover_image != 'Y')
|
||||
|
|
@ -1161,7 +1201,34 @@ class fileController extends file
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function triggerMoveDocument($obj)
|
||||
{
|
||||
$obj->upload_target_srls = $obj->document_srls;
|
||||
executeQuery('file.updateFileModule', $obj);
|
||||
executeQuery('file.updateFileModuleComment', $obj);
|
||||
}
|
||||
|
||||
function triggerAddCopyDocument(&$obj)
|
||||
{
|
||||
if(!$obj->source->uploaded_count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->copyFiles($obj->source->document_srl, $obj->copied->module_srl, $obj->copied->document_srl, $obj->copied->content);
|
||||
}
|
||||
|
||||
function triggerAddCopyCommentByDocument(&$obj)
|
||||
{
|
||||
if(!$obj->source->uploaded_count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->copyFiles($obj->source->comment_srl, $obj->copied->module_srl, $obj->copied->comment_srl, $obj->copied->content);
|
||||
}
|
||||
|
||||
function triggerCopyModule(&$obj)
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
<column name="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="in" column="upload_target_srl" var="upload_target_srls" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
13
modules/file/queries/updateFileModuleComment.xml
Normal file
13
modules/file/queries/updateFileModuleComment.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<query id="updateFileModuleComment" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
<table name="comments" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="files.module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="files.upload_target_srl" default="comments.comment_srl" />
|
||||
<condition operation="in" column="comments.document_srl" var="upload_target_srls" filter="number" notnull="notnull" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -49,7 +49,12 @@ class spamfilter extends ModuleObject
|
|||
if(!$oDB->isColumnExists('spamfilter_denied_word', 'latest_hit')) return true;
|
||||
|
||||
if(!$oDB->isColumnExists('spamfilter_denied_ip', 'description')) return true;
|
||||
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.manage', 'spamfilter', 'controller', 'triggerManageDocument', 'before'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -102,6 +107,11 @@ class spamfilter extends ModuleObject
|
|||
{
|
||||
$oDB->addColumn('spamfilter_denied_ip','description','varchar', 250);
|
||||
}
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.manage', 'spamfilter', 'controller', 'triggerManageDocument', 'before'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.manage', 'spamfilter', 'controller', 'triggerManageDocument', 'before');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -224,7 +224,15 @@ class spamfilterController extends spamfilter
|
|||
// Save a log
|
||||
$this->insertLog();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief while document manager is running, stop filter
|
||||
*/
|
||||
function triggerManageDocument(&$obj)
|
||||
{
|
||||
$this->setAvoidLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Log registration
|
||||
* Register the newly accessed IP address in the log. In case the log interval is withing a certain time,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class tag extends ModuleObject
|
|||
if(!$oModuleModel->getTrigger('module.deleteModule', 'tag', 'controller', 'triggerDeleteModuleTags', 'after')) return true;
|
||||
// tag in the index column of the table tag
|
||||
if(!$oDB->isIndexExists("tags","idx_tag")) return true;
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'tag', 'controller', 'triggerMoveDocument', 'after')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -76,6 +77,11 @@ class tag extends ModuleObject
|
|||
// tag in the index column of the table tag
|
||||
if(!$oDB->isIndexExists("tags","idx_tag"))
|
||||
$oDB->addIndex("tags","idx_tag", array("document_srl","tag"));
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'tag', 'controller', 'triggerMoveDocument', 'after'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.moveDocumentModule', 'tag', 'controller', 'triggerMoveDocument', 'after');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ class tagController extends tag
|
|||
$oTagController = getAdminController('tag');
|
||||
return $oTagController->deleteModuleTags($module_srl);
|
||||
}
|
||||
|
||||
function triggerMoveDocument($obj)
|
||||
{
|
||||
executeQuery('tag.updateTagModule', $obj);
|
||||
}
|
||||
}
|
||||
/* End of file tag.controller.php */
|
||||
/* Location: ./modules/tag/tag.controller.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue