mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-04 19:12:12 +09:00
issue 225 all comment remove when removed comment of parent.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.1@10968 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
578008f085
commit
ebe22cafa2
3 changed files with 68 additions and 6 deletions
|
|
@ -545,16 +545,55 @@
|
|||
$oCommentModel = &getModel('comment');
|
||||
// check if comment already exists
|
||||
$comment = $oCommentModel->getComment($comment_srl);
|
||||
if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request');
|
||||
if($comment->comment_srl != $comment_srl)
|
||||
{
|
||||
return new Object(-1, 'msg_invalid_request');
|
||||
}
|
||||
$document_srl = $comment->document_srl;
|
||||
// call a trigger (before)
|
||||
$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
|
||||
if(!$output->toBool()) return $output;
|
||||
// check if child comment exists on the comment
|
||||
$child_count = $oCommentModel->getChildCommentCount($comment_srl);
|
||||
if($child_count>0) return new Object(-1, 'fail_to_delete_have_children');
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
// check if permission is granted
|
||||
if(!$is_admin && !$comment->isGranted()) return new Object(-1, 'msg_not_permitted');
|
||||
if(!$is_admin && !$comment->isGranted())
|
||||
{
|
||||
return new Object(-1, 'msg_not_permitted');
|
||||
}
|
||||
|
||||
// check if child comment exists on the comment
|
||||
$childs = $oCommentModel->getChildComments($comment_srl);
|
||||
if(count($childs) > 0)
|
||||
{
|
||||
$deleteAllComment = true;
|
||||
if (!$is_admin)
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
foreach($childs as $val)
|
||||
{
|
||||
if($val->member_srl != $logged_info->member_srl)
|
||||
{
|
||||
$deleteAllComment = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$deleteAllComment)
|
||||
{
|
||||
return new Object(-1, 'fail_to_delete_have_children');
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($childs as $val)
|
||||
{
|
||||
$output = $this->deleteComment($val->comment_srl, $is_admin, $isMoveToTrash);
|
||||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// begin transaction
|
||||
$oDB = &DB::getInstance();
|
||||
|
|
|
|||
|
|
@ -107,6 +107,17 @@
|
|||
return (int)$output->data->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of child comments
|
||||
* @param int $comment_srl
|
||||
* @return int
|
||||
*/
|
||||
function getChildComments($comment_srl) {
|
||||
$args->comment_srl = $comment_srl;
|
||||
$output = executeQueryArray('comment.getChildComments', $args);
|
||||
return $output->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comment
|
||||
* @param int $comment_srl
|
||||
|
|
|
|||
12
modules/comment/queries/getChildComments.xml
Normal file
12
modules/comment/queries/getChildComments.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<query id="getChildComments" action="select">
|
||||
<tables>
|
||||
<table name="comments" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="comment_srl" />
|
||||
<column name="member_srl" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="parent_srl" var="comment_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue