diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 65fe91113..afef70e9a 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -137,7 +137,8 @@ $oTagController->deleteTag($document_srl); // 첨부 파일 삭제 - if($document->uploaded_count) $this->deleteFiles($document->module_srl, $document_srl); + $oFileController = getController('file'); + if($document->uploaded_count) $oFileController->deleteFiles($document->module_srl, $document_srl); // 카테고리가 있으면 카테고리 정보 변경 if($document->category_srl) $this->updateCategoryCount($document->category_srl); @@ -368,123 +369,5 @@ return new Object(); } - /** - * @brief 첨부파일 추가 - **/ - function insertFile($module_srl, $document_srl) { - $oDB = &DB::getInstance(); - - $file_info = Context::get('file'); - - // 정상적으로 업로드된 파일이 아니면 오류 출력 - if(!is_uploaded_file($file_info['tmp_name'])) return false; - - // 이미지인지 기타 파일인지 체크하여 upload path 지정 - if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info['name'])) { - $path = sprintf("./files/attach/images/%s/%s/", $module_srl,$document_srl); - $filename = $path.$file_info['name']; - $direct_download = 'Y'; - } else { - $path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); - $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); - $direct_download = 'N'; - } - - // 디렉토리 생성 - if(!FileHandler::makeDir($path)) return false; - - // 파일 이동 - if(!move_uploaded_file($file_info['tmp_name'], $filename)) return false; - - // 사용자 정보를 구함 - $oMemberModel = getModel('member'); - $member_srl = $oMemberModel->getMemberSrl(); - - // 파일 정보를 정리 - $args->file_srl = $oDB->getNextSequence(); - $args->document_srl = $document_srl; - $args->module_srl = $module_srl; - $args->direct_download = $direct_download; - $args->source_filename = $file_info['name']; - $args->uploaded_filename = $filename; - $args->file_size = filesize($filename); - $args->comment = NULL; - $args->member_srl = $member_srl; - $args->sid = md5($args->source_filename); - - $output = $oDB->executeQuery('document.insertFile', $args); - if(!$output->toBool()) return $output; - - $output->add('file_srl', $args->file_srl); - $output->add('file_size', $args->file_size); - $output->add('source_filename', $args->source_filename); - return $output; - } - - /** - * @brief 첨부파일 삭제 - **/ - function deleteFile($file_srl) { - $oDB = &DB::getInstance(); - - // 파일 정보를 가져옴 - $args->file_srl = $file_srl; - $output = $oDB->executeQuery('document.getFile', $args); - if(!$output->toBool()) return $output; - $file_info = $output->data; - if(!$file_info) return new Object(-1, 'file_not_founded'); - - $source_filename = $output->data->source_filename; - $uploaded_filename = $output->data->uploaded_filename; - - // DB에서 삭제 - $output = $oDB->executeQuery('document.deleteFile', $args); - if(!$output->toBool()) return $output; - - // 삭제 성공하면 파일 삭제 - unlink($uploaded_filename); - - return $output; - } - - /** - * @brief 특정 문서의 첨부파일을 모두 삭제 - **/ - function deleteFiles($module_srl, $document_srl) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.deleteFiles', $args); - if(!$output->toBool()) return $output; - - // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl); - $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); - - FileHandler::removeDir($path[0]); - FileHandler::removeDir($path[1]); - - return $output; - } - - /** - * @brief 특정 모두의 첨부파일 모두 삭제 - **/ - function deleteModuleFiles($module_srl) { - $oDB = &DB::getInstance(); - - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.deleteModuleFiles', $args); - if(!$output->toBool()) return $output; - - // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/", $module_srl); - $path[1] = sprintf("./files/attach/binaries/%s/", $module_srl); - FileHandler::removeDir($path[0]); - FileHandler::removeDir($path[1]); - - return $output; - } - } ?> diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 08d948716..fea580a49 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -189,54 +189,6 @@ return (int)$output->data->count; } - /** - * @brief 특정 문서에 속한 첨부파일의 개수를 return - **/ - function getFilesCount($document_srl) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.getFilesCount', $args); - return (int)$output->data->count; - } - - /** - * @brief 파일 정보를 구함 - **/ - function getFile($file_srl) { - $oDB = &DB::getInstance(); - - $args->file_srl = $file_srl; - $output = $oDB->executeQuery('document.getFile', $args); - return $output->data; - } - - /** - * @brief 특정 문서에 속한 파일을 모두 return - **/ - function getFiles($document_srl) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $args->sort_index = 'file_srl'; - $output = $oDB->executeQuery('document.getFiles', $args); - - $file_list = $output->data; - - if($file_list && !is_array($file_list)) $file_list = array($file_list); - - for($i=0;$idirect_download; - - if($direct_download!='Y') continue; - - $uploaded_filename = Context::getRequestUri().substr($file_list[$i]->uploaded_filename,2); - - $file_list[$i]->uploaded_filename = $uploaded_filename; - } - return $file_list; - } - /** * @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경 **/ diff --git a/modules/document/queries/deleteFile.xml b/modules/document/queries/deleteFile.xml deleted file mode 100644 index 3584ea182..000000000 --- a/modules/document/queries/deleteFile.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/modules/document/queries/deleteFiles.xml b/modules/document/queries/deleteFiles.xml deleted file mode 100644 index d4ee8b8df..000000000 --- a/modules/document/queries/deleteFiles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/document/queries/deleteModuleFiles.xml b/modules/document/queries/deleteModuleFiles.xml deleted file mode 100644 index f2f7c2ad7..000000000 --- a/modules/document/queries/deleteModuleFiles.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/document/queries/getFile.xml b/modules/document/queries/getFile.xml deleted file mode 100644 index deb35b994..000000000 --- a/modules/document/queries/getFile.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/document/queries/getFiles.xml b/modules/document/queries/getFiles.xml deleted file mode 100644 index d4e1510f9..000000000 --- a/modules/document/queries/getFiles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/document/queries/getFilesCount.xml b/modules/document/queries/getFilesCount.xml deleted file mode 100644 index a03e6a3e0..000000000 --- a/modules/document/queries/getFilesCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/document/queries/insertFile.xml b/modules/document/queries/insertFile.xml deleted file mode 100644 index 873310014..000000000 --- a/modules/document/queries/insertFile.xml +++ /dev/null @@ -1,20 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - diff --git a/modules/document/queries/updateFileDownloadCount.xml b/modules/document/queries/updateFileDownloadCount.xml deleted file mode 100644 index 251291af2..000000000 --- a/modules/document/queries/updateFileDownloadCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/document/schemas/files.xml b/modules/document/schemas/files.xml deleted file mode 100644 index 5ee2ee2a8..000000000 --- a/modules/document/schemas/files.xml +++ /dev/null @@ -1,16 +0,0 @@ -
- - - - - - - - - - - - - - -
diff --git a/modules/file/conf/info.xml b/modules/file/conf/info.xml index d8bf37a17..d80c3f225 100644 --- a/modules/file/conf/info.xml +++ b/modules/file/conf/info.xml @@ -1,11 +1,11 @@ - 문서 - document + 파일 + file 제로 zero - 문서 모듈 - document + 파일 관리 모듈 + file manager diff --git a/modules/file/document.controller.php b/modules/file/document.controller.php deleted file mode 100644 index 65fe91113..000000000 --- a/modules/file/document.controller.php +++ /dev/null @@ -1,490 +0,0 @@ -category_srl) { - $category_list = $this->getCategoryList($obj->module_srl); - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; - } - - // 태그 처리 - $oTagController = getController('tag'); - $obj->tags = $oTagController->insertTag($obj->module_srl, $obj->document_srl, $obj->tags); - - // 글 입력 - $obj->readed_count = 0; - $obj->update_order = $obj->list_order = $obj->document_srl * -1; - if($obj->password) $obj->password = md5($obj->password); - - // 공지사항일 경우 list_order에 무지막지한 값;;을 입력 - if($obj->is_notice=='Y') $obj->list_order = $this->notice_list_order; - - // DB에 입력 - $output = $oDB->executeQuery('document.insertDocument', $obj); - - if(!$output->toBool()) return $output; - - // 성공하였을 경우 category_srl이 있으면 카테고리 update - if($obj->category_srl) $this->updateCategoryCount($obj->category_srl); - - // return - $this->addGrant($obj->document_srl); - $output->add('document_srl',$obj->document_srl); - $output->add('category_srl',$obj->category_srl); - return $output; - } - - /** - * @brief 문서 수정 - **/ - function updateDocument($source_obj, $obj) { - // 카테고리가 변경되었으면 검사후 없는 카테고리면 0으로 세팅 - if($source_obj->category_srl!=$obj->category_srl) { - $category_list = $this->getCategoryList($obj->module_srl); - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; - } - - // 태그 처리 - $oTagController = getController('tag'); - $obj->tags = $oTagController->insertTag($obj->module_srl, $obj->document_srl, $obj->tags); - - // 수정 - $oDB = &DB::getInstance(); - $obj->update_order = $oDB->getNextSequence() * -1; - - // 공지사항일 경우 list_order에 무지막지한 값을, 그렇지 않으면 document_srl*-1값을 - if($obj->is_notice=='Y') $obj->list_order = $this->notice_list_order; - else $obj->list_order = $obj->document_srl*-1; - - if($obj->password) $obj->password = md5($obj->password); - - // DB에 입력 - $output = $oDB->executeQuery('document.updateDocument', $obj); - - if(!$output->toBool()) return $output; - - // 성공하였을 경우 category_srl이 있으면 카테고리 update - if($source_obj->category_srl!=$obj->category_srl) { - if($source_obj->category_srl) $this->updateCategoryCount($source_obj->category_srl); - if($obj->category_srl) $this->updateCategoryCount($obj->category_srl); - } - - $output->add('document_srl',$obj->document_srl); - return $output; - } - - /** - * @brief 문서 삭제 - **/ - function deleteDocument($obj) { - // 변수 세팅 - $document_srl = $obj->document_srl; - $category_srl = $obj->category_srl; - - // document의 model 객체 생성 - $oDocumentModel = getModel('document'); - - // 기존 문서가 있는지 확인 - $document = $oDocumentModel->getDocument($document_srl); - if($document->document_srl != $document_srl) return false; - - // 권한이 있는지 확인 - if(!$document->is_granted) return new Object(-1, 'msg_not_permitted'); - - $oDB = &DB::getInstance(); - - // 글 삭제 - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.deleteDocument', $args); - if(!$output->toBool()) return $output; - - // 댓글 삭제 - $oCommentController = getController('comment'); - $output = $oCommentController->deleteComments($document_srl); - - // 엮인글 삭제 - $oTrackbackController = getController('trackback'); - $output = $oTrackbackController->deleteTrackbacks($document_srl); - - // 태그 삭제 - $oTagController = getController('tag'); - $oTagController->deleteTag($document_srl); - - // 첨부 파일 삭제 - if($document->uploaded_count) $this->deleteFiles($document->module_srl, $document_srl); - - // 카테고리가 있으면 카테고리 정보 변경 - if($document->category_srl) $this->updateCategoryCount($document->category_srl); - - return $output; - } - - /** - * @brief 특정 모듈의 전체 문서 삭제 - **/ - function deleteModuleDocument($module_srl) { - $oDB = &DB::getInstance(); - - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.deleteModuleDocument', $args); - return $output; - } - - /** - * @brief 해당 document의 조회수 증가 - **/ - function updateReadedCount($document_srl) { - if($_SESSION['readed_document'][$document_srl]) return false; - - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.updateReadedCount', $args); - return $_SESSION['readed_document'][$document_srl] = true; - } - - /** - * @brief 해당 document의 추천수 증가 - **/ - function updateVotedCount($document_srl) { - if($_SESSION['voted_document'][$document_srl]) return new Object(-1, 'failed_voted'); - - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.updateVotedCount', $args); - - $_SESSION['voted_document'][$document_srl] = true; - - return $output; - } - - /** - * @brief 해당 document의 댓글 수 증가 - **/ - function updateCommentCount($document_srl, $comment_count) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $args->comment_count = $comment_count; - - return $oDB->executeQuery('document.updateCommentCount', $args); - } - - /** - * @brief 해당 document의 엮인글 수증가 - **/ - function updateTrackbackCount($document_srl, $trackback_count) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $args->trackback_count = $trackback_count; - - return $oDB->executeQuery('document.updateTrackbackCount', $args); - } - - /** - * @brief 카테고리 추가 - **/ - function insertCategory($module_srl, $title) { - $oDB = &DB::getInstance(); - - $args->list_order = $args->category_srl = $oDB->getNextSequence(); - $args->module_srl = $module_srl; - $args->title = $title; - $args->document_count = 0; - - return $oDB->executeQuery('document.insertCategory', $args); - } - - /** - * @brief 카테고리 정보 수정 - **/ - function updateCategory($args) { - $oDB = &DB::getInstance(); - return $oDB->executeQuery('document.updateCategory', $args); - } - - /** - * @brief 카테고리에 문서의 숫자를 변경 - **/ - function updateCategoryCount($category_srl, $document_count = 0) { - // document model 객체 생성 - $oDocumentModel = getModel('document'); - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($category_srl); - - $oDB = &DB::getInstance(); - - $args->category_srl = $category_srl; - $args->document_count = $document_count; - return $oDB->executeQuery('document.updateCategoryCount', $args); - } - - /** - * @brief 카테고리 삭제 - **/ - function deleteCategory($category_srl) { - $oDB = &DB::getInstance(); - - $args->category_srl = $category_srl; - - // 카테고리 정보를 삭제 - $output = $oDB->executeQuery('document.deleteCategory', $args); - if(!$output->toBool()) return $output; - - // 현 카테고리 값을 가지는 문서들의 category_srl을 0 으로 세팅 - unset($args); - - $args->target_category_srl = 0; - $args->source_category_srl = $category_srl; - $output = $oDB->executeQuery('document.updateDocumentCategory', $args); - return $output; - } - - /** - * @brief 특정 모듈의 카테고리를 모두 삭제 - **/ - function deleteModuleCategory($module_srl) { - $oDB = &DB::getInstance(); - - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.deleteModuleCategory', $args); - return $output; - } - - /** - * @brief 카테고리를 상단으로 이동 - **/ - function moveCategoryUp($category_srl) { - $oDB = &DB::getInstance(); - $oDocumentModel = getModel('document'); - - // 선택된 카테고리의 정보를 구한다 - $args->category_srl = $category_srl; - $output = $oDB->executeQuery('document.getCategory', $args); - - $category = $output->data; - $list_order = $category->list_order; - $module_srl = $category->module_srl; - - // 전체 카테고리 목록을 구한다 - $category_list = $oDocumentModel->getCategoryList($module_srl); - $category_srl_list = array_keys($category_list); - if(count($category_srl_list)<2) return new Object(); - - $prev_category = NULL; - foreach($category_list as $key => $val) { - if($key==$category_srl) break; - $prev_category = $val; - } - - // 이전 카테고리가 없으면 그냥 return - if(!$prev_category) return new Object(-1,Context::getLang('msg_category_not_moved')); - - // 선택한 카테고리가 가장 위의 카테고리이면 그냥 return - if($category_srl_list[0]==$category_srl) return new Object(-1,Context::getLang('msg_category_not_moved')); - - // 선택한 카테고리의 정보 - $cur_args->category_srl = $category_srl; - $cur_args->list_order = $prev_category->list_order; - $cur_args->title = $category->title; - $this->updateCategory($cur_args); - - // 대상 카테고리의 정보 - $prev_args->category_srl = $prev_category->category_srl; - $prev_args->list_order = $list_order; - $prev_args->title = $prev_category->title; - $this->updateCategory($prev_args); - - return new Object(); - } - - /** - * @brief 카테고리를 아래로 이동 - **/ - function moveCategoryDown($category_srl) { - $oDB = &DB::getInstance(); - $oDocumentModel = getModel('document'); - - // 선택된 카테고리의 정보를 구한다 - $args->category_srl = $category_srl; - $output = $oDB->executeQuery('document.getCategory', $args); - - $category = $output->data; - $list_order = $category->list_order; - $module_srl = $category->module_srl; - - // 전체 카테고리 목록을 구한다 - $category_list = $oDocumentModel->getCategoryList($module_srl); - $category_srl_list = array_keys($category_list); - if(count($category_srl_list)<2) return new Object(); - - for($i=0;$icategory_srl = $category_srl; - $cur_args->list_order = $next_category->list_order; - $cur_args->title = $category->title; - $this->updateCategory($cur_args); - - // 대상 카테고리의 정보 - $next_args->category_srl = $next_category->category_srl; - $next_args->list_order = $list_order; - $next_args->title = $next_category->title; - $this->updateCategory($next_args); - - return new Object(); - } - - /** - * @brief 첨부파일 추가 - **/ - function insertFile($module_srl, $document_srl) { - $oDB = &DB::getInstance(); - - $file_info = Context::get('file'); - - // 정상적으로 업로드된 파일이 아니면 오류 출력 - if(!is_uploaded_file($file_info['tmp_name'])) return false; - - // 이미지인지 기타 파일인지 체크하여 upload path 지정 - if(eregi("\.(jpg|jpeg|gif|png|wmv|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi)$", $file_info['name'])) { - $path = sprintf("./files/attach/images/%s/%s/", $module_srl,$document_srl); - $filename = $path.$file_info['name']; - $direct_download = 'Y'; - } else { - $path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); - $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100))); - $direct_download = 'N'; - } - - // 디렉토리 생성 - if(!FileHandler::makeDir($path)) return false; - - // 파일 이동 - if(!move_uploaded_file($file_info['tmp_name'], $filename)) return false; - - // 사용자 정보를 구함 - $oMemberModel = getModel('member'); - $member_srl = $oMemberModel->getMemberSrl(); - - // 파일 정보를 정리 - $args->file_srl = $oDB->getNextSequence(); - $args->document_srl = $document_srl; - $args->module_srl = $module_srl; - $args->direct_download = $direct_download; - $args->source_filename = $file_info['name']; - $args->uploaded_filename = $filename; - $args->file_size = filesize($filename); - $args->comment = NULL; - $args->member_srl = $member_srl; - $args->sid = md5($args->source_filename); - - $output = $oDB->executeQuery('document.insertFile', $args); - if(!$output->toBool()) return $output; - - $output->add('file_srl', $args->file_srl); - $output->add('file_size', $args->file_size); - $output->add('source_filename', $args->source_filename); - return $output; - } - - /** - * @brief 첨부파일 삭제 - **/ - function deleteFile($file_srl) { - $oDB = &DB::getInstance(); - - // 파일 정보를 가져옴 - $args->file_srl = $file_srl; - $output = $oDB->executeQuery('document.getFile', $args); - if(!$output->toBool()) return $output; - $file_info = $output->data; - if(!$file_info) return new Object(-1, 'file_not_founded'); - - $source_filename = $output->data->source_filename; - $uploaded_filename = $output->data->uploaded_filename; - - // DB에서 삭제 - $output = $oDB->executeQuery('document.deleteFile', $args); - if(!$output->toBool()) return $output; - - // 삭제 성공하면 파일 삭제 - unlink($uploaded_filename); - - return $output; - } - - /** - * @brief 특정 문서의 첨부파일을 모두 삭제 - **/ - function deleteFiles($module_srl, $document_srl) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.deleteFiles', $args); - if(!$output->toBool()) return $output; - - // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl); - $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); - - FileHandler::removeDir($path[0]); - FileHandler::removeDir($path[1]); - - return $output; - } - - /** - * @brief 특정 모두의 첨부파일 모두 삭제 - **/ - function deleteModuleFiles($module_srl) { - $oDB = &DB::getInstance(); - - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.deleteModuleFiles', $args); - if(!$output->toBool()) return $output; - - // 실제 파일 삭제 - $path[0] = sprintf("./files/attach/images/%s/", $module_srl); - $path[1] = sprintf("./files/attach/binaries/%s/", $module_srl); - FileHandler::removeDir($path[0]); - FileHandler::removeDir($path[1]); - - return $output; - } - - } -?> diff --git a/modules/file/document.model.php b/modules/file/document.model.php deleted file mode 100644 index 08d948716..000000000 --- a/modules/file/document.model.php +++ /dev/null @@ -1,276 +0,0 @@ -document_srl = $document_srl; - $output = $oDB->executeQuery('document.getDocument', $args); - $document = $output->data; - - // 이 문서에 대한 권한이 있는지 확인 - if($this->isGranted($document->document_srl)) { - $document->is_granted = true; - } elseif($document->member_srl) { - $oMember = getModule('member'); - $member_srl = $oMember->getMemberSrl(); - if($member_srl && $member_srl ==$document->member_srl) $document->is_granted = true; - } - return $document; - } - - /** - * @brief 여러개의 문서들을 가져옴 (페이징 아님) - **/ - function getDocuments($document_srl_list) { - if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list); - - // DB에서 가져옴 - $oDB = &DB::getInstance(); - $args->document_srls = $document_srls; - $output = $oDB->executeQuery('document.getDocuments', $args); - $document_list = $output->data; - if(!$document_list) return; - - // 권한 체크 - $oMemberModel = getModel('member'); - $member_srl = $oMemberModel->getMemberSrl(); - - $document_count = count($document_list); - for($i=0;$i<$document_count;$i++) { - $document = $document_list[$i]; - $is_granted = false; - - if($this->isGranted($document->document_srl)) { - $is_granted = true; - } elseif($member_srl && $member_srl == $document->member_srl) { - $is_granted = true; - } - $document_list[$i]->is_granted = $is_granted; - } - return $document_list; - } - - /** - * @brief module_srl에 해당하는 문서의 전체 갯수를 가져옴 - **/ - function getDocumentCount($module_srl, $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; - $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; - $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; - $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); - - 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; - } - - /** - * @brief 해당 document의 page 가져오기, module_srl이 없으면 전체에서.. - **/ - function getDocumentPage($document_srl, $module_srl=0, $list_count) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('document.getDocumentPage', $args); - - $count = $output->data->count; - $page = (int)(($count-1)/$list_count)+1; - return $page; - } - - /** - * @brief 카테고리의 정보를 가져옴 - **/ - function getCategory($category_srl) { - $oDB = &DB::getInstance(); - - $args->category_srl = $category_srl; - $output = $oDB->executeQuery('document.getCategory', $args); - return $output->data; - } - - /** - * @brief 특정 모듈의 카테고리 목록을 가져옴 - **/ - function getCategoryList($module_srl) { - $oDB = &DB::getInstance(); - - $args->module_srl = $module_srl; - $args->sort_index = 'list_order'; - $output = $oDB->executeQuery('document.getCategoryList', $args); - - $category_list = $output->data; - - if(!$category_list) return NULL; - if(!is_array($category_list)) $category_list = array($category_list); - - $category_count = count($category_list); - for($i=0;$i<$category_count;$i++) { - $category_srl = $category_list[$i]->category_srl; - $list[$category_srl] = $category_list[$i]; - } - return $list; - } - - /** - * @brief 카테고리에 속한 문서의 갯수를 구함 - **/ - function getCategoryDocumentCount($category_srl) { - $oDB = &DB::getInstance(); - - $args->category_srl = $category_srl; - $output = $oDB->executeQuery('document.getCategoryDocumentCount', $args); - return (int)$output->data->count; - } - - /** - * @brief 특정 문서에 속한 첨부파일의 개수를 return - **/ - function getFilesCount($document_srl) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('document.getFilesCount', $args); - return (int)$output->data->count; - } - - /** - * @brief 파일 정보를 구함 - **/ - function getFile($file_srl) { - $oDB = &DB::getInstance(); - - $args->file_srl = $file_srl; - $output = $oDB->executeQuery('document.getFile', $args); - return $output->data; - } - - /** - * @brief 특정 문서에 속한 파일을 모두 return - **/ - function getFiles($document_srl) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $args->sort_index = 'file_srl'; - $output = $oDB->executeQuery('document.getFiles', $args); - - $file_list = $output->data; - - if($file_list && !is_array($file_list)) $file_list = array($file_list); - - for($i=0;$idirect_download; - - if($direct_download!='Y') continue; - - $uploaded_filename = Context::getRequestUri().substr($file_list[$i]->uploaded_filename,2); - - $file_list[$i]->uploaded_filename = $uploaded_filename; - } - return $file_list; - } - - /** - * @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경 - **/ - function transContent($content) { - // 멀티미디어 코드의 변환 - $content = preg_replace_callback('!]*)editor_multimedia([^\>]*?)>!is', array('Document','_transMultimedia'), $content); - - //
코드 변환 - $content = str_replace(array("
","
","
"),"
", $content); - - // 코드를 코드로 변환 - $content = preg_replace('!!is','', $content); - - return $content; - } - - /** - * @brief 내용의 멀티미디어 태그를 html 태그로 변경 - * 로 되어 있는 코드를 변경 - **/ - function _transMultimedia($matches) { - preg_match("/style\=(\"|'){0,1}([^\"\']+)(\"|'){0,1}/i",$matches[0], $buff); - $style = str_replace("\"","'",$buff[0]); - preg_match("/alt\=\"{0,1}([^\"]+)\"{0,1}/i",$matches[0], $buff); - $opt = explode('|@|',$buff[1]); - if(count($opt)<1) return $matches[0]; - - for($i=0;$i{$cmd} = $val; - } - return sprintf("", $obj->type, $obj->src, $style); - } - } -?> diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php new file mode 100644 index 000000000..07d218227 --- /dev/null +++ b/modules/file/file.controller.php @@ -0,0 +1,135 @@ +getMemberSrl(); + + // 파일 정보를 정리 + $args->file_srl = $oDB->getNextSequence(); + $args->document_srl = $document_srl; + $args->module_srl = $module_srl; + $args->direct_download = $direct_download; + $args->source_filename = $file_info['name']; + $args->uploaded_filename = $filename; + $args->file_size = filesize($filename); + $args->comment = NULL; + $args->member_srl = $member_srl; + $args->sid = md5($args->source_filename); + + $output = $oDB->executeQuery('document.insertFile', $args); + if(!$output->toBool()) return $output; + + $output->add('file_srl', $args->file_srl); + $output->add('file_size', $args->file_size); + $output->add('source_filename', $args->source_filename); + return $output; + } + + /** + * @brief 첨부파일 삭제 + **/ + function deleteFile($file_srl) { + $oDB = &DB::getInstance(); + + // 파일 정보를 가져옴 + $args->file_srl = $file_srl; + $output = $oDB->executeQuery('document.getFile', $args); + if(!$output->toBool()) return $output; + $file_info = $output->data; + if(!$file_info) return new Object(-1, 'file_not_founded'); + + $source_filename = $output->data->source_filename; + $uploaded_filename = $output->data->uploaded_filename; + + // DB에서 삭제 + $output = $oDB->executeQuery('document.deleteFile', $args); + if(!$output->toBool()) return $output; + + // 삭제 성공하면 파일 삭제 + unlink($uploaded_filename); + + return $output; + } + + /** + * @brief 특정 문서의 첨부파일을 모두 삭제 + **/ + function deleteFiles($module_srl, $document_srl) { + $oDB = &DB::getInstance(); + + $args->document_srl = $document_srl; + $output = $oDB->executeQuery('document.deleteFiles', $args); + if(!$output->toBool()) return $output; + + // 실제 파일 삭제 + $path[0] = sprintf("./files/attach/images/%s/%s/", $module_srl, $document_srl); + $path[1] = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $document_srl); + + FileHandler::removeDir($path[0]); + FileHandler::removeDir($path[1]); + + return $output; + } + + /** + * @brief 특정 모두의 첨부파일 모두 삭제 + **/ + function deleteModuleFiles($module_srl) { + $oDB = &DB::getInstance(); + + $args->module_srl = $module_srl; + $output = $oDB->executeQuery('document.deleteModuleFiles', $args); + if(!$output->toBool()) return $output; + + // 실제 파일 삭제 + $path[0] = sprintf("./files/attach/images/%s/", $module_srl); + $path[1] = sprintf("./files/attach/binaries/%s/", $module_srl); + FileHandler::removeDir($path[0]); + FileHandler::removeDir($path[1]); + + return $output; + } + + } +?> diff --git a/modules/file/file.model.php b/modules/file/file.model.php new file mode 100644 index 000000000..97ad57f01 --- /dev/null +++ b/modules/file/file.model.php @@ -0,0 +1,65 @@ +document_srl = $document_srl; + $output = $oDB->executeQuery('document.getFilesCount', $args); + return (int)$output->data->count; + } + + /** + * @brief 파일 정보를 구함 + **/ + function getFile($file_srl) { + $oDB = &DB::getInstance(); + + $args->file_srl = $file_srl; + $output = $oDB->executeQuery('document.getFile', $args); + return $output->data; + } + + /** + * @brief 특정 문서에 속한 파일을 모두 return + **/ + function getFiles($document_srl) { + $oDB = &DB::getInstance(); + + $args->document_srl = $document_srl; + $args->sort_index = 'file_srl'; + $output = $oDB->executeQuery('document.getFiles', $args); + + $file_list = $output->data; + + if($file_list && !is_array($file_list)) $file_list = array($file_list); + + for($i=0;$idirect_download; + + if($direct_download!='Y') continue; + + $uploaded_filename = Context::getRequestUri().substr($file_list[$i]->uploaded_filename,2); + + $file_list[$i]->uploaded_filename = $uploaded_filename; + } + return $file_list; + } + + } +?> diff --git a/modules/file/document.view.php b/modules/file/file.view.php similarity index 57% rename from modules/file/document.view.php rename to modules/file/file.view.php index 916f68c7d..cb0881d90 100644 --- a/modules/file/document.view.php +++ b/modules/file/file.view.php @@ -1,11 +1,11 @@ - * @desc : 문서(document) 모듈의 기본 언어팩 - **/ - $lang->msg_category_not_moved = "이동할 수가 없습니다"; -?> diff --git a/modules/file/queries/deleteCategory.xml b/modules/file/queries/deleteCategory.xml deleted file mode 100644 index c1a98762a..000000000 --- a/modules/file/queries/deleteCategory.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/modules/file/queries/deleteDocument.xml b/modules/file/queries/deleteDocument.xml deleted file mode 100644 index 36d157a90..000000000 --- a/modules/file/queries/deleteDocument.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/file/queries/deleteModuleCategory.xml b/modules/file/queries/deleteModuleCategory.xml deleted file mode 100644 index 152826bc4..000000000 --- a/modules/file/queries/deleteModuleCategory.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/file/queries/deleteModuleDocument.xml b/modules/file/queries/deleteModuleDocument.xml deleted file mode 100644 index 0338b85cc..000000000 --- a/modules/file/queries/deleteModuleDocument.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/file/queries/getCategory.xml b/modules/file/queries/getCategory.xml deleted file mode 100644 index 97ba6536a..000000000 --- a/modules/file/queries/getCategory.xml +++ /dev/null @@ -1,8 +0,0 @@ - - -
- - - - - diff --git a/modules/file/queries/getCategoryDocumentCount.xml b/modules/file/queries/getCategoryDocumentCount.xml deleted file mode 100644 index bf0df824d..000000000 --- a/modules/file/queries/getCategoryDocumentCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/getCategoryList.xml b/modules/file/queries/getCategoryList.xml deleted file mode 100644 index 1625c3cfe..000000000 --- a/modules/file/queries/getCategoryList.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/getDocument.xml b/modules/file/queries/getDocument.xml deleted file mode 100644 index eb3b6af8a..000000000 --- a/modules/file/queries/getDocument.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/getDocumentCount.xml b/modules/file/queries/getDocumentCount.xml deleted file mode 100644 index 5ea51255e..000000000 --- a/modules/file/queries/getDocumentCount.xml +++ /dev/null @@ -1,19 +0,0 @@ - - -
- - - - - - - - - - - - - - - - diff --git a/modules/file/queries/getDocumentList.xml b/modules/file/queries/getDocumentList.xml deleted file mode 100644 index de2f2aa88..000000000 --- a/modules/file/queries/getDocumentList.xml +++ /dev/null @@ -1,26 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/file/queries/getDocumentPage.xml b/modules/file/queries/getDocumentPage.xml deleted file mode 100644 index 35bee06c4..000000000 --- a/modules/file/queries/getDocumentPage.xml +++ /dev/null @@ -1,12 +0,0 @@ - - -
- - - - - - - - - diff --git a/modules/file/queries/getDocuments.xml b/modules/file/queries/getDocuments.xml deleted file mode 100644 index 828a6b2db..000000000 --- a/modules/file/queries/getDocuments.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/insertCategory.xml b/modules/file/queries/insertCategory.xml deleted file mode 100644 index 79bfe78e9..000000000 --- a/modules/file/queries/insertCategory.xml +++ /dev/null @@ -1,14 +0,0 @@ - - -
- - - - - - - - - - - diff --git a/modules/file/queries/insertDocument.xml b/modules/file/queries/insertDocument.xml deleted file mode 100644 index 08c0d48eb..000000000 --- a/modules/file/queries/insertDocument.xml +++ /dev/null @@ -1,34 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/file/queries/updateCategory.xml b/modules/file/queries/updateCategory.xml deleted file mode 100644 index 2d1d60687..000000000 --- a/modules/file/queries/updateCategory.xml +++ /dev/null @@ -1,13 +0,0 @@ - - -
- - - - - - - - - - diff --git a/modules/file/queries/updateCategoryCount.xml b/modules/file/queries/updateCategoryCount.xml deleted file mode 100644 index 1d4c5fc2f..000000000 --- a/modules/file/queries/updateCategoryCount.xml +++ /dev/null @@ -1,12 +0,0 @@ - - -
- - - - - - - - - diff --git a/modules/file/queries/updateCommentCount.xml b/modules/file/queries/updateCommentCount.xml deleted file mode 100644 index 8c71dd3c4..000000000 --- a/modules/file/queries/updateCommentCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/updateDocument.xml b/modules/file/queries/updateDocument.xml deleted file mode 100644 index 43d89bc00..000000000 --- a/modules/file/queries/updateDocument.xml +++ /dev/null @@ -1,31 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/file/queries/updateDocumentCategory.xml b/modules/file/queries/updateDocumentCategory.xml deleted file mode 100644 index 67a2976a1..000000000 --- a/modules/file/queries/updateDocumentCategory.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/updateReadedCount.xml b/modules/file/queries/updateReadedCount.xml deleted file mode 100644 index 8391d8cd8..000000000 --- a/modules/file/queries/updateReadedCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/updateTrackbackCount.xml b/modules/file/queries/updateTrackbackCount.xml deleted file mode 100644 index dd8b58c8f..000000000 --- a/modules/file/queries/updateTrackbackCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/queries/updateVotedCount.xml b/modules/file/queries/updateVotedCount.xml deleted file mode 100644 index bd2ddbb04..000000000 --- a/modules/file/queries/updateVotedCount.xml +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - - - - - - - diff --git a/modules/file/schemas/category.xml b/modules/file/schemas/category.xml deleted file mode 100644 index a201b6c0b..000000000 --- a/modules/file/schemas/category.xml +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - - - - -
diff --git a/modules/file/schemas/documents.xml b/modules/file/schemas/documents.xml deleted file mode 100644 index c5b1c4f27..000000000 --- a/modules/file/schemas/documents.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -