mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-16 09:49:54 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1628 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
3f649ab32a
commit
67572cebaf
39 changed files with 543 additions and 459 deletions
|
|
@ -5,6 +5,8 @@
|
|||
* @brief document 모듈의 high 클래스
|
||||
**/
|
||||
|
||||
require_once('./modules/document/document.item.php');
|
||||
|
||||
class document extends ModuleObject {
|
||||
|
||||
// 공지사항용 값
|
||||
|
|
|
|||
|
|
@ -227,11 +227,11 @@
|
|||
$oDocumentModel = &getModel('document');
|
||||
|
||||
// 기존 문서가 있는지 확인
|
||||
$document = $oDocumentModel->getDocument($document_srl, $is_admin);
|
||||
if($document->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
|
||||
if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new Object(-1, 'msg_invalid_document');
|
||||
|
||||
// 권한이 있는지 확인
|
||||
if(!$document->is_granted&&!$is_admin) return new Object(-1, 'msg_not_permitted');
|
||||
if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
|
||||
|
||||
// 글 삭제
|
||||
$args->document_srl = $document_srl;
|
||||
|
|
@ -260,7 +260,7 @@
|
|||
}
|
||||
|
||||
// 카테고리가 있으면 카테고리 정보 변경
|
||||
if($document->category_srl) $this->updateCategoryCount($document->category_srl);
|
||||
if($document->category_srl) $this->updateCategoryCount($oDocument->get('category_srl'));
|
||||
|
||||
// commit
|
||||
$oDB->commit();
|
||||
|
|
@ -271,8 +271,10 @@
|
|||
/**
|
||||
* @brief 해당 document의 조회수 증가
|
||||
**/
|
||||
function updateReadedCount($document) {
|
||||
$document_srl = $document->document_srl;
|
||||
function updateReadedCount($oDocument) {
|
||||
$document_srl = $oDocument->document_srl;
|
||||
$member_srl = $oDocument->get('member_srl');
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
// session에 정보로 조회수를 증가하였다고 생각하면 패스
|
||||
if($_SESSION['readed_document'][$document_srl]) return false;
|
||||
|
|
@ -284,21 +286,18 @@
|
|||
}
|
||||
|
||||
// document의 작성자가 회원일때 조사
|
||||
if($document->member_srl) {
|
||||
// member model 객체 생성
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
if($member_srl) {
|
||||
|
||||
// 글쓴이와 현재 로그인 사용자의 정보가 일치하면 읽었다고 생각하고 세션 등록후 패스
|
||||
if($member_srl && $member_srl == $document->member_srl) {
|
||||
if($member_srl && $logged_info->member_srl == $member_srl) {
|
||||
$_SESSION['readed_document'][$document_srl] = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 로그인 사용자이면 member_srl, 비회원이면 ipaddress로 판단
|
||||
if($member_srl) {
|
||||
$args->member_srl = $member_srl;
|
||||
if($logged_info->member_srl) {
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
} else {
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
|
|
|||
183
modules/document/document.item.php
Normal file
183
modules/document/document.item.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
/**
|
||||
* @class documentItem
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief document 객체
|
||||
**/
|
||||
|
||||
class documentItem extends Object {
|
||||
|
||||
var $document_srl = 0;
|
||||
|
||||
function documentItem($document_srl = 0) {
|
||||
$this->document_srl = $document_srl;
|
||||
$this->_loadFromDB();
|
||||
}
|
||||
|
||||
function setDocument($document_srl) {
|
||||
$this->document_srl = $document_srl;
|
||||
$this->_loadFromDB();
|
||||
}
|
||||
|
||||
function _loadFromDB() {
|
||||
if(!$this->document_srl) return;
|
||||
|
||||
$args->document_srl = $this->document_srl;
|
||||
$output = executeQuery('document.getDocument', $args);
|
||||
|
||||
$this->setAttribute($output->data);
|
||||
}
|
||||
|
||||
function setAttribute($attribute) {
|
||||
if(!$attribute->document_srl) return;
|
||||
$this->document_srl = $attribute->document_srl;
|
||||
$this->adds($attribute);
|
||||
|
||||
// 태그 정리
|
||||
if($this->get('tags')) {
|
||||
$tags = explode(',',$this->get('tags'));
|
||||
$tag_count = count($tags);
|
||||
for($i=0;$i<$tag_count;$i++) if(trim($tags[$i])) $tag_list[] = trim($tags[$i]);
|
||||
$this->add('tag_list', $tag_list);
|
||||
}
|
||||
}
|
||||
|
||||
function isExists() {
|
||||
return $this->document_srl ? true : false;
|
||||
}
|
||||
|
||||
function isGranted() {
|
||||
if($_SESSION['own_attribute'][$this->document_srl]) return true;
|
||||
|
||||
if(!Context::get('is_logged')) return false;
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
if($logged_info->is_admin == 'Y') return true;
|
||||
|
||||
if($this->get('member_srl') && $this->get('member_srl') == $logged_info->member_srl) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function setGrant() {
|
||||
$_SESSION['own_attribute'][$this->document_srl] = true;
|
||||
}
|
||||
|
||||
function allowComment() {
|
||||
return $this->get('allow_comment') == 'Y' ? true : false;
|
||||
}
|
||||
|
||||
function allowTrackback() {
|
||||
return $this->get('allow_trackback') == 'Y' ? true : false;
|
||||
}
|
||||
|
||||
function isLocked() {
|
||||
return $this->get('lock_comment') == 'Y' ? true : false;
|
||||
}
|
||||
|
||||
function isEditable() {
|
||||
if($this->isGranted() || !$this->get('member_srl')) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSecret() {
|
||||
return $this->get('is_secret') == 'Y' ? true : false;
|
||||
}
|
||||
|
||||
function isNotice() {
|
||||
return $this->get('is_notice') == 'Y' ? true : false;
|
||||
}
|
||||
|
||||
function getUserID() {
|
||||
return htmlspecialchars($this->get('user_id'));
|
||||
}
|
||||
|
||||
function getUserName() {
|
||||
return htmlspecialchars($this->get('user_name'));
|
||||
}
|
||||
|
||||
function getNickName() {
|
||||
return htmlspecialchars($this->get('nick_name'));
|
||||
}
|
||||
|
||||
function getTitleText($cut_size = 0) {
|
||||
return htmlspecialchars($this->getTitle());
|
||||
}
|
||||
|
||||
function getTitle($cut_size = 0) {
|
||||
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
|
||||
|
||||
if($cut_size) return cut_str($this->get('title'), $cut_size);
|
||||
|
||||
return $this->get('title');
|
||||
}
|
||||
|
||||
function getContentText() {
|
||||
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
|
||||
|
||||
return htmlspecialchars($this->get('content'));
|
||||
}
|
||||
|
||||
function getContent() {
|
||||
if($this->isSecret() && !$this->isGranted()) return Context::getLang('msg_is_secret');
|
||||
|
||||
return sprintf('<!--BeforeDocument(%d,%d)-->%s<!--AfterDocument(%d,%d)-->', $this->document_srl, $this->get('member_srl'), $this->get('content'), $this->document_srl, $this->get('member_srl'));
|
||||
}
|
||||
|
||||
function getRegdate($format = 'Y.m.d H:i:s') {
|
||||
return zdate($this->get('regdate'), $format);
|
||||
}
|
||||
|
||||
function getPermanentUrl() {
|
||||
return getUrl('','document_srl',$this->document_srl);
|
||||
}
|
||||
|
||||
function getTrackbackUrl() {
|
||||
return getUrl('','document_srl',$this->document_srl,'act','trackback');
|
||||
}
|
||||
|
||||
function updateReadedCount() {
|
||||
$oDocumentController = &getController('document');
|
||||
if($oDocumentController->updateReadedCount($this)) {
|
||||
$readed_count = $this->get('readed_count');
|
||||
$readed_count++;
|
||||
$this->add('readed_count', $readed_count);
|
||||
}
|
||||
}
|
||||
|
||||
function getCommentCount() {
|
||||
return $this->get('comment_count');
|
||||
}
|
||||
|
||||
function getComments() {
|
||||
if(!$this->allowComment() || !$this->get('comment_count')) return;
|
||||
|
||||
$oCommentModel = &getModel('comment');
|
||||
return $oCommentModel->getCommentList($this->document_srl, $is_admin);
|
||||
}
|
||||
|
||||
function getTrackbackCount() {
|
||||
return $this->get('trackback_count');
|
||||
}
|
||||
|
||||
function getTrackbacks() {
|
||||
if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
|
||||
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
|
||||
}
|
||||
|
||||
function hasUploadedFiles() {
|
||||
return $this->get('uploaded_count')? true : false;
|
||||
}
|
||||
|
||||
function getUploadedFiles() {
|
||||
if(!$this->get('uploaded_count')) return;
|
||||
|
||||
$oFileModel = &getModel('file');
|
||||
$file_list = $oFileModel->getFiles($this->document_srl, $is_admin);
|
||||
return $file_list;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -23,71 +23,17 @@
|
|||
/**
|
||||
* @brief 문서 가져오기
|
||||
**/
|
||||
function getDocument($document_srl, $is_admin=false, $get_extra_info=false) {
|
||||
// DB에서 가져옴
|
||||
$args->document_srl = $document_srl;
|
||||
$output = executeQuery('document.getDocument', $args);
|
||||
$document = $output->data;
|
||||
if(!$document) return;
|
||||
function getDocument($document_srl, $is_admin = false) {
|
||||
$oDocument = new documentItem($document_srl);
|
||||
if($is_admin) $oDocument->setGrant();
|
||||
|
||||
// 이 문서에 대한 권한이 있는지 확인
|
||||
if($this->isGranted($document->document_srl) || $is_admin) {
|
||||
$document->is_granted = true;
|
||||
} elseif($document->member_srl) {
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
if($member_srl && $member_srl ==$document->member_srl) $document->is_granted = true;
|
||||
}
|
||||
|
||||
// 비밀글이고 권한이 없을 경우 제목과 내용을 숨김
|
||||
if($document->is_secret=='Y' && !$document->is_granted) {
|
||||
$document->title = $document->content = Context::getLang('msg_is_secret');
|
||||
}
|
||||
|
||||
// 확장 정보(코멘트나 기타 등등) 플래그가 false이면 기본 문서 정보만 return
|
||||
if(!$get_extra_info) return $document;
|
||||
|
||||
// document controller 객체 생성
|
||||
$oDocumentController = &getController('document');
|
||||
|
||||
// 조회수 업데이트
|
||||
if($buff = $oDocumentController->updateReadedCount($document)) $document->readed_count++;
|
||||
|
||||
// 댓글 가져오기
|
||||
if($document->comment_count && $document->allow_comment == 'Y') {
|
||||
$oCommentModel = &getModel('comment');
|
||||
$document->comment_list = $oCommentModel->getCommentList($document_srl, $is_admin);
|
||||
}
|
||||
|
||||
// 트랙백 가져오기
|
||||
if($document->trackback_count && $document->allow_trackback == 'Y') {
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
$document->trackback_list = $oTrackbackModel->getTrackbackList($document_srl, $is_admin);
|
||||
}
|
||||
|
||||
// 첨부파일 가져오기
|
||||
if($document->uploaded_count) {
|
||||
$oFileModel = &getModel('file');
|
||||
$file_list = $oFileModel->getFiles($document_srl, $is_admin);
|
||||
$document->uploaded_list = $file_list;
|
||||
}
|
||||
|
||||
// 태그 정리
|
||||
if($document->tags) {
|
||||
$tag_list = explode(',',$document->tags);
|
||||
$tag_count = count($tag_list);
|
||||
for($i=0;$i<$tag_count;$i++) if(trim($tag_list[$i])) $document->tag_list[] = trim($tag_list[$i]);
|
||||
}
|
||||
|
||||
$document->content = sprintf('<!--BeforeDocument(%d,%d)-->%s<!--AfterDocument(%d,%d)-->', $document_srl, $document->member_srl, $document->content, $document_srl, $document->member_srl);
|
||||
|
||||
return $document;
|
||||
}
|
||||
return $oDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 여러개의 문서들을 가져옴 (페이징 아님)
|
||||
**/
|
||||
function getDocuments($document_srl_list, $is_admin=false) {
|
||||
function getDocuments($document_srl_list, $is_admin = false) {
|
||||
if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list);
|
||||
|
||||
// DB에서 가져옴
|
||||
|
|
@ -97,21 +43,17 @@
|
|||
if(!$document_list) return;
|
||||
if(!is_array($document_list)) $document_list = array($document_list);
|
||||
|
||||
// 권한 체크
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
|
||||
$document_count = count($document_list);
|
||||
for($i=0;$i<$document_count;$i++) {
|
||||
$document = $document_list[$i];
|
||||
$is_granted = false;
|
||||
$document_srl = $attribute->document_srl;
|
||||
$attribute = $document_list[$i];
|
||||
|
||||
if($this->isGranted($document->document_srl) || $is_admin) {
|
||||
$is_granted = true;
|
||||
} elseif($member_srl && $member_srl == $document->member_srl) {
|
||||
$is_granted = true;
|
||||
}
|
||||
$document_list[$i]->is_granted = $is_granted;
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute);
|
||||
if($is_admin) $oDocument->setGrant();
|
||||
|
||||
$document_list[$document_srl] = $oDocument;
|
||||
}
|
||||
return $document_list;
|
||||
}
|
||||
|
|
@ -119,9 +61,9 @@
|
|||
/**
|
||||
* @brief module_srl값을 가지는 문서의 목록을 가져옴
|
||||
**/
|
||||
function getDocumentList($obj, $get_extra_info = false) {
|
||||
|
||||
if(!in_array($obj->sort_index, array('list_order','regdate','update_order','readed_count','voted_count'))) $obj->sort_index = 'list_order'; ///< 소팅 값
|
||||
function getDocumentList($obj) {
|
||||
// 정렬 대상과 순서 체크
|
||||
if(!in_array($obj->sort_index, array('list_order','regdate','update_order','readed_count','voted_count'))) $obj->sort_index = 'list_order';
|
||||
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
|
||||
|
||||
// module_srl 대신 mid가 넘어왔을 경우는 직접 module_srl을 구해줌
|
||||
|
|
@ -135,8 +77,8 @@
|
|||
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
|
||||
else $args->module_srl = $obj->module_srl;
|
||||
|
||||
// 변수 체크
|
||||
$args->category_srl = $obj->category_srl?$obj->category_srl:'';
|
||||
|
||||
$args->sort_index = $obj->sort_index;
|
||||
$args->order_type = $obj->order_type;
|
||||
$args->page = $obj->page?$obj->page:1;
|
||||
|
|
@ -232,55 +174,15 @@
|
|||
// 결과가 없거나 오류 발생시 그냥 return
|
||||
if(!$output->toBool()||!count($output->data)) return $output;
|
||||
|
||||
// 권한 체크
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
foreach($output->data as $key => $attribute) {
|
||||
$document_srl = $attribute->document_srl;
|
||||
|
||||
// document controller 객체 생성
|
||||
$oDocumentController = &getController('document');
|
||||
$oDocument = null;
|
||||
$oDocument = new documentItem();
|
||||
$oDocument->setAttribute($attribute);
|
||||
if($is_admin) $oDocument->setGrant();
|
||||
|
||||
foreach($output->data as $key => $document) {
|
||||
// 권한 부여
|
||||
$is_granted = false;
|
||||
|
||||
if($this->isGranted($document->document_srl)) $is_granted = true;
|
||||
elseif($member_srl && $member_srl == $document->member_srl) $is_granted = true;
|
||||
|
||||
$document->is_granted = $is_granted;
|
||||
|
||||
$document_srl = $document->document_srl;
|
||||
|
||||
if($get_extra_info) {
|
||||
// 댓글 가져오기
|
||||
if($document->comment_count && $document->allow_comment == 'Y') {
|
||||
$oCommentModel = &getModel('comment');
|
||||
$document->comment_list = $oCommentModel->getCommentList($document_srl, $is_admin);
|
||||
}
|
||||
|
||||
// 트랙백 가져오기
|
||||
if($document->trackback_count && $document->allow_trackback == 'Y') {
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
$document->trackback_list = $oTrackbackModel->getTrackbackList($document_srl, $is_admin);
|
||||
}
|
||||
|
||||
// 첨부파일 가져오기
|
||||
if($document->uploaded_count) {
|
||||
$oFileModel = &getModel('file');
|
||||
$file_list = $oFileModel->getFiles($document_srl, $is_admin);
|
||||
$document->uploaded_list = $file_list;
|
||||
}
|
||||
|
||||
// 태그 정리
|
||||
if($document->tags) {
|
||||
$tag_list = explode(',',$document->tags);
|
||||
$tag_count = count($tag_list);
|
||||
for($i=0;$i<$tag_count;$i++) if(trim($tag_list[$i])) $document->tag_list[] = trim($tag_list[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$document->content = sprintf('<!--BeforeDocument(%d,%d)-->%s<!--AfterDocument(%d,%d)-->', $document_srl, $document->member_srl, $document->content, $document_srl, $document->member_srl);
|
||||
|
||||
$output->data[$key] = $document;
|
||||
$output->data[$key] = $oDocument;
|
||||
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -24,26 +24,26 @@
|
|||
<th>{$lang->date}</th>
|
||||
</tr>
|
||||
|
||||
<!--@foreach($document_list as $no => $val)-->
|
||||
<!--@foreach($document_list as $no => $oDocument)-->
|
||||
<tr>
|
||||
<td>{$no}</td>
|
||||
<td><input type="checkbox" name="cart" value="{$val->document_srl}" /></td>
|
||||
<td><a href="#" onclick="window.open('./?mid={$module_list[$val->module_srl]->mid}');return false">{htmlspecialchars($module_list[$val->module_srl]->browser_title)}</a></td>
|
||||
<td><input type="checkbox" name="cart" value="{$oDocument->document_srl}" /></td>
|
||||
<td><a href="#" onclick="window.open('./?mid={$module_list[$oDocument->get('module_srl')]->mid}');return false">{htmlspecialchars($module_list[$oDocument->get('module_srl')]->browser_title)}</a></td>
|
||||
<td>
|
||||
<a href="#" onclick="window.open('./?document_srl={$val->document_srl}');return false">{htmlspecialchars($val->title)}</a>
|
||||
<a href="#" onclick="window.open('./?document_srl={$oDocument->document_srl}');return false">{$oDocument->getTitleText()}</a>
|
||||
|
||||
<!--@if($val->comment_count>0)-->
|
||||
[{$val->comment_count}]
|
||||
<!--@if($oDocument->getCommentCount())-->
|
||||
[{$oDocument->getCommentCount()}]
|
||||
<!--@end-->
|
||||
|
||||
<!--@if($val->trackback_count>0)-->
|
||||
[{$val->trackback_count}]
|
||||
<!--@if($oDocument->getTrackbackCount())-->
|
||||
[{$oDocument->getTrackbackCount()}]
|
||||
<!--@end-->
|
||||
</td>
|
||||
<td><div class="member_{$val->member_srl}">{htmlspecialchars($val->user_name)}</div></td>
|
||||
<td>{$val->readed_count}</td>
|
||||
<td>{$val->voted_count}</td>
|
||||
<td>{zdate($val->regdate,"Y-m-d")}</td>
|
||||
<td><div class="member_{$oDocument->get('member_srl')}">{$oDocument->getUserName()}</div></td>
|
||||
<td>{$oDocument->get('readed_count')}</td>
|
||||
<td>{$oDocument->get('voted_count')}</td>
|
||||
<td>{$oDocument->getRegdate("Y-m-d")}</td>
|
||||
</tr>
|
||||
<!--@end-->
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue