git-svn-id: http://xe-core.googlecode.com/svn/trunk@979 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-04-05 06:05:05 +00:00
parent 2a9f617e1b
commit 959560097b
6 changed files with 128 additions and 19 deletions

View file

@ -87,7 +87,7 @@
* @brief 롤백 * @brief 롤백
**/ **/
function rollback() { function rollback() {
if(!$this->is_connected || $this->transaction_started) return; if(!$this->is_connected || !$this->transaction_started) return;
$this->_query("ROLLBACK;"); $this->_query("ROLLBACK;");
$this->transaction_started = false; $this->transaction_started = false;
} }
@ -96,7 +96,7 @@
* @brief 커밋 * @brief 커밋
**/ **/
function commit() { function commit() {
if(!$this->is_connected || $this->transaction_started) return; if(!$this->is_connected || !$this->transaction_started) return;
$this->_query("COMMIT;"); $this->_query("COMMIT;");
$this->transaction_started = false; $this->transaction_started = false;
} }

View file

@ -93,7 +93,7 @@
* @brief 롤백 * @brief 롤백
**/ **/
function rollback() { function rollback() {
if(!$this->is_connected || $this->transaction_started) return; if(!$this->is_connected || !$this->transaction_started) return;
$this->handler->rollBack(); $this->handler->rollBack();
$this->transaction_started = false; $this->transaction_started = false;
} }
@ -102,7 +102,7 @@
* @brief 커밋 * @brief 커밋
**/ **/
function commit() { function commit() {
if(!$this->is_connected || $this->transaction_started) return; if(!$this->is_connected || !$this->transaction_started) return;
$this->handler->commit(); $this->handler->commit();
$this->transaction_started = false; $this->transaction_started = false;
} }

View file

@ -54,10 +54,10 @@
// 컨텐츠 출력 // 컨텐츠 출력
if(Context::getResponseMethod()!="XMLRPC") { if(Context::getResponseMethod()!="XMLRPC") {
ini_set('zlib.output_compression_level',3); //ini_set('zlib.output_compression_level',3);
ob_start('ob_gzhandler'); //ob_start('ob_gzhandler');
print trim($output); print trim($output);
ob_end_flush(); //ob_end_flush();
} else { } else {
print trim($output); print trim($output);
} }

View file

@ -49,6 +49,7 @@
* @brief 댓글 입력 * @brief 댓글 입력
**/ **/
function insertComment($obj) { function insertComment($obj) {
// document_srl에 해당하는 글이 있는지 확인 // document_srl에 해당하는 글이 있는지 확인
$document_srl = $obj->document_srl; $document_srl = $obj->document_srl;
if(!$document_srl) return new Object(-1,'msg_invalid_document'); if(!$document_srl) return new Object(-1,'msg_invalid_document');
@ -75,6 +76,10 @@
$obj->homepage = $logged_info->homepage; $obj->homepage = $logged_info->homepage;
} }
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// file의 Model객체 생성 // file의 Model객체 생성
$oFileModel = &getModel('file'); $oFileModel = &getModel('file');
@ -85,7 +90,10 @@
$output = executeQuery('comment.insertComment', $obj); $output = executeQuery('comment.insertComment', $obj);
// 입력에 이상이 없으면 해당 글의 댓글 수를 올림 // 입력에 이상이 없으면 해당 글의 댓글 수를 올림
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// comment model객체 생성 // comment model객체 생성
$oCommentModel = &getModel('comment'); $oCommentModel = &getModel('comment');
@ -102,6 +110,9 @@
// 댓글의 권한을 부여 // 댓글의 권한을 부여
$this->addGrant($obj->comment_srl); $this->addGrant($obj->comment_srl);
// commit
$oDB->commit();
$output->add('comment_srl', $obj->comment_srl); $output->add('comment_srl', $obj->comment_srl);
return $output; return $output;
} }
@ -148,8 +159,19 @@
// 첨부 파일의 갯수를 구함 // 첨부 파일의 갯수를 구함
$obj->uploaded_count = $oFileModel->getFilesCount($obj->document_srl); $obj->uploaded_count = $oFileModel->getFilesCount($obj->document_srl);
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 업데이트 // 업데이트
$output = executeQuery('comment.updateComment', $obj); $output = executeQuery('comment.updateComment', $obj);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// commit
$oDB->commit();
$output->add('comment_srl', $obj->comment_srl); $output->add('comment_srl', $obj->comment_srl);
return $output; return $output;
@ -174,10 +196,17 @@
// 권한이 있는지 확인 // 권한이 있는지 확인
if(!$is_admin && !$comment->is_granted) return new Object(-1, 'msg_not_permitted'); if(!$is_admin && !$comment->is_granted) return new Object(-1, 'msg_not_permitted');
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 삭제 // 삭제
$args->comment_srl = $comment_srl; $args->comment_srl = $comment_srl;
$output = executeQuery('comment.deleteComment', $args); $output = executeQuery('comment.deleteComment', $args);
if(!$output->toBool()) return new Object(-1, 'msg_error_occured'); if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 첨부 파일 삭제 // 첨부 파일 삭제
if($comment->uploaded_count) { if($comment->uploaded_count) {
@ -193,6 +222,13 @@
// 해당글의 댓글 수를 업데이트 // 해당글의 댓글 수를 업데이트
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count); $output = $oDocumentController->updateCommentCount($document_srl, $comment_count);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// commit
$oDB->commit();
$output->add('document_srl', $document_srl); $output->add('document_srl', $document_srl);
return $output; return $output;

View file

@ -47,6 +47,11 @@
* @brief 문서 입력 * @brief 문서 입력
**/ **/
function insertDocument($obj) { function insertDocument($obj) {
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 기본 변수들 정리 // 기본 변수들 정리
if($obj->is_secret!='Y') $obj->is_secret = 'N'; if($obj->is_secret!='Y') $obj->is_secret = 'N';
if($obj->allow_comment!='Y') $obj->allow_comment = 'N'; if($obj->allow_comment!='Y') $obj->allow_comment = 'N';
@ -97,7 +102,10 @@
// DB에 입력 // DB에 입력
$output = executeQuery('document.insertDocument', $obj); $output = executeQuery('document.insertDocument', $obj);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 성공하였을 경우 category_srl이 있으면 카테고리 update // 성공하였을 경우 category_srl이 있으면 카테고리 update
if($obj->category_srl) $this->updateCategoryCount($obj->category_srl); if($obj->category_srl) $this->updateCategoryCount($obj->category_srl);
@ -112,6 +120,9 @@
$oFileController->setFilesValid($obj->document_srl); $oFileController->setFilesValid($obj->document_srl);
} }
// commit
$oDB->commit();
// return // return
$this->addGrant($obj->document_srl); $this->addGrant($obj->document_srl);
$output->add('document_srl',$obj->document_srl); $output->add('document_srl',$obj->document_srl);
@ -123,6 +134,11 @@
* @brief 문서 수정 * @brief 문서 수정
**/ **/
function updateDocument($source_obj, $obj) { function updateDocument($source_obj, $obj) {
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 기본 변수들 정리 // 기본 변수들 정리
if($obj->is_secret!='Y') $obj->is_secret = 'N'; if($obj->is_secret!='Y') $obj->is_secret = 'N';
if($obj->allow_comment!='Y') $obj->allow_comment = 'N'; if($obj->allow_comment!='Y') $obj->allow_comment = 'N';
@ -186,7 +202,11 @@
// DB에 입력 // DB에 입력
$output = executeQuery('document.updateDocument', $obj); $output = executeQuery('document.updateDocument', $obj);
if(!$output->toBool()) return $output;
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 성공하였을 경우 category_srl이 있으면 카테고리 update // 성공하였을 경우 category_srl이 있으면 카테고리 update
if($source_obj->category_srl!=$obj->category_srl) { if($source_obj->category_srl!=$obj->category_srl) {
@ -204,6 +224,9 @@
$oEditorController = &getController('editor'); $oEditorController = &getController('editor');
$oEditorController->deleteSavedDoc(); $oEditorController->deleteSavedDoc();
// commit
$oDB->commit();
$output->add('document_srl',$obj->document_srl); $output->add('document_srl',$obj->document_srl);
return $output; return $output;
} }
@ -213,6 +236,10 @@
**/ **/
function deleteDocument($document_srl, $is_admin = false) { function deleteDocument($document_srl, $is_admin = false) {
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// document의 model 객체 생성 // document의 model 객체 생성
$oDocumentModel = &getModel('document'); $oDocumentModel = &getModel('document');
@ -226,7 +253,10 @@
// 글 삭제 // 글 삭제
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$output = executeQuery('document.deleteDocument', $args); $output = executeQuery('document.deleteDocument', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 댓글 삭제 // 댓글 삭제
$oCommentController = &getController('comment'); $oCommentController = &getController('comment');
@ -249,6 +279,9 @@
// 카테고리가 있으면 카테고리 정보 변경 // 카테고리가 있으면 카테고리 정보 변경
if($document->category_srl) $this->updateCategoryCount($document->category_srl); if($document->category_srl) $this->updateCategoryCount($document->category_srl);
// commit
$oDB->commit();
return $output; return $output;
} }

View file

@ -87,6 +87,10 @@
* @brief 모듈 입력 * @brief 모듈 입력
**/ **/
function insertModule($args) { function insertModule($args) {
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// module model 객체 생성 // module model 객체 생성
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
@ -99,7 +103,13 @@
$args->module_srl = getNextSequence(); $args->module_srl = getNextSequence();
$args->skin_vars = serialize($skin_vars); $args->skin_vars = serialize($skin_vars);
$output = executeQuery('module.insertModule', $args); $output = executeQuery('module.insertModule', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// commit
$oDB->commit();
$output->add('module_srl',$args->module_srl); $output->add('module_srl',$args->module_srl);
return $output; return $output;
@ -161,6 +171,11 @@
* 모듈 삭제시는 관련 정보들을 모두 삭제 시도한다. * 모듈 삭제시는 관련 정보들을 모두 삭제 시도한다.
**/ **/
function deleteModule($module_srl) { function deleteModule($module_srl) {
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
$args->module_srl = $module_srl; $args->module_srl = $module_srl;
// addon 삭제 // addon 삭제
@ -170,34 +185,59 @@
// document 삭제 // document 삭제
$oDocumentController = &getController('document'); $oDocumentController = &getController('document');
$output = $oDocumentController->deleteModuleDocument($module_srl); $output = $oDocumentController->deleteModuleDocument($module_srl);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// category 삭제 // category 삭제
$output = $oDocumentController->deleteModuleCategory($module_srl); $output = $oDocumentController->deleteModuleCategory($module_srl);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// trackbacks 삭제 // trackbacks 삭제
$oTrackbackController = &getController('trackback'); $oTrackbackController = &getController('trackback');
$output = $oTrackbackController->deleteModuleTrackbacks($module_srl); $output = $oTrackbackController->deleteModuleTrackbacks($module_srl);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// comments 삭제 // comments 삭제
$oCommentController = &getController('comment'); $oCommentController = &getController('comment');
$output = $oCommentController->deleteModuleComments($module_srl); $output = $oCommentController->deleteModuleComments($module_srl);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// tags 삭제 // tags 삭제
$oTagController = &getController('tag'); $oTagController = &getController('tag');
$output = $oTagController->deleteModuleTags($module_srl); $output = $oTagController->deleteModuleTags($module_srl);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 첨부 파일 삭제 // 첨부 파일 삭제
$oFileController = &getController('file'); $oFileController = &getController('file');
$output = $oFileController->deleteModuleFiles($module_srl); $output = $oFileController->deleteModuleFiles($module_srl);
if(!$output->toBool()) return $output; if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// module 정보를 DB에서 삭제 // module 정보를 DB에서 삭제
$output = executeQuery('module.deleteModule', $args); $output = executeQuery('module.deleteModule', $args);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// commit
$oDB->commit();
return $output; return $output;
} }