function getComments() { if (!$this->allowComment() || !$this->getCommentCount()) { return; } if (!$this->isGranted() && $this->isSecret()) { return; } // cpage는 댓글페이지의 번호 $cpage = Context::get('cpage'); // 댓글 목록을 구해옴 $oCommentModel =& getModel('comment'); $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); if (!$output->toBool() || !count($output->data)) { return; } // 구해온 목록을 commentItem 객체로 만듬 // 계층구조에 따라 부모글에 관리권한이 있으면 자식글에는 보기 권한을 줌 $accessible = array(); foreach ($output->data as $key => $val) { $oCommentItem = new commentItem(); $oCommentItem->setAttribute($val); // 권한이 있는 글에 대해 임시로 권한이 있음을 설정 if ($oCommentItem->isGranted()) { $accessible[$val->comment_srl] = true; } // 현재 댓글이 비밀글이고 부모글이 있는 답글이고 부모글에 대해 관리 권한이 있으면 보기 가능하도록 수정 if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) { $oCommentItem->setAccessible(); } $comment_list[$val->comment_srl] = $oCommentItem; } // 스킨에서 출력하기 위한 변수 설정 Context::set('cpage', $output->page_navigation->cur_page); if ($output->total_page > 1) { $this->comment_page_navigation = $output->page_navigation; } return $comment_list; }
function getComments() { if (!$this->getCommentCount()) { return; } if (!$this->isGranted() && $this->isSecret()) { return; } // cpage is a number of comment pages $cpageStr = sprintf('%d_cpage', $this->document_srl); $cpage = Context::get($cpageStr); if (!$cpage) { $cpage = Context::get('cpage'); } // Get a list of comments $oCommentModel = getModel('comment'); $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); if (!$output->toBool() || !count($output->data)) { return; } // Create commentItem object from a comment list // If admin priviledge is granted on parent posts, you can read its child posts. $accessible = array(); $comment_list = array(); foreach ($output->data as $key => $val) { $oCommentItem = new commentItem(); $oCommentItem->setAttribute($val); // If permission is granted to the post, you can access it temporarily if ($oCommentItem->isGranted()) { $accessible[$val->comment_srl] = true; } // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) { $oCommentItem->setAccessible(); } $comment_list[$val->comment_srl] = $oCommentItem; } // Variable setting to be displayed on the skin Context::set($cpageStr, $output->page_navigation->cur_page); Context::set('cpage', $output->page_navigation->cur_page); if ($output->total_page > 1) { $this->comment_page_navigation = $output->page_navigation; } return $comment_list; }
function getComments() { if (!$this->getCommentCount()) { return; } if (!$this->isGranted() && $this->isSecret()) { return; } // cpage is a number of comment pages $cpageStr = sprintf('%d_cpage', $this->document_srl); $cpage = Context::get($cpageStr); if (!$cpage) { $cpage = Context::get('cpage'); } // Get a list of comments $oCommentModel = getModel('comment'); $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin); if (!$output->toBool() || !count($output->data)) { return; } // Create commentItem object from a comment list // If admin priviledge is granted on parent posts, you can read its child posts. $accessible = array(); $comment_list = array(); $setAccessibleComments = Context::getSessionStatus(); foreach ($output->data as $key => $val) { $oCommentItem = new commentItem(); $oCommentItem->setAttribute($val); // If permission is granted to the post, you can access it temporarily if ($oCommentItem->isGranted()) { $accessible[$val->comment_srl] = true; } // If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true) { if ($setAccessibleComments) { $oCommentItem->setAccessible(); } } $comment_list[$val->comment_srl] = $oCommentItem; } // Cache the vote log for all comments. $logged_info = Context::get('logged_info'); if ($logged_info->member_srl) { $comment_srls = array(); foreach ($comment_list as $comment_srl => $comment) { if (!isset($_SESSION['voted_comment'][$comment_srl])) { $comment_srls[] = $comment_srl; } } if (count($comment_srls)) { $output = executeQuery('comment.getCommentVotedLogMulti', (object) array('comment_srls' => $comment_srls, 'member_srl' => $logged_info->member_srl)); foreach ($output->data as $data) { $_SESSION['voted_comment'][$data->comment_srl] = $data->point; } foreach ($comment_srls as $comment_srl) { if (!isset($_SESSION['voted_comment'][$comment_srl])) { $_SESSION['voted_comment'][$comment_srl] = false; } } } } // Variable setting to be displayed on the skin Context::set($cpageStr, $output->page_navigation->cur_page); Context::set('cpage', $output->page_navigation->cur_page); if ($output->total_page > 1) { $this->comment_page_navigation = $output->page_navigation; } return $comment_list; }