#17763731 : Added a feature, comment, to wiki

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5842 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2009-03-11 05:04:20 +00:00
parent b386bd7c44
commit 173955e8f9
19 changed files with 566 additions and 1 deletions

View file

@ -13,6 +13,15 @@
// 글작성시 필요한 변수를 세팅
$obj = Context::getRequestVars();
$obj->module_srl = $this->module_srl;
if($this->module_info->use_comment != 'N')
{
$obj->allow_comment = 'Y';
}
else
{
$obj->allow_comment = 'N';
}
if(!$obj->nick_name) $obj->nick_name = "anonymous";
if($obj->is_notice!='Y'||!$this->grant->manager) $obj->is_notice = 'N';
@ -53,6 +62,98 @@
// 성공 메세지 등록
$this->setMessage($msg_code);
}
function procWikiInsertComment() {
// 권한 체크
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','is_secret','notify_message');
$obj->module_srl = $this->module_srl;
// 원글이 존재하는지 체크
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($obj->document_srl);
if(!$oDocument->isExists()) return new Object(-1,'msg_not_permitted');
// comment 모듈의 model 객체 생성
$oCommentModel = &getModel('comment');
// comment 모듈의 controller 객체 생성
$oCommentController = &getController('comment');
// comment_srl이 존재하는지 체크
// 만일 comment_srl이 n/a라면 getNextSequence()로 값을 얻어온다.
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);
}
// 문제가 없고 모듈 설정에 관리자 메일이 등록되어 있으면 메일 발송
if($output->toBool() && $this->module_info->admin_mail) {
$oMail = new Mail();
$oMail->setTitle($oDocument->getTitleText());
$oMail->setContent( sprintf("From : <a href=\"%s#comment_%d\">%s#comment_%d</a><br/>\r\n%s", $oDocument->getPermanentUrl(), $obj->comment_srl, $oDocument->getPermanentUrl(), $obj->comment_srl, $obj->content));
$oMail->setSender($obj->user_name, $obj->email_address);
$target_mail = explode(',',$this->module_info->admin_mail);
for($i=0;$i<count($target_mail);$i++) {
$email_address = trim($target_mail[$i]);
if(!$email_address) continue;
$oMail->setReceiptor($email_address, $email_address);
$oMail->send();
}
}
// 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->setMessage('success_registed');
$this->add('mid', Context::get('mid'));
$this->add('document_srl', $obj->document_srl);
$this->add('comment_srl', $obj->comment_srl);
}
function procWikiDeleteComment() {
// check the comment's sequence number
debugPrint('here');
$comment_srl = Context::get('comment_srl');
if(!$comment_srl) return $this->doError('msg_invalid_request');
// create controller object of comment module
$oCommentController = &getController('comment');
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
debugPrint($output);
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');
}
}
?>