게시판 관리자가 분류를 추가/삭제/이동/수정 하지 못하는 권한 문제 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6015 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2009-04-02 08:36:55 +00:00
parent d5d2220df4
commit 658bafbd46
10 changed files with 270 additions and 246 deletions

View file

@ -4,8 +4,14 @@
<permissions>
<permission action="dispDocumentManageDocument" target="member" />
<permission action="getDocumentCategories" target="member" />
<permission action="getDocumentCategoryTplInfo" target="member" />
<permission action="procDocumentAddCart" target="member" />
<permission action="procDocumentInsertCategory" target="member" />
<permission action="procDocumentManageCheckedDocument" target="member" />
<permission action="procDocumentMoveCategory" target="member" />
<permission action="procDocumentDeleteCategory" target="member" />
<permission action="procDocumentMakeXmlFile" target="member" />
</permissions>
<actions>
<action name="dispDocumentPrint" type="view" standalone="true" />
@ -28,16 +34,17 @@
<action name="dispDocumentAdminDeclared" type="view" standalone="true" />
<action name="dispDocumentAdminTrashList" type="view" standalone="true" />
<action name="getDocumentAdminCategoryTplInfo" type="model" standalone="true"/>
<action name="getDocumentCategoryTplInfo" type="model" standalone="true"/>
<action name="procDocumentInsertCategory" type="controller" standalone="true"/>
<action name="procDocumentDeleteCategory" type="controller" standalone="true"/>
<action name="procDocumentMoveCategory" type="controller" standalone="true"/>
<action name="procDocumentMakeXmlFile" type="controller" standalone="true"/>
<action name="procDocumentAdminInsertCategory" type="controller" standalone="true"/>
<action name="procDocumentAdminDeleteCategory" type="controller" standalone="true"/>
<action name="procDocumentAdminMoveCategory" type="controller" standalone="true"/>
<action name="procDocumentAdminMakeXmlFile" type="controller" standalone="true"/>
<action name="procDocumentAdminInsertAlias" type="controller" standalone="true"/>
<action name="procDocumentAdminDeleteAlias" type="controller" standalone="true"/>
<action name="procDocumentAdminRestoreTrash" type="controller" standalone="true"/>
<action name="procAdminMoveExtraVar" type="controller" standalone="true"/>
<action name="procDocumentAdminMoveExtraVar" type="controller" standalone="true"/>
<action name="procDocumentAdminInsertExtraVar" type="controller" standalone="true" />
<action name="procDocumentAdminDeleteExtraVar" type="controller" standalone="true" />

View file

@ -380,179 +380,10 @@
$this->setMessage('success_deleted');
}
/**
* @brief 카테고리 추가
**/
function procDocumentAdminInsertCategory($args = null) {
// 입력할 변수 정리
if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','title','expand','group_srls','color');
if($args->expand !="Y") $args->expand = "N";
$args->group_srls = str_replace('|@|',',',$args->group_srls);
$args->parent_srl = (int)$args->parent_srl;
$oDocumentController = &getController('document');
$oDocumentModel = &getModel('document');
$oDB = &DB::getInstance();
$oDB->begin();
// 이미 존재하는지를 확인
if($args->category_srl) {
$category_info = $oDocumentModel->getCategory($args->category_srl);
if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
}
// 존재하게 되면 update를 해준다
if($args->category_srl) {
$output = $oDocumentController->updateCategory($args);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 존재하지 않으면 insert를 해준다
} else {
$output = $oDocumentController->insertCategory($args);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
}
// XML 파일을 갱신하고 위치을 넘겨 받음
$xml_file = $oDocumentController->makeCategoryFile($args->module_srl);
$oDB->commit();
$this->add('xml_file', $xml_file);
$this->add('module_srl', $args->module_srl);
$this->add('category_srl', $args->category_srl);
$this->add('parent_srl', $args->parent_srl);
}
/**
* @brief 카테고리 삭제
**/
function procDocumentAdminDeleteCategory() {
// 변수 정리
$args = Context::gets('module_srl','category_srl');
$oDB = &DB::getInstance();
$oDB->begin();
$oDocumentModel = &getModel('document');
// 원정보를 가져옴
$category_info = $oDocumentModel->getCategory($args->category_srl);
if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
// 자식 노드가 있는지 체크하여 있으면 삭제 못한다는 에러 출력
if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
// DB에서 삭제
$oDocumentController = &getController('document');
$output = $oDocumentController->deleteCategory($args->category_srl);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// XML 파일을 갱신하고 위치을 넘겨 받음
$xml_file = $oDocumentController->makeCategoryFile($args->module_srl);
$oDB->commit();
$this->add('xml_file', $xml_file);
$this->add('category_srl', $parent_srl);
$this->setMessage('success_deleted');
}
function procDocumentAdminMoveCategory() {
$source_category_srl = Context::get('source_srl');
// parent_srl 이 있으면 첫 자식으로 들어간다
$parent_category_srl = Context::get('parent_srl');
// target_srl 이 있으면 target_srl 아래로 형제로 들어간다
$target_category_srl = Context::get('target_srl');
$oDocumentModel = &getModel('document');
$oDocumentController = &getController('document');
$source_category = $oDocumentModel->getCategory($source_category_srl);
//parent_category_srl 의 첫 자식으로 넣자
if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)){
$parent_category = $oDocumentModel->getCategory($parent_category_srl);
$args->module_srl = $source_category->module_srl;
$args->parent_srl = $parent_category_srl;
$output = executeQuery('document.getChildCategoryMinListOrder', $args);
if(!$output->toBool()) return $output;
$args->list_order = (int)$output->data->list_order;
if(!$args->list_order) $args->list_order = 0;
$args->list_order--;
$source_args->category_srl = $source_category_srl;
$source_args->parent_srl = $parent_category_srl;
$source_args->list_order = $args->list_order;
$output = $oDocumentController->updateCategory($source_args);
if(!$output->toBool()) return $output;
// $target_category_srl의 아래동생으로
}else if($target_category_srl > 0){
$target_category = $oDocumentModel->getCategory($target_category_srl);
//$target_category의 아래 동생을 모두 내린다
$output = $oDocumentController->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
if(!$output->toBool()) return $output;
$source_args->category_srl = $source_category_srl;
$source_args->parent_srl = $target_category->parent_srl;
$source_args->list_order = $target_category->list_order+1;
$output = $oDocumentController->updateCategory($source_args);
if(!$output->toBool()) return $output;
}
// xml파일 재생성
$xml_file = $oDocumentController->makeCategoryFile($source_category->module_srl);
// return 변수 설정
$this->add('xml_file', $xml_file);
$this->add('source_category_srl', $source_category_srl);
}
/**
* @brief xml 파일을 갱신
* 관리자페이지에서 메뉴 구성 간혹 xml파일이 재생성 안되는 경우가 있는데\n
* 이럴 경우 관리자의 수동 갱신 기능을 구현해줌\n
* 개발 중간의 문제인 같고 현재는 문제가 생기지 않으나 굳이 없앨 필요 없는 기능
**/
function procDocumentAdminMakeXmlFile() {
// 입력값을 체크
$module_srl = Context::get('module_srl');
// xml파일 재생성
$oDocumentController = &getController('document');
$xml_file = $oDocumentController->makeCategoryFile($module_srl);
// return 값 설정
$this->add('xml_file',$xml_file);
}
/**
* @brief 확장변수 순서 조절
**/
function procAdminMoveExtraVar() {
function procDocumentAdminMoveExtraVar() {
$type = Context::get('type');
$module_srl = Context::get('module_srl');
$var_idx = Context::get('var_idx');

View file

@ -14,67 +14,6 @@
function init() {
}
/**
* @brief 특정 카테고리의 정보를 이용하여 템플릿을 구한후 return
* 관리자 페이지에서 특정 메뉴의 정보를 추가하기 위해 서버에서 tpl을 컴파일 한후 컴파일 html을 직접 return
**/
function getDocumentAdminCategoryTplInfo() {
// 해당 메뉴의 정보를 가져오기 위한 변수 설정
$module_srl = Context::get('module_srl');
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
$category_srl = Context::get('category_srl');
$parent_srl = Context::get('parent_srl');
// 회원 그룹의 목록을 가져옴
$oMemberModel = &getModel('member');
$group_list = $oMemberModel->getGroups($module_info->site_srl);
Context::set('group_list', $group_list);
$oDocumentModel = &getModel('document');
// parent_srl이 있고 category_srl 이 없으면 하부 메뉴 추가임
if(!$category_srl && $parent_srl) {
// 상위 메뉴의 정보를 가져옴
$parent_info = $oDocumentModel->getCategory($parent_srl);
// 추가하려는 메뉴의 기본 변수 설정
$category_info->category_srl = getNextSequence();
$category_info->parent_srl = $parent_srl;
$category_info->parent_category_title = $parent_info->title;
// root에 메뉴 추가하거나 기존 메뉴의 수정일 경우
} else {
// category_srl 이 있으면 해당 메뉴의 정보를 가져온다
if($category_srl) $category_info = $oDocumentModel->getCategory($category_srl);
// 찾아진 값이 없다면 신규 메뉴 추가로 보고 category_srl값만 구해줌
if(!$category_info->category_srl) {
$category_info->category_srl = getNextSequence();
}
}
$category_info->title = htmlspecialchars($category_info->title);
Context::set('category_info', $category_info);
// template 파일을 직접 컴파일한후 tpl변수에 담아서 return한다.
$oTemplate = &TemplateHandler::getInstance();
$tpl = $oTemplate->compile('./modules/document/tpl', 'category_info');
$tpl = str_replace("\n",'',$tpl);
// 사용자 정의 언어 변경
$oModuleController = &getController('module');
$oModuleController->replaceDefinedLangCode($tpl);
// return 할 변수 설정
$this->add('tpl', $tpl);
}
/**
* @brief 휴지통에 존재하는 문서 목록을 가져옴
**/

View file

@ -1018,6 +1018,191 @@
Context::addHtmlHeader($js_code);
}
/**
* @brief 카테고리 추가
**/
function procDocumentInsertCategory($args = null) {
// 입력할 변수 정리
if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','title','expand','group_srls','color');
// 권한 체크
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl);
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
if(!$grant->manager) return new Object(-1,'msg_not_permitted');
if($args->expand !="Y") $args->expand = "N";
$args->group_srls = str_replace('|@|',',',$args->group_srls);
$args->parent_srl = (int)$args->parent_srl;
$oDocumentModel = &getModel('document');
$oDB = &DB::getInstance();
$oDB->begin();
// 이미 존재하는지를 확인
if($args->category_srl) {
$category_info = $oDocumentModel->getCategory($args->category_srl);
if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
}
// 존재하게 되면 update를 해준다
if($args->category_srl) {
$output = $this->updateCategory($args);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 존재하지 않으면 insert를 해준다
} else {
$output = $this->insertCategory($args);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
}
// XML 파일을 갱신하고 위치을 넘겨 받음
$xml_file = $this->makeCategoryFile($args->module_srl);
$oDB->commit();
$this->add('xml_file', $xml_file);
$this->add('module_srl', $args->module_srl);
$this->add('category_srl', $args->category_srl);
$this->add('parent_srl', $args->parent_srl);
}
function procDocumentMoveCategory() {
$source_category_srl = Context::get('source_srl');
// parent_srl 이 있으면 첫 자식으로 들어간다
$parent_category_srl = Context::get('parent_srl');
// target_srl 이 있으면 target_srl 아래로 형제로 들어간다
$target_category_srl = Context::get('target_srl');
$oDocumentModel = &getModel('document');
$source_category = $oDocumentModel->getCategory($source_category_srl);
// 권한 체크
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl);
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
if(!$grant->manager) return new Object(-1,'msg_not_permitted');
//parent_category_srl 의 첫 자식으로 넣자
if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)){
$parent_category = $oDocumentModel->getCategory($parent_category_srl);
$args->module_srl = $source_category->module_srl;
$args->parent_srl = $parent_category_srl;
$output = executeQuery('document.getChildCategoryMinListOrder', $args);
if(!$output->toBool()) return $output;
$args->list_order = (int)$output->data->list_order;
if(!$args->list_order) $args->list_order = 0;
$args->list_order--;
$source_args->category_srl = $source_category_srl;
$source_args->parent_srl = $parent_category_srl;
$source_args->list_order = $args->list_order;
$output = $this->updateCategory($source_args);
if(!$output->toBool()) return $output;
// $target_category_srl의 아래동생으로
}else if($target_category_srl > 0){
$target_category = $oDocumentModel->getCategory($target_category_srl);
//$target_category의 아래 동생을 모두 내린다
$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
if(!$output->toBool()) return $output;
$source_args->category_srl = $source_category_srl;
$source_args->parent_srl = $target_category->parent_srl;
$source_args->list_order = $target_category->list_order+1;
$output = $this->updateCategory($source_args);
if(!$output->toBool()) return $output;
}
// xml파일 재생성
$xml_file = $this->makeCategoryFile($source_category->module_srl);
// return 변수 설정
$this->add('xml_file', $xml_file);
$this->add('source_category_srl', $source_category_srl);
}
/**
* @brief 카테고리 삭제
**/
function procDocumentDeleteCategory() {
// 변수 정리
$args = Context::gets('module_srl','category_srl');
$oDB = &DB::getInstance();
$oDB->begin();
// 권한 체크
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl);
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
if(!$grant->manager) return new Object(-1,'msg_not_permitted');
$oDocumentModel = &getModel('document');
// 원정보를 가져옴
$category_info = $oDocumentModel->getCategory($args->category_srl);
if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
// 자식 노드가 있는지 체크하여 있으면 삭제 못한다는 에러 출력
if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new Object(-1, 'msg_cannot_delete_for_child');
// DB에서 삭제
$output = $this->deleteCategory($args->category_srl);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// XML 파일을 갱신하고 위치을 넘겨 받음
$xml_file = $this->makeCategoryFile($args->module_srl);
$oDB->commit();
$this->add('xml_file', $xml_file);
$this->add('category_srl', $parent_srl);
$this->setMessage('success_deleted');
}
/**
* @brief xml 파일을 갱신
* 관리자페이지에서 메뉴 구성 간혹 xml파일이 재생성 안되는 경우가 있는데\n
* 이럴 경우 관리자의 수동 갱신 기능을 구현해줌\n
* 개발 중간의 문제인 같고 현재는 문제가 생기지 않으나 굳이 없앨 필요 없는 기능
**/
function procDocumentMakeXmlFile() {
// 입력값을 체크
$module_srl = Context::get('module_srl');
// 권한 체크
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
if(!$grant->manager) return new Object(-1,'msg_not_permitted');
$xml_file = $this->makeCategoryFile($module_srl);
// return 값 설정
$this->add('xml_file',$xml_file);
}
/**
* @brief 카테고리를 캐시 파일로 저장
**/

View file

@ -852,6 +852,68 @@
return $oTemplate->compile($this->module_path.'tpl', 'category_list');
}
/**
* @brief 특정 카테고리의 정보를 이용하여 템플릿을 구한후 return
* 관리자 페이지에서 특정 메뉴의 정보를 추가하기 위해 서버에서 tpl을 컴파일 한후 컴파일 html을 직접 return
**/
function getDocumentCategoryTplInfo() {
$oModuleModel = &getModel('module');
$oMemberModel = &getModel('member');
// 해당 메뉴의 정보를 가져오기 위한 변수 설정
$module_srl = Context::get('module_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
// 권한 체크
$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
if(!$grant->manager) return new Object(-1,'msg_not_permitted');
$category_srl = Context::get('category_srl');
$parent_srl = Context::get('parent_srl');
// 회원 그룹의 목록을 가져옴
$group_list = $oMemberModel->getGroups($module_info->site_srl);
Context::set('group_list', $group_list);
// parent_srl이 있고 category_srl 이 없으면 하부 메뉴 추가임
if(!$category_srl && $parent_srl) {
// 상위 메뉴의 정보를 가져옴
$parent_info = $this->getCategory($parent_srl);
// 추가하려는 메뉴의 기본 변수 설정
$category_info->category_srl = getNextSequence();
$category_info->parent_srl = $parent_srl;
$category_info->parent_category_title = $parent_info->title;
// root에 메뉴 추가하거나 기존 메뉴의 수정일 경우
} else {
// category_srl 이 있으면 해당 메뉴의 정보를 가져온다
if($category_srl) $category_info = $this->getCategory($category_srl);
// 찾아진 값이 없다면 신규 메뉴 추가로 보고 category_srl값만 구해줌
if(!$category_info->category_srl) {
$category_info->category_srl = getNextSequence();
}
}
$category_info->title = htmlspecialchars($category_info->title);
Context::set('category_info', $category_info);
// template 파일을 직접 컴파일한후 tpl변수에 담아서 return한다.
$oTemplate = &TemplateHandler::getInstance();
$tpl = $oTemplate->compile('./modules/document/tpl', 'category_info');
$tpl = str_replace("\n",'',$tpl);
// 사용자 정의 언어 변경
$oModuleController = &getController('module');
$oModuleController->replaceDefinedLangCode($tpl);
// return 할 변수 설정
$this->add('tpl', $tpl);
}
function getDocumentSrlByAlias($mid, $alias)
{
if(!$mid || !$alias) return null;

View file

@ -1,4 +1,4 @@
<filter name="delete_category" module="document" act="procDocumentAdminDeleteCategory" confirm_msg_code="confirm_delete">
<filter name="delete_category" module="document" act="procDocumentDeleteCategory" confirm_msg_code="confirm_delete">
<form>
<node target="category_srl" required="true" />
</form>

View file

@ -1,4 +1,4 @@
<filter name="insert_category" module="document" act="procDocumentAdminInsertCategory" confirm_msg_code="confirm_submit">
<filter name="insert_category" module="document" act="procDocumentInsertCategory" confirm_msg_code="confirm_submit">
<form>
<node target="module_srl" required="true" />
<node target="category_srl" required="true" />

View file

@ -1,4 +1,4 @@
<filter name="move_category" module="document" act="procDocumentAdminMoveCategory" confirm_msg_code="confirm_move">
<filter name="move_category" module="document" act="procDocumentMoveCategory" confirm_msg_code="confirm_move">
<form />
<parameter />
<response callback_func="completeMoveCategory">

View file

@ -142,7 +142,7 @@ function moveVar(type, module_srl, var_idx) {
params['module_srl'] = module_srl;
params['var_idx'] = var_idx;
var response_tags = new Array('error','message');
exec_xml('document','procAdminMoveExtraVar', params, function() { location.reload(); });
exec_xml('document','procDocumentAdminMoveExtraVar', params, function() { location.reload(); });
}
function completeRestoreTrash(ret_obj) {

View file

@ -88,7 +88,7 @@ function Tree(url){
parent_srl = 0;
}
jQuery.exec_json("board.procDocumentAdminMoveCategory",{ "module_srl":module_srl,"parent_srl":parent_srl,"target_srl":target_srl,"source_srl":source_srl},
jQuery.exec_json("board.procDocumentMoveCategory",{ "module_srl":module_srl,"parent_srl":parent_srl,"target_srl":target_srl,"source_srl":source_srl},
function(data){
jQuery('#category_info').html('');
if(data.error > 0) Tree(xml_url);
@ -126,7 +126,7 @@ function addNode(node,e){
,"module_srl":jQuery("#fo_category [name=module_srl]").val()
};
jQuery.exec_json('document.getDocumentAdminCategoryTplInfo', params, function(data){
jQuery.exec_json('document.getDocumentCategoryTplInfo', params, function(data){
jQuery('#category_info').html(data.tpl).css('left',e.pageX).css('top',e.pageY);
});
}
@ -138,7 +138,7 @@ function modifyNode(node,e){
,"module_srl":jQuery("#fo_category [name=module_srl]").val()
};
jQuery.exec_json('document.getDocumentAdminCategoryTplInfo', params, function(data){
jQuery.exec_json('document.getDocumentCategoryTplInfo', params, function(data){
jQuery('#category_info').html(data.tpl).css('left',e.pageX).css('top',e.pageY);
});
}
@ -159,7 +159,7 @@ function deleteNode(node){
,"module_srl":jQuery("#fo_category [name=module_srl]").val()
};
jQuery.exec_json('document.procDocumentAdminDeleteCategory', params, function(data){
jQuery.exec_json('document.procDocumentDeleteCategory', params, function(data){
if(data.error==0) Tree(xml_url);
});
}
@ -182,7 +182,7 @@ function doReloadTreeCategory(module_srl) {
// 서버에 요청하여 해당 노드의 정보를 수정할 수 있도록 한다.
var response_tags = new Array('error','message', 'xml_file');
exec_xml('document', 'procDocumentAdminMakeXmlFile', params, completeInsertCategory, response_tags, params);
exec_xml('document', 'procDocumentMakeXmlFile', params, completeInsertCategory, response_tags, params);
}
function doCategoryFormMove() {