Merge branch 'develop' into pr/multidomain

This commit is contained in:
Kijin Sung 2017-03-08 20:12:15 +09:00
commit 2e5ffa7dea
8 changed files with 238 additions and 9 deletions

View file

@ -3,7 +3,7 @@
/**
* RX_VERSION is the version number of the Rhymix CMS.
*/
define('RX_VERSION', '1.8.33');
define('RX_VERSION', '1.8.34');
/**
* RX_MICROTIME is the startup time of the current script, in microseconds since the Unix epoch.

View file

@ -527,9 +527,15 @@ class boardController extends board
// generate comment controller object
$oCommentController = getController('comment');
$updateComment = false;
if($this->module_info->comment_delete_message === 'yes' && $instant_delete != 'Y')
{
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
$updateComment = true;
if($this->module_info->trash_use == 'Y')
{
$output = $oCommentController->moveCommentToTrash($comment, $updateComment);
}
}
elseif(starts_with('only_comm', $this->module_info->comment_delete_message) && $instant_delete != 'Y')
{
@ -537,22 +543,41 @@ class boardController extends board
if(count($childs) > 0)
{
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
$updateComment = true;
if($this->module_info->trash_use == 'Y')
{
$output = $oCommentController->moveCommentToTrash($comment, $updateComment);
}
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager, FALSE, $childs);
if(!$output->toBool())
if($this->module_info->trash_use == 'Y')
{
return $output;
$output = $oCommentController->moveCommentToTrash($comment, $updateComment);
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager, FALSE, $childs);
if(!$output->toBool())
{
return $output;
}
}
}
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
if(!$output->toBool())
if($this->module_info->trash_use == 'Y')
{
return $output;
$output = $oCommentController->moveCommentToTrash($comment, $this->module_info->comment_delete_message);
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
if(!$output->toBool())
{
return $output;
}
}
}

View file

@ -467,7 +467,18 @@ class commentAdminController extends comment
$obj->module_srl = $originObject->module_srl;
$oCommentController = getController('comment');
$output = $oCommentController->insertComment($obj, true);
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($originObject->comment_srl);
if($oComment->isExists())
{
$output = $oCommentController->updateCommentByRestore($obj);
}
else
{
$output = $oCommentController->insertComment($obj, true);
}
return $output;
}

View file

@ -990,6 +990,50 @@ class commentController extends comment
return $output;
}
function updateCommentByRestore($obj)
{
if (!$obj->comment_srl)
{
return new Object(-1, 'msg_invalid_request');
}
// begin transaction
$oDB = DB::getInstance();
$oDB->begin();
$obj->status = RX_STATUS_PUBLIC;
// use to query default
unset($obj->last_update);
$output = executeQuery('comment.updateCommentByRestore', $obj);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
// update the number of comments
$oCommentModel = getModel('comment');
$comment_count = $oCommentModel->getCommentCount($obj->document_srl);
// only document is exists
if(isset($comment_count))
{
// create the controller object of the document
$oDocumentController = getController('document');
// update comment count of the article posting
$output = $oDocumentController->updateCommentCount($obj->document_srl, $comment_count, NULL, FALSE);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
}
$oDB->commit();
return $output;
}
/**
* Delete comment
* @param int $comment_srl
@ -1153,6 +1197,123 @@ class commentController extends comment
return $output;
}
/**
* Comment move to trash
* @param $obj
* @return object
*/
function moveCommentToTrash($obj, $updateComment = false)
{
$logged_info = Context::get('logged_info');
$trash_args = new stdClass();
if(!$obj->trash_srl)
{
$trash_args->trash_srl = getNextSequence();
}
else
{
$trash_args->trash_srl = $obj->trash_srl;
}
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($obj->comment_srl);
$oMemberModel = getModel('member');
$member_info = $oMemberModel->getMemberInfoByMemberSrl($oComment->get('member_srl'));
if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y')
{
return new Object(-1, 'msg_admin_comment_no_move_to_trash');
}
$trash_args->module_srl = $oComment->variables['module_srl'];
$obj->module_srl = $oComment->variables['module_srl'];
if($trash_args->module_srl === 0)
{
return new Object(-1, 'msg_module_srl_not_exists');
}
$trash_args->document_srl = $obj->document_srl;
$trash_args->comment_srl = $obj->comment_srl;
$trash_args->description = $obj->description;
if(!Context::get('is_logged'))
{
$trash_args->member_Srl = $logged_info->member_srl;
$trash_args->user_id = htmlspecialchars_decode($logged_info->user_id);
$trash_args->user_name = htmlspecialchars_decode($logged_info->user_name);
$trash_args->nick_name = htmlspecialchars_decode($logged_info->nick_name);
}
$oDB = &DB::getInstance();
$oDB->begin();
require_once(RX_BASEDIR.'modules/trash/model/TrashVO.php');
$oTrashVO = new TrashVO();
$oTrashVO->setTrashSrl(getNextSequence());
$oTrashVO->setTitle(trim(strip_tags($obj->variables['content'])));
$oTrashVO->setOriginModule('comment');
$oTrashVO->setSerializedObject(serialize($obj->variables));
$oTrashVO->setDescription($obj->description);
$oTrashAdminController = getAdminController('trash');
$output = $oTrashAdminController->insertTrash($oTrashVO);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
if($updateComment !== true)
{
$output = executeQuery('comment.deleteComment', $trash_args);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
}
$args = new stdClass();
$args->comment_srl = $obj->comment_srl;
$output = executeQuery('comment.deleteCommentList', $args);
// update the number of comments
$comment_count = $oCommentModel->getCommentCount($obj->document_srl);
// only document is exists
if(isset($comment_count))
{
// create the controller object of the document
$oDocumentController = getController('document');
// update comment count of the article posting
$output = $oDocumentController->updateCommentCount($obj->document_srl, $comment_count, NULL, FALSE);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
}
if($oComment->hasUploadedFiles())
{
$args = new stdClass();
$args->upload_target_srl = $oComment->comment_srl;
$args->isvalid = 'N';
executeQuery('file.updateFileValid', $args);
}
ModuleHandler::triggerCall('comment.moveCommentToTrash', 'after', $obj);
$oDB->commit();
Rhymix\Framework\Storage::deleteEmptyDirectory(RX_BASEDIR . sprintf('files/thumbnails/%s', getNumberingPath($comment_srl, 3)), true);
$output->add('document_srl', $obj->document_srl);
return $output;
}
/**
* Remove all comment relation log
* @return Object

View file

@ -55,3 +55,5 @@ $lang->msg_deleted_comment = '삭제된 댓글입니다.';
$lang->msg_admin_deleted_comment = '관리자가 삭제한 댓글입니다.';
$lang->msg_no_text_comment = '글자가 없는 댓글입니다.';
$lang->msg_comment_notify_mail = '[%s] 새로운 댓글이 등록되었습니다 : %s';
$lang->msg_admin_comment_no_move_to_trash = '최고관리자의 댓글을 휴지통으로 이동시킬 권한이 없습니다.';
$lang->msg_module_srl_not_exists = '모듈 번호가 존재하지 않습니다.';

View file

@ -0,0 +1,14 @@
<query id="updateCommentByRestore" action="update">
<tables>
<table name="comments" />
</tables>
<columns>
<column name="member_srl" var="member_srl" />
<column name="content" var="content" notnull="notnull" />
<column name="last_update" var="last_update" default="curdate()" />
<column name="status" var="status" default="1" />
</columns>
<conditions>
<condition operation="equal" column="comment_srl" var="comment_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -2,6 +2,7 @@
<module>
<grants />
<permissions>
<permission action="procFileGetList" target="manager" />
<permission action="procFileAdminInsertModuleConfig" target="manager" />
</permissions>
<actions>

View file

@ -170,7 +170,16 @@ class fileController extends file
if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
// Delete and then attempt to re-upload if file_srl is requested
$file_srl = Context::get('file_srl');
if($file_srl) $this->deleteFile($file_srl);
if($file_srl)
{
$oFileModel = getModel('file');
$logged_info = Context::get('logged_info');
$file_info = $oFileModel->getFile($file_srl);
if($file_info->file_srl == $file_srl && $oFileModel->getFileGrant($file_info, $logged_info)->is_deletable)
{
$this->deleteFile($file_srl);
}
}
$file_info = Context::get('Filedata');
// An error appears if not a normally uploaded file
@ -546,6 +555,12 @@ class fileController extends file
function procFileGetList()
{
if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
$logged_info = Context::get('logged_info');
if($logged_info->is_admin !== 'Y' && !getModel('module')->isSiteAdmin($logged_info))
{
return new Object(-1,'msg_not_permitted');
}
$fileSrls = Context::get('file_srls');
if($fileSrls) $fileSrlList = explode(',', $fileSrls);