예제 #1
0
 function getComment($document_srl, $comment_srl)
 {
     $args->comment_srl = $comment_srl;
     $args->document_srl = $document_srl;
     $result = new Object();
     // 전체 개수
     $output = executeQuery('socialxe.getCommentCount', $args);
     if (!$output->toBool()) {
         $result->add('list', array());
         $result->add('total', 0);
         return $result;
     }
     $total = $output->data->count;
     // 댓글을 가져온다
     $output = executeQueryArray('socialxe.getComment', $args);
     // 쿼리 결과에서 오류가 생기면 그냥 return
     if (!$output->toBool()) {
         $result->add('list', array());
         $result->add('total', 0);
         return $result;
     }
     $comment_list = $output->data;
     if (!$comment_list) {
         $comment_list = array();
     }
     if (!is_array($comment_list)) {
         $comment_list = array($comment_list);
     }
     // 소셜 댓글 아이템을 생성
     $socialCommentList = array();
     foreach ($comment_list as $comment) {
         if (!$comment->comment_srl) {
             continue;
         }
         unset($oSocialComment);
         $oSocialComment = new socialCommentItem();
         $oSocialComment->setAttribute($comment);
         if ($is_admin) {
             $oSocialComment->setGrant();
         }
         $socialCommentList[$comment->comment_srl] = $oSocialComment;
     }
     $result->add('total', $total);
     $result->add('use_comment_srl', true);
     // 결과가 없으면 그냥 전체 댓글 리스트를 반환한다.
     if (!count($socialCommentList)) {
         return $this->getCommentList($document_srl);
     } else {
         $result->add('list', $socialCommentList);
         return $result;
     }
 }