Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
88
application/libraries/apis/Comment_list.php
Normal file
88
application/libraries/apis/Comment_list.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Comment_list
|
||||
*/
|
||||
|
||||
|
||||
class Comment_list 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->get('con_id'));
|
||||
if (empty($con_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("존재하지 않는 컨텐츠입니다.");
|
||||
}
|
||||
|
||||
$data = $this->CI->Contents_comment_model->get_api_list($app_id, $con_id);
|
||||
$result = array();
|
||||
$count = 0;
|
||||
if ($data) {
|
||||
foreach ($data as $key => $value) {
|
||||
$result[$key]['com_id'] = html_escape(element('com_id', $value));
|
||||
$result[$key]['con_id'] = html_escape(element('con_id', $value));
|
||||
$result[$key]['user_id'] = html_escape(element('user_id', $value));
|
||||
$result[$key]['user_name'] = html_escape(element('user_username', $value));
|
||||
$result[$key]['user_photo'] = user_photo_url(element('user_photo', $value));
|
||||
$result[$key]['com_content'] = html_escape(element('com_content', $value));
|
||||
$result[$key]['com_created_at'] = html_escape(element('com_created_at', $value));
|
||||
$result[$key]['com_updated_at'] = html_escape(element('com_updated_at', $value));
|
||||
|
||||
$result[$key]['com_reply_user_userid'] = '';
|
||||
if (element('com_reply_user_id', $value)) {
|
||||
$reply_user = $this->CI->User_model->get_one(element('com_reply_user_id', $value), 'user_userid');
|
||||
$result[$key]['com_reply_user_userid'] = element('user_userid', $reply_user);
|
||||
}
|
||||
|
||||
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$arr = array(
|
||||
'result' => 'ok',
|
||||
'token' => $token,
|
||||
'app_id' => $app_id,
|
||||
'count' => $count,
|
||||
'list' => $result,
|
||||
);
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user