message module update

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7680 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ChanMyeong 2010-09-07 03:56:58 +00:00
parent 6c13cf0229
commit f5e4778372
2 changed files with 853 additions and 853 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,296 +1,296 @@
<?php <?php
/** /**
* @class ModuleObject * @class ModuleObject
* @author zero (zero@nzeo.com) * @author NHN (developers@xpressengine.com)
* @brief base class of ModuleHandler * @brief base class of ModuleHandler
**/ **/
class ModuleObject extends Object { class ModuleObject extends Object {
var $mid = NULL; ///< string to represent run-time instance of Module (XE Module) var $mid = NULL; ///< string to represent run-time instance of Module (XE Module)
var $module = NULL; ///< Class name of Xe Module that is identified by mid var $module = NULL; ///< Class name of Xe Module that is identified by mid
var $module_srl = NULL; ///< integer value to represent a run-time instance of Module (XE Module) var $module_srl = NULL; ///< integer value to represent a run-time instance of Module (XE Module)
var $module_info = NULL; ///< an object containing the module information var $module_info = NULL; ///< an object containing the module information
var $xml_info = NULL; ///< an object containing the module description extracted from XML file var $xml_info = NULL; ///< an object containing the module description extracted from XML file
var $module_path = NULL; ///< a path to directory where module source code resides var $module_path = NULL; ///< a path to directory where module source code resides
var $act = NULL; ///< a string value to contain the action name var $act = NULL; ///< a string value to contain the action name
var $template_path = NULL; ///< a path of directory where template files reside var $template_path = NULL; ///< a path of directory where template files reside
var $template_file = NULL; ///< name of template file var $template_file = NULL; ///< name of template file
var $layout_path = ''; ///< a path of directory where layout files reside var $layout_path = ''; ///< a path of directory where layout files reside
var $layout_file = ''; ///< name of layout file var $layout_file = ''; ///< name of layout file
var $edited_layout_file = ''; ///< name of temporary layout files that is modified in an admin mode var $edited_layout_file = ''; ///< name of temporary layout files that is modified in an admin mode
var $stop_proc = false; ///< a flag to indicating whether to stop the execution of code. var $stop_proc = false; ///< a flag to indicating whether to stop the execution of code.
/** /**
* @brief setter to set the name of module * @brief setter to set the name of module
* @param name of module * @param name of module
**/ **/
function setModule($module) { function setModule($module) {
$this->module = $module; $this->module = $module;
} }
/** /**
* @brief setter to set the name of module path * @brief setter to set the name of module path
* @param the directory path to a module directory * @param the directory path to a module directory
**/ **/
function setModulePath($path) { function setModulePath($path) {
if(substr($path,-1)!='/') $path.='/'; if(substr($path,-1)!='/') $path.='/';
$this->module_path = $path; $this->module_path = $path;
} }
/** /**
* @brief setter to set an url for redirection * @brief setter to set an url for redirection
* @param $url url for redirection * @param $url url for redirection
* @remark redirect_url is used only for ajax requests * @remark redirect_url is used only for ajax requests
**/ **/
function setRedirectUrl($url='./') { function setRedirectUrl($url='./') {
$this->add('redirect_url', $url); $this->add('redirect_url', $url);
} }
/** /**
* @brief sett to set the template path for refresh.html * @brief sett to set the template path for refresh.html
* @remark refresh.html is executed as a result of method execution * @remark refresh.html is executed as a result of method execution
* 공통 tpl중 refresh.html을 실행할 .. * 공통 tpl중 refresh.html을 실행할 ..
**/ **/
function setRefreshPage() { function setRefreshPage() {
$this->setTemplatePath('./common/tpl'); $this->setTemplatePath('./common/tpl');
$this->setTemplateFile('refresh'); $this->setTemplateFile('refresh');
} }
/** /**
* @brief sett to set the action name * @brief sett to set the action name
**/ **/
function setAct($act) { function setAct($act) {
$this->act = $act; $this->act = $act;
} }
/** /**
* @brief sett to set module information * @brief sett to set module information
* @param[in] $module_info object containing module information * @param[in] $module_info object containing module information
* @param[in] $xml_info object containing module description * @param[in] $xml_info object containing module description
**/ **/
function setModuleInfo($module_info, $xml_info) { function setModuleInfo($module_info, $xml_info) {
// 기본 변수 설정 // 기본 변수 설정
$this->mid = $module_info->mid; $this->mid = $module_info->mid;
$this->module_srl = $module_info->module_srl; $this->module_srl = $module_info->module_srl;
$this->module_info = $module_info; $this->module_info = $module_info;
$this->xml_info = $xml_info; $this->xml_info = $xml_info;
$this->skin_vars = $module_info->skin_vars; $this->skin_vars = $module_info->skin_vars;
// 웹서비스에서 꼭 필요한 인증 정보와 권한 설정 체크 // 웹서비스에서 꼭 필요한 인증 정보와 권한 설정 체크
$is_logged = Context::get('is_logged'); $is_logged = Context::get('is_logged');
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
// module model 객체 생성 // module model 객체 생성
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
// XE에서 access, manager (== is_admin) 는 고정된 권한명이며 이와 관련된 권한 설정 // XE에서 access, manager (== is_admin) 는 고정된 권한명이며 이와 관련된 권한 설정
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
if(!$module_info->mid && preg_match('/^([0-9]+)$/',$module_srl)) { if(!$module_info->mid && preg_match('/^([0-9]+)$/',$module_srl)) {
$request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl); $request_module = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($request_module->module_srl == $module_srl) { if($request_module->module_srl == $module_srl) {
$grant = $oModuleModel->getGrant($request_module, $logged_info); $grant = $oModuleModel->getGrant($request_module, $logged_info);
} }
} else { } else {
$grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info); $grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
} }
// 현재 모듈의 access 권한이 없으면 권한 없음 표시 // 현재 모듈의 access 권한이 없으면 권한 없음 표시
//if(!$grant->access) return $this->stop("msg_not_permitted"); //if(!$grant->access) return $this->stop("msg_not_permitted");
// 관리 권한이 없으면 permision, action 확인 // 관리 권한이 없으면 permision, action 확인
if(!$grant->manager) { if(!$grant->manager) {
// 현재 요청된 action의 퍼미션 type(guest, member, manager, root)를 구함 // 현재 요청된 action의 퍼미션 type(guest, member, manager, root)를 구함
$permission_target = $xml_info->permission->{$this->act}; $permission_target = $xml_info->permission->{$this->act};
// module.xml에 명시된 퍼미션이 없을때 action명에 Admin이 있으면 manager로 체크 // module.xml에 명시된 퍼미션이 없을때 action명에 Admin이 있으면 manager로 체크
if(!$permission_target && substr_count($this->act, 'Admin')) $permission_target = 'manager'; if(!$permission_target && substr_count($this->act, 'Admin')) $permission_target = 'manager';
// 권한 체크 // 권한 체크
switch($permission_target) { switch($permission_target) {
case 'root' : case 'root' :
$this->stop('msg_not_permitted_act'); $this->stop('msg_not_permitted_act');
break; break;
case 'manager' : case 'manager' :
if(!$grant->manager) $this->stop('msg_not_permitted_act'); if(!$grant->manager) $this->stop('msg_not_permitted_act');
break; break;
case 'member' : case 'member' :
if(!$is_logged) $this->stop('msg_not_permitted_act'); if(!$is_logged) $this->stop('msg_not_permitted_act');
break; break;
} }
} }
// 권한변수 설정 // 권한변수 설정
$this->grant = $grant; $this->grant = $grant;
Context::set('grant', $grant); Context::set('grant', $grant);
if(method_exists($this, 'init')) $this->init(); if(method_exists($this, 'init')) $this->init();
} }
/** /**
* @brief set the stop_proc and approprate message for msg_code * @brief set the stop_proc and approprate message for msg_code
* @param $msg_code an error code * @param $msg_code an error code
**/ **/
function stop($msg_code) { function stop($msg_code) {
// proc 수행을 중지 시키기 위한 플래그 세팅 // proc 수행을 중지 시키기 위한 플래그 세팅
$this->stop_proc = true; $this->stop_proc = true;
// 에러 처리 // 에러 처리
$this->setError(-1); $this->setError(-1);
$this->setMessage($msg_code); $this->setMessage($msg_code);
// message 모듈의 에러 표시 // message 모듈의 에러 표시
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view'; $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type); $oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
$oMessageObject->setError(-1); $oMessageObject->setError(-1);
$oMessageObject->setMessage($msg_code); $oMessageObject->setMessage($msg_code);
$oMessageObject->dispMessage(); $oMessageObject->dispMessage();
$this->setTemplatePath($oMessageObject->getTemplatePath()); $this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile()); $this->setTemplateFile($oMessageObject->getTemplateFile());
return $this; return $this;
} }
/** /**
* @brief set the file name of the template file * @brief set the file name of the template file
**/ **/
function setTemplateFile($filename) { function setTemplateFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html'; if(substr($filename,-5)!='.html') $filename .= '.html';
$this->template_file = $filename; $this->template_file = $filename;
} }
/** /**
* @brief retrieve the directory path of the template directory * @brief retrieve the directory path of the template directory
**/ **/
function getTemplateFile() { function getTemplateFile() {
return $this->template_file; return $this->template_file;
} }
/** /**
* @brief set the directory path of the template directory * @brief set the directory path of the template directory
**/ **/
function setTemplatePath($path) { function setTemplatePath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path; if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,-1)!='/') $path .= '/'; if(substr($path,-1)!='/') $path .= '/';
$this->template_path = $path; $this->template_path = $path;
} }
/** /**
* @brief retrieve the directory path of the template directory * @brief retrieve the directory path of the template directory
**/ **/
function getTemplatePath() { function getTemplatePath() {
return $this->template_path; return $this->template_path;
} }
/** /**
* @brief set the file name of the temporarily modified by admin * @brief set the file name of the temporarily modified by admin
**/ **/
function setEditedLayoutFile($filename) { function setEditedLayoutFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html'; if(substr($filename,-5)!='.html') $filename .= '.html';
$this->edited_layout_file = $filename; $this->edited_layout_file = $filename;
} }
/** /**
* @brief retreived the file name of edited_layout_file * @brief retreived the file name of edited_layout_file
**/ **/
function getEditedLayoutFile() { function getEditedLayoutFile() {
return $this->edited_layout_file; return $this->edited_layout_file;
} }
/** /**
* @brief set the file name of the layout file * @brief set the file name of the layout file
**/ **/
function setLayoutFile($filename) { function setLayoutFile($filename) {
if(substr($filename,-5)!='.html') $filename .= '.html'; if(substr($filename,-5)!='.html') $filename .= '.html';
$this->layout_file = $filename; $this->layout_file = $filename;
} }
/** /**
* @brief get the file name of the layout file * @brief get the file name of the layout file
**/ **/
function getLayoutFile() { function getLayoutFile() {
return $this->layout_file; return $this->layout_file;
} }
/** /**
* @brief set the directory path of the layout directory * @brief set the directory path of the layout directory
**/ **/
function setLayoutPath($path) { function setLayoutPath($path) {
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path; if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
if(substr($path,-1)!='/') $path .= '/'; if(substr($path,-1)!='/') $path .= '/';
$this->layout_path = $path; $this->layout_path = $path;
} }
/** /**
* @brief set the directory path of the layout directory * @brief set the directory path of the layout directory
**/ **/
function getLayoutPath() { function getLayoutPath() {
return $this->layout_path; return $this->layout_path;
} }
/** /**
* @brief excute the member method specified by $act variable * @brief excute the member method specified by $act variable
* *
**/ **/
function proc() { function proc() {
// stop_proc==true이면 그냥 패스 // stop_proc==true이면 그냥 패스
if($this->stop_proc) return false; if($this->stop_proc) return false;
// addon 실행(called_position 를 before_module_proc로 하여 호출) // addon 실행(called_position 를 before_module_proc로 하여 호출)
$called_position = 'before_module_proc'; $called_position = 'before_module_proc';
$oAddonController = &getController('addon'); $oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc"); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file); @include($addon_file);
if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) { if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act)) {
// 권한 체크 // 권한 체크
if(!$this->grant->access) return $this->stop("msg_not_permitted_act"); if(!$this->grant->access) return $this->stop("msg_not_permitted_act");
// 모듈의 스킨 정보를 연동 (스킨 정보의 테이블 분리로 동작대상 모듈에만 스킨 정보를 싱크시키도록 변경) // 모듈의 스킨 정보를 연동 (스킨 정보의 테이블 분리로 동작대상 모듈에만 스킨 정보를 싱크시키도록 변경)
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
$oModuleModel->syncSkinInfoToModuleInfo($this->module_info); $oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
Context::set('module_info', $this->module_info); Context::set('module_info', $this->module_info);
// 실행 // 실행
$output = $this->{$this->act}(); $output = $this->{$this->act}();
} }
else { else {
return false; return false;
} }
// addon 실행(called_position 를 after_module_proc로 하여 호출) // addon 실행(called_position 를 after_module_proc로 하여 호출)
$called_position = 'after_module_proc'; $called_position = 'after_module_proc';
$oAddonController = &getController('addon'); $oAddonController = &getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc"); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone()?"mobile":"pc");
@include($addon_file); @include($addon_file);
if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) { if(is_a($output, 'Object') || is_subclass_of($output, 'Object')) {
$this->setError($output->getError()); $this->setError($output->getError());
$this->setMessage($output->getMessage()); $this->setMessage($output->getMessage());
return false; return false;
} }
// view action이고 결과 출력이 XMLRPC 또는 JSON일 경우 해당 모듈의 api method를 실행 // view action이고 결과 출력이 XMLRPC 또는 JSON일 경우 해당 모듈의 api method를 실행
if($this->module_info->module_type == 'view'){ if($this->module_info->module_type == 'view'){
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') { if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
$oAPI = getAPI($this->module_info->module, 'api'); $oAPI = getAPI($this->module_info->module, 'api');
if(method_exists($oAPI, $this->act)) { if(method_exists($oAPI, $this->act)) {
$oAPI->{$this->act}($this); $oAPI->{$this->act}($this);
} }
} }
} }
return true; return true;
} }
} }
?> ?>