묻고답하기

안녕하세요. xe 초보입니다.


혼자서 xe 를 좀 익혀보고자 게시판 dx 라는 모듈의  코드를 뒤적거리고 있는데요...


beluxe.controller.php  파일에서 궁금한 점이 하나 생겨서 질문 드리게 되었습니다.


이 파일의 function 중에 procBoardInsertDocument 라는 것이 

쓴 글을 게시판에 등록해주는 역할을 담당하고 있는 부분이라고 생각되는데요.



이 파일에 등록되어 있는 다른 대부분의 function 들이 대부분 executequery 명령을 실행하는 것과는 달리 

여기에는 executequery 나 그 비슷한 명령들이 안보이는 것 같아서요.


내용을 디비에 등록하려면 쿼리를 실행하는 부분이 분명히 있을거라고 생각하는데, 능력이 부족해 찾을수가 없으니 답답합니다.


설명 가능하신분은 좀 알려주시면 감사하겠습니다.^^;


아래는 해당 function 부분의 코드입니다.





function procBoardInsertDocument()

{

if(!$this->grant->write_document) return new Object(-1, 'msg_not_permitted');


// TODO 카테고리 grant 체크해라, 근데 코어에서 해야될거 같거든?

$args = Context::getRequestVars();


$mod_srl = (int) $args->module_srl;

$doc_srl = (int) $args->document_srl;

if(!$mod_srl || $this->module_srl != $mod_srl) return new Object(-1,'msg_invalid_request');


$oLogIfo = Context::get('logged_info');

$log_mbr_srl = $oLogIfo->member_srl;


// 회원이라면 닉,암호 제거, 상담기능 사용시 비회원 에러

if(Context::get('is_logged'))

{

unset($args->nick_name);

unset($args->password);

}

else if($this->module_info->consultation == 'Y')

{

return new Object(-1,'msg_invalid_request');

}


if(!$this->grant->manager)

{

// 제목 색상 변경 허용이 아니라면 게시글 색상/굵기 제거

if($this->module_info->use_title_color != 'Y')

{

unset($args->title_color);

unset($args->title_bold);

}


if($this->module_info->allow_comment == 'Y' || $this->module_info->allow_comment == 'N')

{

$args->allow_comment = $this->module_info->allow_comment == 'Y' ? 'Y' : 'N';

}


if($this->module_info->allow_trackback == 'Y' || $this->module_info->allow_trackback == 'N')

{

$args->allow_trackback = $this->module_info->allow_trackback == 'Y' ? 'Y' : 'N';

}

}


$args->allow_comment = $args->allow_comment == 'Y' ? 'Y' : 'N';

$args->allow_trackback = $args->allow_trackback == 'Y' ? 'Y' : 'N';


// 사용 상태에 없는 값이면 임시로 설정

$use_status = explode(',', $this->module_info->use_status);

if(!in_array($args->status, $use_status)) $args->status = count($use_status) ? 'TEMP' : 'PUBLIC';


// 사용자 상태 사용시 관리자이고 공지가 아니면 is_notice 필드에 상태입력 TODO is_notice 필드 사용하는이유는 상태를 넣을 필드가 없어서...

if($args->is_notice != 'Y' || !$this->grant->manager) $args->is_notice = 'N';

$args->custom_status = (string) (((int) $args->custom_status < 1 && (int) $args->custom_status > 9) ? 'N' : $args->custom_status);

if($this->module_info->custom_status && $this->grant->manager && $args->is_notice != 'Y'+ ') $args->is_notice = $args->custom_status;


// 값 체크

settype($args->title, "string");

if($args->title == '') $args->title = cut_str(strip_tags($args->content), 20);

if($args->title == '') $args->title = 'Untitled';

if($args->tags) $args->tags = preg_replace('/\s+/', ',', strip_tags($args->tags));


// 포인트 사용이 아니면 포인트 값 제거

$args->use_point = (int) $args->use_point;

$is_use_point = Context::get('is_logged') && ($this->module_info->use_restrict_view == 'P' || $this->module_info->use_restrict_down == 'P');

if(!$is_use_point) unset($args->use_point);


// document module의 객체 생성

$cmDocument = &getModel('document');

$ccDocument = &getController('document');


// 이미 존재하는 글인지 체크

$oDocIfo = $cmDocument->getDocument($doc_srl, FALSE, FALSE);

if($oDocIfo->isExists() && $oDocIfo->get('module_srl') != $mod_srl) return new Object(-1, 'msg_invalid_request');


// 사용자 정의 확장 필드 최대 20개로 제한함

$outvars = $this->_arrangeExtraField($oDocIfo->isExists() ? $oDocIfo->get('extra_vars') : NULL, &$args);

if(!$outvars->toBool()) return $outvars;

if(count($args->extra_vars->beluxe->extra) > 20) return new Object(-1, 'msg_max_extra_fields');


// 포인트  없으면 중단

if($is_use_point && $args->use_point > 0)

{

$cmPoint = &getModel('point');

if($cmPoint->getPoint($log_mbr_srl) < $args->use_point) return new Object(-1, 'msg_not_enough_point');

}


// 익명 사용중인지 체크

$is_anonymous = $log_mbr_srl && in_array($this->module_info->use_anonymous, array('Y', 'S'));

$args->anonymous = ($is_anonymous && ($this->module_info->use_anonymous == 'Y' || $args->anonymous == 'Y')) ? 'Y' : 'N';


$oDB = &DB::getInstance();

if($oDB)

{

$oDB->begin();


// 이미 존재하는 경우 수정

if($oDocIfo->isExists())

{

// 권한 체크

if(!$oDocIfo->isGranted())

{

$oDB->rollback();

return new Object(-1,'msg_not_permitted');

}


if(!$this->grant->manager)

{

//수정,삭제 잠금

if($this->module_info->use_lock_document == 'Y')

{

$is_lock = TRUE;

}

else if($this->module_info->use_lock_document == 'C')

{

$is_lock = (int) $this->module_info->use_lock_document_option <= $oDocIfo->get('comment_count');

}

else if($this->module_info->use_lock_document == 'T')

{

$is_lock = (time() - ztime($oDocIfo->get('regdate'))) > ((int) $this->module_info->use_lock_document_option * 60 * 60 * 24);

}


if($is_lock)

{

$oDB->rollback();

return new Object(-1,'msg_is_locked_document');

}

}


// 관리자 아니면 수정 불가

if(!$this->grant->manager) $args->is_notice = $oDocIfo->get('is_notice');


$out = $ccDocument->updateDocument($oDocIfo, $args);


// 익명 사용시 멥버 정보만 따로 업데이트

if($out->toBool() && $log_mbr_srl && $is_anonymous)

{

$cmMember = &getModel('member');

$oMbrIfo = $cmMember->getMemberInfoByMemberSrl(abs($oDocIfo->get('member_srl')));

$this->_setAnonymous($args, $oMbrIfo);

executeQuery('beluxe.updateDocumentMemberInfo', $args);

}


$is_upCateCnt = $oDocIfo->get('category_srl') != $args->category_srl;

$msg_code = 'success_updated';

$page = Context::get('page');

}

else

{

// 그렇지 않으면 신규 등록

//익명 사용시

if($is_anonymous = $args->anonymous == 'Y') $this->_setAnonymous($args, $oLogIfo);


// 신규에 srl 이 있으면 첨부 파일이 들어있는 경우

$out = $ccDocument->insertDocument($args, $is_anonymous);

$doc_srl = $out->get('document_srl');


// 관리자 메일이 등록되어 있으면 메일 발송

if($out->toBool() && $this->module_info->admin_mail)

{

$tmp_url = getFullUrl(''+ ','document_srl',$doc_srl);

$this->_sendMail(

($is_anonymous || $args->user_name) ? $args->user_name : $oLogIfo->user_name,

($is_anonymous || $args->email_address) ? $args->email_address : $oLogIfo->email_address,

$this->module_info->admin_mail,

$args->title,

sprintf("From : <a href=\"%s\">%s</a><br/>\r\n%s", $tmp_url, $tmp_url, $args->content)

);

}


$is_upCateCnt = TRUE;

$msg_code = 'success_registed';

}


// 오류 발생시 멈춤

if(!$out->toBool())

{

$oDB->rollback();

return $out;

}


$doc_srl = $out->get('document_srl');


// 포인트 사용이면 빼기

if($is_use_point && $args->use_point)

{

$ccPoint = &getController('point');

$ccPoint->setPoint($log_mbr_srl, $args->use_point, 'minus');

}


$oDB->commit();

}

else return new Object(-1,'msg_dbconnect_failed');


// 캐쉬 갱신

if($is_upCateCnt)

{

require_once(__XEFM_PATH__ . 'classes.cache.php');

BeluxeCache::categoryList($mod_srl);

}


// addons 에서 사용하기에 variables 입력 필요.

$this->add('mid', Context::get('mid'));

$this->add('document_srl', $doc_srl);


$this->setMessage($msg_code);

$this->_setLocation('document_srl', $doc_srl);

}


글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
Carine 쉬운설치 이후 FTP수동설치가 [1] 2012.01.28 by KANTSOFT
종필샘 쉬운 설치 시 에러 메시지  
mathgongyoo 지식인 XE 모듈이 레이아웃에서 잘려서 나올 경우  
J나킴 XE 1.5 버전 이상에서 회원목록볼때 그룹별로 보는방법있나요?  
재문아빠 V3 갤러리에서 썸네일 크기 바꿨더니... [1] file 2012.01.28
forest535 RSS 피드 갱신주기를 조절할 수 있나요? [1] 2012.01.28 by snows96
miso777 업데이트 진행시 바로 최신으로 설치.? [2] 2012.01.28 by snows96
재문아빠 네이버 지도 오픈 API를 입력하는 곳이 없네요.  
Free942 첨부파일을 다른 지정된 곳에 저장할 수 있을까요??  
leebackup 1.5.1.2 에서 변경된 파일만 받으려고 합니다. [5] 2012.01.28 by leebackup
오바릿 목록 노출 관련 질문 file  
쿵푸팬더 files 폴더를 모르고 전체 삭제 하였습니다.!! [1] 2012.01.28 by Free942
94DT 이부분에 음악 위젯을 넣고싶은데요 [1] file 2012.01.28 by KANTSOFT
sky77 왜이럴까요?도와주세요 file  
sbshs77 소셜로그인으로 가입한 사람이 정보 수정시  
비타민. 데이터 이전 질문 [1] 2012.01.28 by 비타민.
질문있습니다.  
삐짐이 html문서 비회원 접근시 -부탁드립니다. [2] 2012.01.28 by 송동우
Joozoa 최근 게시물이 출력이 안됩니다.  
잔비어 카테고리지정글을 한페이지 제한둘수 있을까요? [1] 2012.01.28 by 송동우
행복하소서 송동우님 짧은질문 좀 드려도될까요? [1] 2012.01.28 by 송동우
닉네임을 중복할수 있게 하고싶습니다.  
오순도순 글작성시 등록하려면 에러납니다.  
autism26 메뉴관리 질문입니다.  
서부주민 url에 www가 있을 때와 없을 때... [1] 2012.01.28 by 송동우
빵상 게시물에 유투브 동영상을 링크했을 때  
오락실주인 중복추천 막는 방법좀 제발 ㅠ  
이성훈887 최근글 위젯 설정이 안먹힙니다...ㅠㅠ [1] 2012.01.28 by 때린데 또때려
아파츼 질문 답변좀 해주세요 ㅜ  
saliey 갑자기 왜이럴까요 ㅠㅠ