Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
80
application/libraries/apis/Comment_delete.php
Normal file
80
application/libraries/apis/Comment_delete.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Comment_delete
|
||||
*/
|
||||
|
||||
|
||||
class Comment_delete extends CI_Controller
|
||||
{
|
||||
|
||||
private $CI;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->CI = & get_instance();
|
||||
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
|
||||
if ( ! $this->CI->input->post_get('token')) {
|
||||
$this->CI->apilib->make_error("토큰 값이 넘어오지 않았습니다");
|
||||
}
|
||||
$token = $this->CI->input->post_get('token');
|
||||
|
||||
|
||||
$app_id = (int) trim($this->CI->input->post_get('app_id'));
|
||||
if (empty($app_id)) {
|
||||
$this->CI->apilib->make_error("어플 아이디가 넘어오지 않았습니다");
|
||||
}
|
||||
|
||||
$con_id = (int) trim($this->CI->input->post('con_id'));
|
||||
if (empty($con_id)) {
|
||||
$this->CI->apilib->make_error("데이터 고유 아이디가 넘어오지 않았습니다");
|
||||
}
|
||||
$com_id = (int) trim($this->CI->input->post('com_id'));
|
||||
if (empty($com_id)) {
|
||||
$this->CI->apilib->make_error("댓글 고유 아이디가 넘어오지 않았습니다");
|
||||
}
|
||||
|
||||
|
||||
$this->CI->load->model(array('Contents_model', 'Contents_comment_model'));
|
||||
|
||||
$sessionuser = $this->CI->User_model->get_by_token($app_id, $token);
|
||||
if ( ! element('user_id', $sessionuser)) {
|
||||
$this->CI->apilib->make_error("로그인 한 회원만 댓글을 삭제할 수 있습니다");
|
||||
}
|
||||
|
||||
$contents = $this->CI->Contents_model->get_one($con_id);
|
||||
if ( ! element('con_id', $contents)) {
|
||||
$this->CI->apilib->make_error("존재하지 않는 컨텐츠입니다.");
|
||||
}
|
||||
|
||||
$comment = $this->CI->Contents_comment_model->get_one($com_id);
|
||||
if ( ! element('com_id', $comment)) {
|
||||
$this->CI->apilib->make_error("존재하지 않는 댓글입니다.");
|
||||
}
|
||||
if (element('user_id', $comment) != element('user_id', $sessionuser)) {
|
||||
$this->CI->apilib->make_error("본인의 댓글만 삭제가 가능합니다.");
|
||||
}
|
||||
|
||||
$this->CI->Contents_comment_model->delete($com_id);
|
||||
|
||||
|
||||
$arr = array(
|
||||
'result' => 'ok',
|
||||
'token' => $token,
|
||||
'app_id' => $app_id,
|
||||
'con_id' => $con_id,
|
||||
'com_id' => $com_id,
|
||||
'datetime' => cdate('Y-m-d H:i:s'),
|
||||
);
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user