Merge pull request #173 from misol/improvement/charge-with-something

신고/계정 거부에 이유를 적을 수 있게 하는 PR
This commit is contained in:
MinSoo Kim 2016-01-29 10:26:47 +09:00
commit 6b263844ad
38 changed files with 887 additions and 138 deletions

View file

@ -205,7 +205,19 @@ class commentController extends comment
return new Object(-1, 'msg_invalid_request');
}
return $this->declaredComment($comment_srl);
// if an user select message from options, message would be the option.
$message_option = strval(Context::get('message_option'));
$improper_comment_reasons = Context::getLang('improper_comment_reasons');
$declare_message = ($message_option !== 'others' && isset($improper_comment_reasons[$message_option]))?
$improper_comment_reasons[$message_option] : trim(Context::get('declare_message'));
// if there is return url, set that.
if(Context::get('success_return_url'))
{
$this->setRedirectUrl(Context::get('success_return_url'));
}
return $this->declaredComment($comment_srl, $declare_message);
}
/**
@ -1313,9 +1325,10 @@ class commentController extends comment
/**
* Report a blamed comment
* @param $comment_srl
* @param string $declare_message
* @return void
*/
function declaredComment($comment_srl)
function declaredComment($comment_srl, $declare_message)
{
// Fail if session information already has a reported document
if($_SESSION['declared_comment'][$comment_srl])
@ -1331,6 +1344,7 @@ class commentController extends comment
{
return $output;
}
$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
$trigger_obj = new stdClass();
@ -1379,7 +1393,9 @@ class commentController extends comment
{
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
}
$args->comment_srl = $comment_srl;
$args->declare_message = trim(htmlspecialchars($declare_message));
$log_output = executeQuery('comment.getCommentDeclaredLogInfo', $args);
// session registered if log info contains report log.
@ -1411,6 +1427,13 @@ class commentController extends comment
// leave the log
$output = executeQuery('comment.insertCommentDeclaredLog', $args);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
$this->add('declared_count', $declared_count + 1);
// Call a trigger (after)
$trigger_obj->declared_count = $declared_count + 1;
@ -1421,6 +1444,7 @@ class commentController extends comment
return $trigger_output;
}
// commit
$oDB->commit();
// leave into the session information