mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2327 201d5d3c-b55e-5fd7-737f-ddc643e51545
226 lines
8.5 KiB
PHP
226 lines
8.5 KiB
PHP
<?php
|
|
/**
|
|
* @class blogController
|
|
* @author zero (zero@nzeo.com)
|
|
* @brief blog 모듈의 Controller class
|
|
**/
|
|
|
|
class blogController extends blog {
|
|
|
|
/**
|
|
* @brief 초기화
|
|
**/
|
|
function init() {
|
|
}
|
|
|
|
/**
|
|
* @brief 문서 입력
|
|
**/
|
|
function procBlogInsertDocument() {
|
|
// 권한 체크
|
|
if(!$this->grant->write_document) return new Object(-1, 'msg_not_permitted');
|
|
|
|
// 글작성시 필요한 변수를 세팅
|
|
$obj = Context::getRequestVars();
|
|
$obj->module_srl = $this->module_srl;
|
|
if($obj->is_notice!='Y'||!$this->grant->manager) $obj->is_notice = 'N';
|
|
|
|
// document module의 model 객체 생성
|
|
$oDocumentModel = &getModel('document');
|
|
|
|
// document module의 controller 객체 생성
|
|
$oDocumentController = &getController('document');
|
|
|
|
// 이미 존재하는 글인지 체크
|
|
$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
|
|
|
|
// 이미 존재하는 경우 수정
|
|
if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) {
|
|
$output = $oDocumentController->updateDocument($oDocument, $obj);
|
|
$msg_code = 'success_updated';
|
|
|
|
// 그렇지 않으면 신규 등록
|
|
} else {
|
|
$output = $oDocumentController->insertDocument($obj);
|
|
$msg_code = 'success_registed';
|
|
$obj->document_srl = $output->get('document_srl');
|
|
}
|
|
|
|
// 오류 발생시 멈춤
|
|
if(!$output->toBool()) return $output;
|
|
|
|
// 트랙백이 있으면 트랙백 발송
|
|
$trackback_url = Context::get('trackback_url');
|
|
$trackback_charset = Context::get('trackback_charset');
|
|
if($trackback_url) {
|
|
$oTrackbackController = &getController('trackback');
|
|
$oTrackbackController->sendTrackback($obj, $trackback_url, $trackback_charset);
|
|
}
|
|
|
|
// 결과를 리턴
|
|
$this->add('mid', Context::get('mid'));
|
|
$this->add('document_srl', $output->get('document_srl'));
|
|
|
|
// 성공 메세지 등록
|
|
$this->setMessage($msg_code);
|
|
}
|
|
|
|
/**
|
|
* @brief 문서 삭제
|
|
**/
|
|
function procBlogDeleteDocument() {
|
|
// 문서 번호 확인
|
|
$document_srl = Context::get('document_srl');
|
|
|
|
// 문서 번호가 없다면 오류 발생
|
|
if(!$document_srl) return $this->doError('msg_invalid_document');
|
|
|
|
// document module model 객체 생성
|
|
$oDocumentController = &getController('document');
|
|
|
|
// 삭제 시도
|
|
$output = $oDocumentController->deleteDocument($document_srl, $this->grant->manager);
|
|
if(!$output->toBool()) return $output;
|
|
|
|
// 성공 메세지 등록
|
|
$this->add('mid', Context::get('mid'));
|
|
$this->add('page', $output->get('page'));
|
|
$this->setMessage('success_deleted');
|
|
}
|
|
|
|
/**
|
|
* @brief 코멘트 추가
|
|
**/
|
|
function procBlogInsertComment() {
|
|
// 권한 체크
|
|
if(!$this->grant->write_comment) return new Object(-1, 'msg_not_permitted');
|
|
|
|
// 댓글 입력에 필요한 데이터 추출
|
|
$obj = Context::gets('document_srl','comment_srl','parent_srl','content','password','nick_name','nick_name','member_srl','email_address','homepage');
|
|
$obj->module_srl = $this->module_srl;
|
|
|
|
// comment 모듈의 model 객체 생성
|
|
$oCommentModel = &getModel('comment');
|
|
|
|
// comment 모듈의 controller 객체 생성
|
|
$oCommentController = &getController('comment');
|
|
|
|
// 줄바꾸임나 태그제거등의 작업
|
|
$obj->content = nl2br(strip_tags($obj->content));
|
|
|
|
/**
|
|
* 존재하는 댓글인지를 확인하여 존재 하지 않는 댓글이라면 신규로 등록하기 위해서 comment_srl의 sequence값을 받는다
|
|
**/
|
|
if(!$obj->comment_srl) {
|
|
$obj->comment_srl = getNextSequence();
|
|
} else {
|
|
$comment = $oCommentModel->getComment($obj->comment_srl, $this->grant->manager);
|
|
}
|
|
|
|
// comment_srl이 없을 경우 신규 입력
|
|
if($comment->comment_srl != $obj->comment_srl) {
|
|
|
|
// parent_srl이 있으면 답변으로
|
|
if($obj->parent_srl) {
|
|
$parent_comment = $oCommentModel->getComment($obj->parent_srl);
|
|
if(!$parent_comment->comment_srl) return new Object(-1, 'msg_invalid_request');
|
|
|
|
$output = $oCommentController->insertComment($obj);
|
|
|
|
// 없으면 신규
|
|
} else {
|
|
$output = $oCommentController->insertComment($obj);
|
|
}
|
|
|
|
// comment_srl이 있으면 수정으로
|
|
} else {
|
|
$obj->parent_srl = $comment->parent_srl;
|
|
$output = $oCommentController->updateComment($obj, $this->grant->manager);
|
|
$comment_srl = $obj->comment_srl;
|
|
}
|
|
|
|
if(!$output->toBool()) return $output;
|
|
|
|
$this->add('mid', Context::get('mid'));
|
|
$this->add('document_srl', $obj->document_srl);
|
|
$this->add('comment_srl', $obj->comment_srl);
|
|
|
|
$this->setMessage('success_registed');
|
|
}
|
|
|
|
/**
|
|
* @brief 코멘트 삭제
|
|
**/
|
|
function procBlogDeleteComment() {
|
|
// 댓글 번호 확인
|
|
$comment_srl = Context::get('comment_srl');
|
|
if(!$comment_srl) return $this->doError('msg_invalid_request');
|
|
|
|
// comment 모듈의 controller 객체 생성
|
|
$oCommentController = &getController('comment');
|
|
|
|
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
|
|
if(!$output->toBool()) return $output;
|
|
|
|
$this->add('mid', Context::get('mid'));
|
|
$this->add('page', Context::get('page'));
|
|
$this->add('document_srl', $output->get('document_srl'));
|
|
$this->setMessage('success_deleted');
|
|
}
|
|
|
|
/**
|
|
* @brief 엮인글 삭제
|
|
**/
|
|
function procBlogDeleteTrackback() {
|
|
$trackback_srl = Context::get('trackback_srl');
|
|
|
|
// trackback module의 controller 객체 생성
|
|
$oTrackbackController = &getController('trackback');
|
|
$output = $oTrackbackController->deleteTrackback($trackback_srl, $this->grant->manager);
|
|
if(!$output->toBool()) return $output;
|
|
|
|
$this->add('mid', Context::get('mid'));
|
|
$this->add('page', Context::get('page'));
|
|
$this->add('document_srl', $output->get('document_srl'));
|
|
$this->setMessage('success_deleted');
|
|
}
|
|
|
|
/**
|
|
* @brief 문서와 댓글의 비밀번호를 확인
|
|
**/
|
|
function procBlogVerificationPassword() {
|
|
// 비밀번호와 문서 번호를 받음
|
|
$password = md5(Context::get('password'));
|
|
$document_srl = Context::get('document_srl');
|
|
$comment_srl = Context::get('comment_srl');
|
|
|
|
// comment_srl이 있을 경우 댓글이 대상
|
|
if($comment_srl) {
|
|
// 문서번호에 해당하는 글이 있는지 확인
|
|
$oCommentModel = &getModel('comment');
|
|
$data = $oCommentModel->getComment($comment_srl);
|
|
// comment_srl이 없으면 문서가 대상
|
|
} else {
|
|
// 문서번호에 해당하는 글이 있는지 확인
|
|
$oDocumentModel = &getModel('document');
|
|
$data = $oDocumentModel->getDocument($document_srl);
|
|
}
|
|
|
|
// 글이 없을 경우 에러
|
|
if(!$data) return new Object(-1, 'msg_invalid_request');
|
|
|
|
// 문서의 비밀번호와 입력한 비밀번호의 비교
|
|
if($data->password != $password) return new Object(-1, 'msg_invalid_password');
|
|
|
|
// 해당 글에 대한 권한 부여
|
|
if($comment_srl) {
|
|
$oCommentController = &getController('comment');
|
|
$oCommentController->addGrant($comment_srl);
|
|
} else {
|
|
$oDocumentController = &getController('document');
|
|
$oDocumentController->addGrant($document_srl);
|
|
}
|
|
}
|
|
|
|
}
|
|
?>
|