mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@126 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ee2a89b7ce
commit
e7d5dd84e8
27 changed files with 395 additions and 279 deletions
|
|
@ -12,7 +12,7 @@
|
|||
**/
|
||||
function init() {
|
||||
// 파일 업로드일 경우 $act값을 procUploadFile() 로 변경
|
||||
if(Context::isUploaded() && $this->grant->fileupload) $this->act = 'procUploadFile';
|
||||
if(Context::isUploaded() && $this->grant->fileupload) Context::set('act', 'procUploadFile');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -433,7 +433,7 @@
|
|||
/**
|
||||
* @brief 게시판 추가
|
||||
**/
|
||||
function procBoardInsert() {
|
||||
function procInsertBoard() {
|
||||
// 일단 입력된 값들을 모두 받아서 db 입력항목과 그외 것으로 분리
|
||||
$args = Context::gets('module_srl','mid','skin','use_category','browser_title','description','is_default','header_text','footer_text','admin_id');
|
||||
$args->module = 'board';
|
||||
|
|
@ -483,7 +483,7 @@
|
|||
/**
|
||||
* @brief 게시판 삭제
|
||||
**/
|
||||
function procBoardDelete() {
|
||||
function procDeleteBoard() {
|
||||
$module_srl = Context::get('module_srl');
|
||||
|
||||
// 원본을 구해온다
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
// 카테고리를 사용한다면 카테고리 목록을 구해옴
|
||||
// 카테고리를 사용하는지 확인후 사용시 카테고리 목록을 구해와서 Context에 세팅
|
||||
if($this->module_info->use_category=='Y') {
|
||||
$oDocumentModel = &getModel('document');
|
||||
$this->category_list = $oDocumentModel->getCategoryList($this->module_srl);
|
||||
|
|
@ -27,8 +27,6 @@
|
|||
// 스킨 디렉토리 세팅
|
||||
$skin_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
|
||||
$this->setTemplatePath($skin_path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -47,86 +45,34 @@
|
|||
|
||||
// document_srl이 있다면 해당 글을 구해오자
|
||||
if($this->grant->view && $document_srl) {
|
||||
$document = $oDocumentModel->getDocument($document_srl);
|
||||
|
||||
// 글이 찾아지지 않으면 무효화
|
||||
if(!$document) {
|
||||
Context::set('document_srl','');
|
||||
$document_srl = NULL;
|
||||
unset($document);
|
||||
}
|
||||
}
|
||||
|
||||
// 글이 찾아지면 조회수 업데이트 및 기타 등등
|
||||
if($document) {
|
||||
|
||||
// 비밀글이고 권한이 없을 경우 인증페이지로
|
||||
if($document->is_secret=='Y' && !$document->is_granted) return $this->setTemplateFile('input_password_form');
|
||||
|
||||
// 조회수 업데이트
|
||||
if($oDocument->updateReadedCount($document_srl)) $document->readed_count++;
|
||||
|
||||
// 댓글 가져오기
|
||||
if($document->comment_count && $document->allow_comment == 'Y') {
|
||||
$oCommentModel = &getModel('comment');
|
||||
$comment_list = $oCommentModel->getCommentList($document_srl);
|
||||
Context::set('comment_list', $comment_list);
|
||||
}
|
||||
|
||||
// 트랙백 가져오기
|
||||
if($document->trackback_count && $document->allow_trackback == 'Y') {
|
||||
$oTrackback = &getModule('trackback');
|
||||
$trackback_list = $oTrackback->getTrackbackList($document_srl);
|
||||
Context::set('trackback_list', $trackback_list);
|
||||
}
|
||||
|
||||
// 첨부파일 가져오기
|
||||
if($document->uploaded_count) {
|
||||
$file_list = $oDocument->getFiles($document_srl);
|
||||
$document->uploaded_list = $file_list;
|
||||
}
|
||||
|
||||
$document = $oDocumentModel->getDocument($document_srl, $this->grant->manager, true);
|
||||
Context::set('document', $document);
|
||||
|
||||
}
|
||||
|
||||
// 만약 document_srl은 있는데 page가 없다면 글만 호출된 경우,
|
||||
// 그럼 page를 구해서 세팅해주자..
|
||||
// 만약 document_srl은 있는데 page가 없다면 글만 호출된 경우 page를 구해서 세팅해주자..
|
||||
if($document_srl && !$page) {
|
||||
$page = $oDocument->getDocumentPage($document_srl, $this->module_srl, $this->list_count);
|
||||
$page = $oDocumentModel->getDocumentPage($document_srl, $this->module_srl, $this->list_count);
|
||||
Context::set('page', $page);
|
||||
}
|
||||
|
||||
// 검색옵션
|
||||
$search_target = Context::get('search_target');
|
||||
$keyword = Context::get('keyword');
|
||||
if($search_target && $keyword) {
|
||||
$keyword = str_replace(' ','%',$keyword);
|
||||
switch($search_target) {
|
||||
case 'title' :
|
||||
$search_obj->s_title = $keyword;
|
||||
break;
|
||||
case 'content' :
|
||||
$search_obj->s_content = $keyword;
|
||||
break;
|
||||
case 'title_content' :
|
||||
$search_obj->s_title = $keyword;
|
||||
$search_obj->s_content = $keyword;
|
||||
break;
|
||||
case 'user_name' :
|
||||
$search_obj->s_user_name = $keyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 목록을 구하기 위한 옵션
|
||||
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
|
||||
$args->page = $page; ///< 페이지
|
||||
$args->list_count = $this->list_count; ///< 한페이지에 보여줄 글 수
|
||||
$args->page_count = $this->page_count; ///< 페이지 네비게이션에 나타날 페이지의 수
|
||||
|
||||
// 카테고리
|
||||
$category = Context::get('category');
|
||||
if($category) $search_obj->category_srl = $category;
|
||||
$args->search_target = Context::get('search_target'); ///< 검색 대상 (title, contents...)
|
||||
$args->search_keyword = Context::get('search_keyword'); ///< 검색어
|
||||
if($this->module_info->use_category=='Y') $args->category_srl = Context::get('category'); ///< 카테고리 사용시 선택된 카테고리
|
||||
|
||||
// 목록의 경우 document->getDocumentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다)
|
||||
$oDocumentModel = &getModel('document');
|
||||
$output = $oDocumentModel->getDocumentList($this->module_srl, 'list_order', $page, $this->list_count, $this->page_count, $search_obj);
|
||||
$args->sort_index = 'list_order'; ///< 소팅 값
|
||||
|
||||
// 템플릿에 쓰기 위해서 context::set
|
||||
// 목록 구함, document->getDocumentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다)
|
||||
$output = $oDocumentModel->getDocumentList($args);
|
||||
|
||||
// 템플릿에 쓰기 위해서 document_model::getDocumentList() 의 return object에 있는 값들을 세팅
|
||||
Context::set('total_count', $output->total_count);
|
||||
Context::set('total_page', $output->total_page);
|
||||
Context::set('page', $output->page);
|
||||
|
|
@ -139,6 +85,7 @@
|
|||
$search_option[$this->search_option[$i]] = Context::getLang($this->search_option[$i]);
|
||||
}
|
||||
Context::set('search_option', $search_option);
|
||||
|
||||
$this->setTemplateFile('list');
|
||||
}
|
||||
|
||||
|
|
@ -149,24 +96,25 @@
|
|||
// 권한 체크
|
||||
if(!$this->grant->write_document) return $this->dispMessage('msg_not_permitted');
|
||||
|
||||
// 목록 구현에 필요한 변수들을 가져온다
|
||||
// GET parameter에서 document_srl을 가져옴
|
||||
$document_srl = Context::get('document_srl');
|
||||
|
||||
// document 모듈 객체 생성
|
||||
$oDocument = &getModule('document');
|
||||
$oDocumentModel = &getModel('document');
|
||||
|
||||
// 지정된 글이 없다면 (신규) 새로운 번호를 만든다
|
||||
if($document_srl) {
|
||||
$document = $oDocumentModel->getDocument($document_srl);
|
||||
if(!$document) {
|
||||
unset($document_srl);
|
||||
Context::set('document_srl','');
|
||||
}
|
||||
}
|
||||
|
||||
// 문서 번호가 없으면 새로운 값을 받아옴
|
||||
if(!$document_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
$document_srl = $oDB->getNextSequence();
|
||||
|
||||
// 글의 수정일 경우 원본 글을 가져와서 확인을 한다
|
||||
} else {
|
||||
$document = $oDocument->getDocument($document_srl);
|
||||
if(!$document) {
|
||||
$oDB = &DB::getInstance();
|
||||
$document_srl = $oDB->getNextSequence();
|
||||
}
|
||||
}
|
||||
|
||||
// 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로
|
||||
|
|
@ -190,8 +138,8 @@
|
|||
|
||||
// 지정된 글이 있는지 확인
|
||||
if($document_srl) {
|
||||
$oDocument = &getModule('document');
|
||||
$document = $oDocument->getDocument($document_srl);
|
||||
$oDocumentModel = &getModel('document');
|
||||
$document = $oDocumentModel->getDocument($document_srl);
|
||||
}
|
||||
|
||||
// 삭제하려는 글이 없으면 에러
|
||||
|
|
@ -220,11 +168,11 @@
|
|||
if(!$parent_srl) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
// 해당 댓글를 찾아본다
|
||||
$oComment = &getModule('comment');
|
||||
$source_comment = $oComment->getComment($parent_srl);
|
||||
$oCommentModel = &getModel('comment');
|
||||
$source_comment = $oCommentModel->getComment($parent_srl);
|
||||
|
||||
// 댓글이 없다면 오류
|
||||
if(!$source_comment) return new Object(-1, 'msg_invalid_request');
|
||||
if(!$source_comment) return $this->dispMessage('msg_invalid_request');
|
||||
|
||||
// 필요한 정보들 세팅
|
||||
Context::set('document_srl',$document_srl);
|
||||
|
|
@ -250,14 +198,14 @@
|
|||
if(!$comment_srl) return new Object(-1, 'msg_invalid_request');
|
||||
|
||||
// 해당 댓글를 찾아본다
|
||||
$oComment = &getModule('comment');
|
||||
$comment = $oComment->getComment($comment_srl);
|
||||
$oCommentModel = &getModel('comment');
|
||||
$comment = $oCommentModel->getComment($comment_srl);
|
||||
|
||||
// 댓글이 없다면 오류
|
||||
if(!$comment) return new Object(-1, 'msg_invalid_request');
|
||||
if(!$comment) return $this->dispMessage('msg_invalid_request');
|
||||
|
||||
// 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로
|
||||
if($comment_srl&&$comment&&!$_SESSION['own_comment'][$comment_srl]) return $this->setTemplateFile('input_password_form');
|
||||
if($comment_srl&&$comment&&!$comment->is_granted) return $this->setTemplateFile('input_password_form');
|
||||
|
||||
// 필요한 정보들 세팅
|
||||
Context::set('document_srl',$document_srl);
|
||||
|
|
@ -279,26 +227,46 @@
|
|||
|
||||
// 삭제하려는 댓글가 있는지 확인
|
||||
if($comment_srl) {
|
||||
$oComment = &getModule('comment');
|
||||
$comment = $oComment->getComment($comment_srl);
|
||||
$oCommentModel = &getModel('comment');
|
||||
$comment = $oCommentModel->getComment($comment_srl);
|
||||
}
|
||||
|
||||
// 삭제하려는 글이 없으면 에러
|
||||
if(!$comment) return $this->list();
|
||||
|
||||
// 권한이 없는 경우 비밀번호 입력화면으로
|
||||
if($comment_srl&&$comment&&!$_SESSION['own_comment'][$comment_srl]) return $this->setTemplateFile('input_password_form');
|
||||
if($comment_srl&&$comment&&!$comment->is_granted) return $this->setTemplateFile('input_password_form');
|
||||
|
||||
Context::set('comment',$comment);
|
||||
|
||||
$this->setTemplateFile('delete_comment_form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 엮인글 삭제 화면 출력
|
||||
**/
|
||||
function dispTrackbackDelete() {
|
||||
// 삭제할 댓글번호를 가져온다
|
||||
$trackback_srl = Context::get('trackback_srl');
|
||||
|
||||
// 삭제하려는 댓글가 있는지 확인
|
||||
$oTrackbackModel = &getModel('trackback');
|
||||
$output = $oTrackbackModel->getTrackback($trackback_srl);
|
||||
$trackback = $output->data;
|
||||
|
||||
// 삭제하려는 글이 없으면 에러
|
||||
if(!$trackback) return $this->dispContent();
|
||||
|
||||
Context::set('trackback',$trackback);
|
||||
|
||||
$this->setTemplateFile('delete_trackback_form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 로그인 폼 출력
|
||||
**/
|
||||
function dispLogin() {
|
||||
if(Context::get('is_logged')) return $this->list();
|
||||
if(Context::get('is_logged')) return $this->dispContent();
|
||||
$this->setTemplateFile('login_form');
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +274,7 @@
|
|||
* @brief 로그아웃 화면 출력
|
||||
**/
|
||||
function dispLogout() {
|
||||
if(!Context::get('is_logged')) return $this->list();
|
||||
if(!Context::get('is_logged')) return $this->dispContent();
|
||||
$this->setTemplateFile('logout');
|
||||
}
|
||||
|
||||
|
|
@ -321,26 +289,6 @@
|
|||
$this->setTemplateFile('message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 엮인글 삭제 화면 출력
|
||||
**/
|
||||
function dispTrackbackDelete() {
|
||||
// 삭제할 댓글번호를 가져온다
|
||||
$trackback_srl = Context::get('trackback_srl');
|
||||
|
||||
// 삭제하려는 댓글가 있는지 확인
|
||||
$oTrackback = &getModule('trackback');
|
||||
$output = $oTrackback->getTrackback($trackback_srl);
|
||||
$trackback = $output->data;
|
||||
|
||||
// 삭제하려는 글이 없으면 에러
|
||||
if(!$trackback) return $this->list();
|
||||
|
||||
Context::set('trackback',$trackback);
|
||||
|
||||
$this->setTemplateFile('delete_trackback_form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief RSS 출력
|
||||
**/
|
||||
|
|
@ -348,7 +296,21 @@
|
|||
// 권한 체크
|
||||
if(!$this->grant->list) return $this->dispMessage('msg_not_permitted');
|
||||
|
||||
$page = Context::get('page');
|
||||
// 컨텐츠 추출
|
||||
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
|
||||
$args->page = Context::get('page'); ///< 페이지
|
||||
$args->list_count = $this->list_count; ///< 한페이지에 보여줄 글 수
|
||||
$args->page_count = $this->page_count; ///< 페이지 네비게이션에 나타날 페이지의 수
|
||||
|
||||
$args->search_target = Context::get('search_target'); ///< 검색 대상 (title, contents...)
|
||||
$args->search_keyword = Context::get('search_keyword'); ///< 검색어
|
||||
if($this->module_info->use_category=='Y') $args->category_srl = Context::get('category'); ///< 카테고리 사용시 선택된 카테고리
|
||||
|
||||
$args->sort_index = 'list_order'; ///< 소팅 값
|
||||
|
||||
$oDocumentModel = &getModel('document');
|
||||
$output = $oDocumentModel->getDocumentList($args);
|
||||
$document_list = $output->data;
|
||||
|
||||
// rss 제목 및 정보등을 추출
|
||||
$info->title = Context::getBrowserTitle();
|
||||
|
|
@ -356,15 +318,12 @@
|
|||
$info->language = Context::getLangType();
|
||||
$info->date = gmdate("D, d M Y H:i:s");
|
||||
$info->link = sprintf("%s?mid=%s", Context::getRequestUri(), Context::get('mid'));
|
||||
|
||||
// 컨텐츠 추출
|
||||
$oDocument = &getModule('document');
|
||||
$output = $oDocument->getDocumentList($this->module_srl, 'update_order', $page, 20, 20, NULL);
|
||||
$document_list = $output->data;
|
||||
$info->total_count = $output->total_count;
|
||||
$info->total_page = $output->total_page;
|
||||
|
||||
// 출력하고 끝내기
|
||||
$oRss = &getView('rss');
|
||||
$oRss->dispRss($info, $document_list);
|
||||
$oRssView = &getView('rss');
|
||||
$oRssView->dispRss($info, $document_list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -373,9 +332,10 @@
|
|||
function dispAdminContent() {
|
||||
// module_srl이 있으면 미리 체크하여 존재하는 모듈이면 module_info 세팅
|
||||
$module_srl = Context::get('module_srl');
|
||||
|
||||
if($module_srl) {
|
||||
$oModule = &getModule('module_manager');
|
||||
$module_info = $oModule->getModuleInfoByModuleSrl($module_srl);
|
||||
$oModuleModel = &getModel('module');
|
||||
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
|
||||
if(!$module_info) {
|
||||
Context::set('module_srl','');
|
||||
$this->act = 'list';
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<action name="dispCommentDelete" type="view" />
|
||||
<action name="dispTrackbackDelete" type="view" />
|
||||
<action name="dispLogin" type="view" />
|
||||
<action name="dispLogout" type="view" />
|
||||
<action name="dispLogout" type="view" grant="member" />
|
||||
<action name="dispMessage" type="view" />
|
||||
<action name="dispRss" type="view" />
|
||||
<action name="dispAdminContent" type="view" grant="root" />
|
||||
|
|
@ -45,5 +45,25 @@
|
|||
<action name="dispAdminSkinInfo" type="view" grant="root" />
|
||||
<action name="dispAdminCategoryInfo" type="view" grant="root" />
|
||||
<action name="dispAdminGrantInfo" type="view" grant="root" />
|
||||
<action name="procLogin" type="controller" />
|
||||
<action name="procLogout" type="controller" grant="member" />
|
||||
<action name="procInsertDocument" type="controller" />
|
||||
<action name="procDeleteDocument" type="controller" />
|
||||
<action name="procVoteDocument" type="controller" />
|
||||
<action name="procInsertComment" type="controller" />
|
||||
<action name="procDeleteComment" type="controller" />
|
||||
<action name="procReceiveTrackback" type="controller" />
|
||||
<action name="procDeleteTrackback" type="controller" />
|
||||
<action name="procVerificationPassword" type="controller" />
|
||||
<action name="procDeleteFile" type="controller" />
|
||||
<action name="procUploadFile" type="controller" />
|
||||
<action name="procDownload" type="controller" />
|
||||
<action name="procClearFile" type="controller" />
|
||||
<action name="procInsertGrant" type="controller" grant="root"/>
|
||||
<action name="procUpdateSkinInfo" type="controller" grant="root"/>
|
||||
<action name="procInsertBoard" type="controller" grant="root"/>
|
||||
<action name="procDeleteBoard" type="controller" grant="root"/>
|
||||
<action name="procInsertCategory" type="controller" grant="root"/>
|
||||
<action name="procUpdateCategory" type="controller" grant="root"/>
|
||||
</actions>
|
||||
</module>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<filter name="insert" module="board" act="procInsert" confirm_msg_code="confirm_submit">
|
||||
<filter name="insert" module="board" act="procInsertDocument" confirm_msg_code="confirm_submit">
|
||||
<form>
|
||||
<node target="document_srl" required="true" />
|
||||
<node target="user_name" required="true" />
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<node target="title" required="true" minlength="1" maxlength="250" />
|
||||
<node target="content" required="true" />
|
||||
</form>
|
||||
<response>
|
||||
<response callback_func="completeDocumentInserted">
|
||||
<tag name="error" />
|
||||
<tag name="message" />
|
||||
<tag name="mid" />
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
**/
|
||||
|
||||
/* 글쓰기 작성후 */
|
||||
function procInsert(ret_obj, response_tags) {
|
||||
function completeDocumentInserted(ret_obj) {
|
||||
var error = ret_obj['error'];
|
||||
var message = ret_obj['message'];
|
||||
var mid = ret_obj['mid'];
|
||||
|
|
@ -17,6 +17,13 @@ function procInsert(ret_obj, response_tags) {
|
|||
location.href = url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* 글 삭제 */
|
||||
function procDeleteDocument(ret_obj, response_tags) {
|
||||
var error = ret_obj['error'];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!--%import("filter/filter.insert.xml")-->
|
||||
<!--%import("filter/insert.xml")-->
|
||||
<!--#include("header.html")-->
|
||||
|
||||
<form action="./" method="post" onsubmit="return procFilter(this, insert)" <!--@if($grant->fileupload)-->enctype="multipart/form-data"<!--@end-->>
|
||||
|
|
|
|||
|
|
@ -185,14 +185,41 @@
|
|||
/**
|
||||
* @brief 해당 document의 조회수 증가
|
||||
**/
|
||||
function updateReadedCount($document_srl) {
|
||||
if($_SESSION['readed_document'][$document_srl]) return false;
|
||||
function updateReadedCount($document) {
|
||||
$document_srl = $document->document_srl;
|
||||
|
||||
// session에 정보로 조회수를 증가하였다고 생각하면 패스
|
||||
if($_SESSION['readed_document'][$document_srl]) return;
|
||||
|
||||
// member model 객체 생성
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
|
||||
// 글쓴이와 현재 로그인 사용자의 정보가 일치하면 읽었다고 생각하고 세션 등록후 패스
|
||||
if($member_srl && $member_srl == $document->member_srl) return $_SESSION['readed_document'][$document_srl] = true;
|
||||
|
||||
// DB 객체 생성
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->document_srl = $document_srl;
|
||||
// 로그인 사용자이면 member_srl, 비회원이면 ipaddress로 판단
|
||||
if($member_srl) {
|
||||
$args->member_srl = $member_srl;
|
||||
} else {
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
$output = $oDB->executeQuery('document.getDocumentReadedLogInfo', $args);
|
||||
|
||||
// 로그 정보에 조회 로그가 있으면 세션 등록후 패스
|
||||
if($output->data->count) return $_SESSION['readed_document'][$document_srl] = true;
|
||||
|
||||
// 조회수 업데이트
|
||||
$output = $oDB->executeQuery('document.updateReadedCount', $args);
|
||||
return $_SESSION['readed_document'][$document_srl] = true;
|
||||
|
||||
// 로그 남기기
|
||||
$output = $oDB->executeQuery('document.insertDocumentReadedLog', $args);
|
||||
|
||||
// 세션 정보에 남김
|
||||
$_SESSION['readed_document'][$document_srl] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,28 +23,61 @@
|
|||
/**
|
||||
* @brief 문서 가져오기
|
||||
**/
|
||||
function getDocument($document_srl) {
|
||||
function getDocument($document_srl, $is_admin=false, $get_extra_info=false) {
|
||||
// DB에서 가져옴
|
||||
$oDB = &DB::getInstance();
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $oDB->executeQuery('document.getDocument', $args);
|
||||
$document = $output->data;
|
||||
|
||||
if(!$get_extra_info) return $document;
|
||||
|
||||
// document controller 객체 생성
|
||||
$oDocumentController = &getController('document');
|
||||
|
||||
// 조회수 업데이트
|
||||
$oDocumentController->updateReadedCount($document);
|
||||
|
||||
// 이 문서에 대한 권한이 있는지 확인
|
||||
if($this->isGranted($document->document_srl)) {
|
||||
if($this->isGranted($document->document_srl) || $is_admin) {
|
||||
$document->is_granted = true;
|
||||
} elseif($document->member_srl) {
|
||||
$oMemberModel = &getMemberModel('member');
|
||||
$member_srl = $oMemberModel->getMemberSrl();
|
||||
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');
|
||||
}
|
||||
|
||||
// 댓글 가져오기
|
||||
if($document->comment_count && $document->allow_comment == 'Y') {
|
||||
$oCommentModel = &getModel('comment');
|
||||
$document->comment_list = $oCommentModel->getCommentList($document_srl);
|
||||
}
|
||||
|
||||
// 트랙백 가져오기
|
||||
if($document->trackback_count && $document->allow_trackback == 'Y') {
|
||||
$oTrackback = &getModule('trackback');
|
||||
$document->trackback_list = $oTrackback->getTrackbackList($document_srl);
|
||||
}
|
||||
|
||||
// 첨부파일 가져오기
|
||||
if($document->uploaded_count) {
|
||||
$oFileModel = &getModel('file');
|
||||
$file_list = $oFileModel->getFiles($document_srl);
|
||||
$document->uploaded_list = $file_list;
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 여러개의 문서들을 가져옴 (페이징 아님)
|
||||
**/
|
||||
function getDocuments($document_srl_list) {
|
||||
function getDocuments($document_srl_list, $is_admin=false) {
|
||||
if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list);
|
||||
|
||||
// DB에서 가져옴
|
||||
|
|
@ -63,7 +96,7 @@
|
|||
$document = $document_list[$i];
|
||||
$is_granted = false;
|
||||
|
||||
if($this->isGranted($document->document_srl)) {
|
||||
if($this->isGranted($document->document_srl) || $is_admin) {
|
||||
$is_granted = true;
|
||||
} elseif($member_srl && $member_srl == $document->member_srl) {
|
||||
$is_granted = true;
|
||||
|
|
@ -73,30 +106,79 @@
|
|||
return $document_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief module_srl값을 가지는 문서의 목록을 가져옴
|
||||
**/
|
||||
function getDocumentList($obj) {
|
||||
|
||||
// 검색 키워드가 있으면 공백을 % 로 변경하여 키워드 or 연산이 되도록 수정
|
||||
if($obj->keyword) $obj->keyword = str_replace(' ','%',$obj->keyword);
|
||||
|
||||
|
||||
if($obj->search_target && $obj->keyword) {
|
||||
switch($obj->search_target) {
|
||||
case 'title' :
|
||||
$search_obj->s_title = $obj->keyword;
|
||||
break;
|
||||
case 'content' :
|
||||
$search_obj->s_content = $obj->keyword;
|
||||
break;
|
||||
case 'title_content' :
|
||||
$search_obj->s_title = $obj->keyword;
|
||||
$search_obj->s_content = $obj->keyword;
|
||||
break;
|
||||
case 'user_name' :
|
||||
$search_obj->s_user_name = $obj->keyword;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// DB 객체 생성
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
// 변수 설정
|
||||
$args->module_srl = $obj->module_srl;
|
||||
$args->s_title = $obj->search_target=='title'?$obj->keyword:'';
|
||||
$args->s_content = $obj->search_target=='content'?$obj->keyword:'';
|
||||
$args->s_user_name = $obj->search_target=='user_name'?$obj->keyword:'';
|
||||
$args->s_member_srl = $obj->search_target=='member'?$obj->keyword:'';
|
||||
$args->s_ipaddress = $obj->search_target=='ipaddress'?$obj->keyword:'';
|
||||
$args->s_regdate = $obj->search_target=='regdate'?$obj->keyword:'';
|
||||
$args->category_srl = $obj->category_srl?$obj->category_srl:'';
|
||||
|
||||
$args->sort_index = $obj->sort_index;
|
||||
$args->page = $obj->page?$obj->page:1;
|
||||
$args->list_count = $obj->list_count?$obj->list_count:20;
|
||||
$args->page_count = $obj->page_count?$obj->page_count:10;
|
||||
|
||||
// document.getDocumentList 쿼리 실행
|
||||
$output = $oDB->executeQuery('document.getDocumentList', $args);
|
||||
|
||||
// 결과가 없거나 오류 발생시 그냥 return
|
||||
if(!$output->toBool()||!count($output->data)) return $output;
|
||||
|
||||
// 권한 체크
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getMemberSrl();
|
||||
|
||||
foreach($output->data as $key => $document) {
|
||||
$is_granted = false;
|
||||
|
||||
if($this->isGranted($document->document_srl) || $is_admin) $is_granted = true;
|
||||
elseif($member_srl && $member_srl == $document->member_srl) $is_granted = true;
|
||||
|
||||
$output->data[$key]->is_granted = $is_granted;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* @brief module_srl에 해당하는 문서의 전체 갯수를 가져옴
|
||||
**/
|
||||
function getDocumentCount($module_srl, $search_obj = NULL) {
|
||||
// DB 객체 생성
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->module_srl = $module_srl;
|
||||
$args->s_title = $search_obj->s_title;
|
||||
$args->s_content = $search_obj->s_content;
|
||||
$args->s_user_name = $search_obj->s_user_name;
|
||||
$args->s_member_srl = $search_obj->s_member_srl;
|
||||
$args->s_ipaddress = $search_obj->s_ipaddress;
|
||||
$args->s_regdate = $search_obj->s_regdate;
|
||||
$output = $oDB->executeQuery('document.getDocumentCount', $args);
|
||||
$total_count = $output->data->count;
|
||||
return (int)$total_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief module_srl값을 가지는 문서의 목록을 가져옴
|
||||
**/
|
||||
function getDocumentList($module_srl, $sort_index = 'list_order', $page = 1, $list_count = 20, $page_count = 10, $search_obj = NULL) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
// 검색 옵션 추가
|
||||
$args->module_srl = $module_srl;
|
||||
$args->s_title = $search_obj->s_title;
|
||||
$args->s_content = $search_obj->s_content;
|
||||
|
|
@ -106,39 +188,25 @@
|
|||
$args->s_regdate = $search_obj->s_regdate;
|
||||
$args->category_srl = $search_obj->category_srl;
|
||||
|
||||
$args->sort_index = $sort_index;
|
||||
$args->page = $page;
|
||||
$args->list_count = $list_count;
|
||||
$args->page_count = $page_count;
|
||||
$output = $oDB->executeQuery('document.getDocumentList', $args);
|
||||
$output = $oDB->executeQuery('document.getDocumentCount', $args);
|
||||
|
||||
if(!count($output->data)) return $output;
|
||||
|
||||
// 권한 체크
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getMemberSrl();
|
||||
|
||||
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;
|
||||
|
||||
$output->data[$key]->is_granted = $is_granted;
|
||||
}
|
||||
return $output;
|
||||
// 전체 갯수를 return
|
||||
$total_count = $output->data->count;
|
||||
return (int)$total_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 해당 document의 page 가져오기, module_srl이 없으면 전체에서..
|
||||
**/
|
||||
function getDocumentPage($document_srl, $module_srl=0, $list_count) {
|
||||
// DB 객체 생성
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
// 변수 설정
|
||||
$args->document_srl = $document_srl;
|
||||
$args->module_srl = $module_srl;
|
||||
$output = $oDB->executeQuery('document.getDocumentPage', $args);
|
||||
|
||||
// 전체 갯수를 구한후 해당 글의 페이지를 검색
|
||||
$output = $oDB->executeQuery('document.getDocumentPage', $args);
|
||||
$count = $output->data->count;
|
||||
$page = (int)(($count-1)/$list_count)+1;
|
||||
return $page;
|
||||
|
|
|
|||
|
|
@ -5,4 +5,6 @@
|
|||
* @desc : 문서(document) 모듈의 기본 언어팩
|
||||
**/
|
||||
$lang->msg_category_not_moved = "이동할 수가 없습니다";
|
||||
|
||||
$lang->msg_is_secret = '비밀글입니다';
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="equal" column="category_srl" var="category_srl" />
|
||||
<group pipe="and">
|
||||
<condition operation="like" column="title" var="s_title" />
|
||||
<condition operation="like" column="content" var="s_content" pipe="and" />
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
* @brief 첨부파일 추가
|
||||
**/
|
||||
function insertFile($module_srl, $document_srl) {
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
$file_info = Context::get('file');
|
||||
|
||||
// 정상적으로 업로드된 파일이 아니면 오류 출력
|
||||
|
|
@ -43,7 +41,10 @@
|
|||
|
||||
// 사용자 정보를 구함
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_srl = $oMemberModel->getMemberSrl();
|
||||
$member_srl = $oMemberModel->getLoggedMemberSrl();
|
||||
|
||||
// DB 객체 생성
|
||||
$oDB = &DB::getInstance();
|
||||
|
||||
// 파일 정보를 정리
|
||||
$args->file_srl = $oDB->getNextSequence();
|
||||
|
|
@ -55,9 +56,9 @@
|
|||
$args->file_size = filesize($filename);
|
||||
$args->comment = NULL;
|
||||
$args->member_srl = $member_srl;
|
||||
$args->sid = md5($args->source_filename);
|
||||
$args->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999)));
|
||||
|
||||
$output = $oDB->executeQuery('document.insertFile', $args);
|
||||
$output = $oDB->executeQuery('file.insertFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$output->add('file_srl', $args->file_srl);
|
||||
|
|
@ -74,7 +75,7 @@
|
|||
|
||||
// 파일 정보를 가져옴
|
||||
$args->file_srl = $file_srl;
|
||||
$output = $oDB->executeQuery('document.getFile', $args);
|
||||
$output = $oDB->executeQuery('file.getFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
$file_info = $output->data;
|
||||
if(!$file_info) return new Object(-1, 'file_not_founded');
|
||||
|
|
@ -83,7 +84,7 @@
|
|||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
|
||||
// DB에서 삭제
|
||||
$output = $oDB->executeQuery('document.deleteFile', $args);
|
||||
$output = $oDB->executeQuery('file.deleteFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// 삭제 성공하면 파일 삭제
|
||||
|
|
@ -99,7 +100,7 @@
|
|||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $oDB->executeQuery('document.deleteFiles', $args);
|
||||
$output = $oDB->executeQuery('file.deleteFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// 실제 파일 삭제
|
||||
|
|
@ -119,7 +120,7 @@
|
|||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->module_srl = $module_srl;
|
||||
$output = $oDB->executeQuery('document.deleteModuleFiles', $args);
|
||||
$output = $oDB->executeQuery('file.deleteModuleFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// 실제 파일 삭제
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->document_srl = $document_srl;
|
||||
$output = $oDB->executeQuery('document.getFilesCount', $args);
|
||||
$output = $oDB->executeQuery('file.getFilesCount', $args);
|
||||
return (int)$output->data->count;
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
$oDB = &DB::getInstance();
|
||||
|
||||
$args->file_srl = $file_srl;
|
||||
$output = $oDB->executeQuery('document.getFile', $args);
|
||||
$output = $oDB->executeQuery('file.getFile', $args);
|
||||
return $output->data;
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
$args->document_srl = $document_srl;
|
||||
$args->sort_index = 'file_srl';
|
||||
$output = $oDB->executeQuery('document.getFiles', $args);
|
||||
$output = $oDB->executeQuery('file.getFiles', $args);
|
||||
|
||||
$file_list = $output->data;
|
||||
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
// 이상이 없으면 download_count 증가
|
||||
$args->file_srl = $file_srl;
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->executeQuery('document.updateFileDownloadCount', $args);
|
||||
$oDB->executeQuery('file.updateFileDownloadCount', $args);
|
||||
|
||||
// 파일 출력
|
||||
$filename = $file_obj->source_filename;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue