mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
issue 2119. supporting php 5.4. module classes.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12691 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
9aa87c343f
commit
2383b8d711
2 changed files with 1475 additions and 1221 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class ModuleHandler
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
|
|
@ -8,17 +9,15 @@
|
|||
* Constructing an instance without any parameterconstructor, it finds the target module based on Context.
|
||||
* If there is no act on the found module, excute an action referencing action_forward.
|
||||
* */
|
||||
|
||||
class ModuleHandler extends Handler {
|
||||
class ModuleHandler extends Handler
|
||||
{
|
||||
|
||||
var $module = NULL; ///< Module
|
||||
var $act = NULL; ///< action
|
||||
var $mid = NULL; ///< Module ID
|
||||
var $document_srl = NULL; ///< Document Number
|
||||
var $module_srl = NULL; ///< Module Number
|
||||
|
||||
var $module_info = NULL; ///< Module Info. Object
|
||||
|
||||
var $error = NULL; ///< an error code.
|
||||
var $httpStatusCode = NULL; ///< http status code.
|
||||
|
||||
|
|
@ -31,16 +30,19 @@
|
|||
* @param int $module_srl
|
||||
* @return void
|
||||
* */
|
||||
function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '') {
|
||||
|
||||
function ModuleHandler($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
|
||||
{
|
||||
// If XE has not installed yet, set module as install
|
||||
if(!Context::isInstalled()) {
|
||||
if(!Context::isInstalled())
|
||||
{
|
||||
$this->module = 'install';
|
||||
$this->act = Context::get('act');
|
||||
return;
|
||||
}
|
||||
|
||||
$oContext = Context::getInstance();
|
||||
if($oContext->isSuccessInit == false)
|
||||
if($oContext->isSuccessInit == FALSE)
|
||||
{
|
||||
$this->error = 'msg_invalid_request';
|
||||
return;
|
||||
|
|
@ -55,10 +57,19 @@
|
|||
$this->entry = Context::convertEncodingStr(Context::get('entry'));
|
||||
|
||||
// Validate variables to prevent XSS
|
||||
$isInvalid = null;
|
||||
if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i",$this->module)) $isInvalid = true;
|
||||
if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i",$this->mid)) $isInvalid = true;
|
||||
if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i",$this->act)) $isInvalid = true;
|
||||
$isInvalid = NULL;
|
||||
if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module))
|
||||
{
|
||||
$isInvalid = TRUE;
|
||||
}
|
||||
if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid))
|
||||
{
|
||||
$isInvalid = TRUE;
|
||||
}
|
||||
if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act))
|
||||
{
|
||||
$isInvalid = TRUE;
|
||||
}
|
||||
if($isInvalid)
|
||||
{
|
||||
htmlHeader();
|
||||
|
|
@ -79,7 +90,7 @@
|
|||
|
||||
// execute addon (before module initialization)
|
||||
$called_position = 'before_module_init';
|
||||
$oAddonController = &getController('addon');
|
||||
$oAddonController = getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? 'mobile' : 'pc');
|
||||
@include($addon_file);
|
||||
}
|
||||
|
|
@ -88,73 +99,105 @@
|
|||
* Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action
|
||||
* @return boolean true: OK, false: redirected
|
||||
* */
|
||||
function init() {
|
||||
$oModuleModel = &getModel('module');
|
||||
function init()
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
|
||||
if(!$this->document_srl && $this->mid && $this->entry) {
|
||||
if(!$this->document_srl && $this->mid && $this->entry)
|
||||
{
|
||||
$oDocumentModel = &getModel('document');
|
||||
$this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry);
|
||||
if($this->document_srl) Context::set('document_srl', $this->document_srl);
|
||||
if($this->document_srl)
|
||||
{
|
||||
Context::set('document_srl', $this->document_srl);
|
||||
}
|
||||
}
|
||||
|
||||
// Get module's information based on document_srl, if it's specified
|
||||
if($this->document_srl && !$this->module) {
|
||||
if($this->document_srl && !$this->module)
|
||||
{
|
||||
$module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl);
|
||||
|
||||
// If the document does not exist, remove document_srl
|
||||
if(!$module_info) {
|
||||
if(!$module_info)
|
||||
{
|
||||
unset($this->document_srl);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it exists, compare mid based on the module information
|
||||
// if mids are not matching, set it as the document's mid
|
||||
if($this->mid != $module_info->mid) {
|
||||
if($this->mid != $module_info->mid)
|
||||
{
|
||||
$this->mid = $module_info->mid;
|
||||
Context::set('mid', $module_info->mid, true);
|
||||
Context::set('mid', $module_info->mid, TRUE);
|
||||
header('location:' . getNotEncodedSiteUrl($site_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl));
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// if requested module is different from one of the document, remove the module information retrieved based on the document number
|
||||
if($this->module && $module_info->module != $this->module) unset($module_info);
|
||||
if($this->module && $module_info->module != $this->module)
|
||||
{
|
||||
unset($module_info);
|
||||
}
|
||||
}
|
||||
|
||||
// If module_info is not set yet, and there exists mid information, get module information based on the mid
|
||||
if(!$module_info && $this->mid) {
|
||||
if(!$module_info && $this->mid)
|
||||
{
|
||||
$module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl);
|
||||
//if($this->module && $module_info->module != $this->module) unset($module_info);
|
||||
}
|
||||
|
||||
// redirect, if module_site_srl and site_srl are different
|
||||
if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) {
|
||||
if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0)
|
||||
{
|
||||
$site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl);
|
||||
header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid));
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// If module_info is not set still, and $module does not exist, find the default module
|
||||
if(!$module_info && !$this->module && !$this->mid) $module_info = $site_module_info;
|
||||
if(!$module_info && !$this->module && !$this->mid)
|
||||
{
|
||||
$module_info = $site_module_info;
|
||||
}
|
||||
|
||||
if(!$module_info && !$this->module && $site_module_info->module_site_srl) $module_info = $site_module_info;
|
||||
if(!$module_info && !$this->module && $site_module_info->module_site_srl)
|
||||
{
|
||||
$module_info = $site_module_info;
|
||||
}
|
||||
|
||||
// redirect, if site_srl of module_info is different from one of site's module_info
|
||||
if($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler()) {
|
||||
if($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler())
|
||||
{
|
||||
// If the module is of virtual site
|
||||
if($module_info->site_srl) {
|
||||
if($module_info->site_srl)
|
||||
{
|
||||
$site_info = $oModuleModel->getSiteInfo($module_info->site_srl);
|
||||
$redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
|
||||
// If it's called from a virtual site, though it's not a module of the virtual site
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$db_info = Context::getDBInfo();
|
||||
if(!$db_info->default_url) return Context::getLang('msg_default_url_is_not_defined');
|
||||
else $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid',Context::get('mid'),'document_srl',Context::get('document_srl'),'module_srl',Context::get('module_srl'),'entry',Context::get('entry'));
|
||||
if(!$db_info->default_url)
|
||||
{
|
||||
return Context::getLang('msg_default_url_is_not_defined');
|
||||
}
|
||||
else
|
||||
{
|
||||
$redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
|
||||
}
|
||||
}
|
||||
header("location:" . $redirect_url);
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// If module info was set, retrieve variables from the module information
|
||||
if($module_info) {
|
||||
if($module_info)
|
||||
{
|
||||
$this->module = $module_info->module;
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module_info = $module_info;
|
||||
|
|
@ -182,6 +225,10 @@
|
|||
}
|
||||
|
||||
// Set module and mid into module_info
|
||||
if(!isset($this->module_info))
|
||||
{
|
||||
$this->module_info = new stdClass();
|
||||
}
|
||||
$this->module_info->module = $this->module;
|
||||
$this->module_info->mid = $this->mid;
|
||||
|
||||
|
|
@ -196,33 +243,39 @@
|
|||
}
|
||||
|
||||
// If mid exists, set mid into context
|
||||
if($this->mid) Context::set('mid', $this->mid, true);
|
||||
if($this->mid)
|
||||
{
|
||||
Context::set('mid', $this->mid, TRUE);
|
||||
}
|
||||
|
||||
// Call a trigger after moduleHandler init
|
||||
$output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info);
|
||||
if(!$output->toBool()) {
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$this->error = $output->getMessage();
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Set current module info into context
|
||||
Context::set('current_module_info', $this->module_info);
|
||||
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* get a module instance and execute an action
|
||||
* @return ModuleObject executed module instance
|
||||
* */
|
||||
function procModule() {
|
||||
$oModuleModel = &getModel('module');
|
||||
function procModule()
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
|
||||
// If error occurred while preparation, return a message instance
|
||||
if($this->error) {
|
||||
if($this->error)
|
||||
{
|
||||
$this->_setInputErrorToContext();
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -237,21 +290,29 @@
|
|||
$xml_info = $oModuleModel->getModuleActionXml($this->module);
|
||||
|
||||
// If not installed yet, modify act
|
||||
if($this->module=="install") {
|
||||
if(!$this->act || !$xml_info->action->{$this->act}) $this->act = $xml_info->default_index_act;
|
||||
if($this->module == "install")
|
||||
{
|
||||
if(!$this->act || !$xml_info->action->{$this->act})
|
||||
{
|
||||
$this->act = $xml_info->default_index_act;
|
||||
}
|
||||
}
|
||||
|
||||
// if act exists, find type of the action, if not use default index act
|
||||
if(!$this->act) $this->act = $xml_info->default_index_act;
|
||||
if(!$this->act)
|
||||
{
|
||||
$this->act = $xml_info->default_index_act;
|
||||
}
|
||||
|
||||
// still no act means error
|
||||
if(!$this->act) {
|
||||
if(!$this->act)
|
||||
{
|
||||
$this->error = 'msg_module_is_not_exists';
|
||||
$this->httpStatusCode = '404';
|
||||
|
||||
$this->_setInputErrorToContext();
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -265,16 +326,23 @@
|
|||
// get type, kind
|
||||
$type = $xml_info->action->{$this->act}->type;
|
||||
$ruleset = $xml_info->action->{$this->act}->ruleset;
|
||||
$kind = strpos(strtolower($this->act),'admin')!==false?'admin':'';
|
||||
if(!$kind && $this->module == 'admin') $kind = 'admin';
|
||||
if($this->module_info->use_mobile != "Y") Mobile::setMobile(false);
|
||||
$kind = strpos(strtolower($this->act), 'admin') !== FALSE ? 'admin' : '';
|
||||
if(!$kind && $this->module == 'admin')
|
||||
{
|
||||
$kind = 'admin';
|
||||
}
|
||||
if($this->module_info->use_mobile != "Y")
|
||||
{
|
||||
Mobile::setMobile(FALSE);
|
||||
}
|
||||
|
||||
// Admin ip
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($kind == 'admin' && $_SESSION['denied_admin'] == 'Y'){
|
||||
if($kind == 'admin' && $_SESSION['denied_admin'] == 'Y')
|
||||
{
|
||||
$this->_setInputErrorToContext();
|
||||
$this->error = "msg_not_permitted_act";
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -287,23 +355,25 @@
|
|||
$orig_type = "view";
|
||||
$type = "mobile";
|
||||
// create a module instance
|
||||
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||
if(!is_object($oModule) || !method_exists($oModule, $this->act)) {
|
||||
$oModule = $this->getModuleInstance($this->module, $type, $kind);
|
||||
if(!is_object($oModule) || !method_exists($oModule, $this->act))
|
||||
{
|
||||
$type = $orig_type;
|
||||
Mobile::setMobile(false);
|
||||
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||
Mobile::setMobile(FALSE);
|
||||
$oModule = $this->getModuleInstance($this->module, $type, $kind);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create a module instance
|
||||
$oModule = &$this->getModuleInstance($this->module, $type, $kind);
|
||||
$oModule = $this->getModuleInstance($this->module, $type, $kind);
|
||||
}
|
||||
|
||||
if(!is_object($oModule)) {
|
||||
if(!is_object($oModule))
|
||||
{
|
||||
$this->_setInputErrorToContext();
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -322,7 +392,7 @@
|
|||
{
|
||||
$this->_setInputErrorToContext();
|
||||
$this->error = 'msg_invalid_request';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -333,12 +403,15 @@
|
|||
return $oMessageObject;
|
||||
}
|
||||
|
||||
$forward = null;
|
||||
$forward = NULL;
|
||||
// 1. Look for the module with action name
|
||||
if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches)) {
|
||||
if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches))
|
||||
{
|
||||
$module = strtolower($matches[2] . $matches[3]);
|
||||
$xml_info = $oModuleModel->getModuleActionXml($module);
|
||||
if($xml_info->action->{$this->act}) {
|
||||
if($xml_info->action->{$this->act})
|
||||
{
|
||||
$forward = new stdClass();
|
||||
$forward->module = $module;
|
||||
$forward->type = $xml_info->action->{$this->act}->type;
|
||||
$forward->ruleset = $xml_info->action->{$this->act}->ruleset;
|
||||
|
|
@ -351,8 +424,9 @@
|
|||
$forward = $oModuleModel->getActionForward($this->act);
|
||||
}
|
||||
|
||||
if($forward->module && $forward->type && $forward->act && $forward->act == $this->act) {
|
||||
$kind = strpos(strtolower($forward->act),'admin')!==false?'admin':'';
|
||||
if($forward->module && $forward->type && $forward->act && $forward->act == $this->act)
|
||||
{
|
||||
$kind = strpos(strtolower($forward->act), 'admin') !== FALSE ? 'admin' : '';
|
||||
$type = $forward->type;
|
||||
$ruleset = $forward->ruleset;
|
||||
$tpl_path = $oModule->getTemplatePath();
|
||||
|
|
@ -363,22 +437,24 @@
|
|||
$orig_type = "view";
|
||||
$type = "mobile";
|
||||
// create a module instance
|
||||
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
|
||||
if(!is_object($oModule) || !method_exists($oModule, $this->act)) {
|
||||
$oModule = $this->getModuleInstance($forward->module, $type, $kind);
|
||||
if(!is_object($oModule) || !method_exists($oModule, $this->act))
|
||||
{
|
||||
$type = $orig_type;
|
||||
Mobile::setMobile(false);
|
||||
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
|
||||
Mobile::setMobile(FALSE);
|
||||
$oModule = $this->getModuleInstance($forward->module, $type, $kind);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$oModule = &$this->getModuleInstance($forward->module, $type, $kind);
|
||||
$oModule = $this->getModuleInstance($forward->module, $type, $kind);
|
||||
}
|
||||
|
||||
if(!is_object($oModule)) {
|
||||
if(!is_object($oModule))
|
||||
{
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$this->_setInputErrorToContext();
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage('msg_module_is_not_exists');
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -390,41 +466,45 @@
|
|||
}
|
||||
|
||||
$xml_info = $oModuleModel->getModuleActionXml($forward->module);
|
||||
$oMemberModel = &getModel('member');
|
||||
$oMemberModel = getModel('member');
|
||||
|
||||
if($this->module == "admin" && $type == "view")
|
||||
{
|
||||
if($logged_info->is_admin=='Y'){
|
||||
if($logged_info->is_admin == 'Y')
|
||||
{
|
||||
if($this->act != 'dispLayoutAdminLayoutModify')
|
||||
{
|
||||
$oAdminView = &getAdminView('admin');
|
||||
$oAdminView = getAdminView('admin');
|
||||
$oAdminView->makeGnbUrl($forward->module);
|
||||
$oModule->setLayoutPath("./modules/admin/tpl");
|
||||
$oModule->setLayoutFile("layout.html");
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_setInputErrorToContext();
|
||||
|
||||
$this->error = 'msg_is_not_administrator';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
return $oMessageObject;
|
||||
}
|
||||
}
|
||||
if ($kind == 'admin'){
|
||||
if($kind == 'admin')
|
||||
{
|
||||
$grant = $oModuleModel->getGrant($this->module_info, $logged_info);
|
||||
if(!$grant->is_admin && !$grant->manager) {
|
||||
if(!$grant->is_admin && !$grant->manager)
|
||||
{
|
||||
$this->_setInputErrorToContext();
|
||||
$this->error = 'msg_is_not_manager';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message','view');
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', 'view');
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
return $oMessageObject;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act))
|
||||
|
|
@ -494,7 +574,8 @@
|
|||
Context::addHtmlFooter($footer);
|
||||
}
|
||||
|
||||
if($type == "view" && $kind != 'admin'){
|
||||
if($type == "view" && $kind != 'admin')
|
||||
{
|
||||
$module_config = $oModuleModel->getModuleConfig('module');
|
||||
if($module_config->htmlFooter)
|
||||
{
|
||||
|
|
@ -526,9 +607,11 @@
|
|||
if(!$procResult)
|
||||
{
|
||||
$this->error = $message;
|
||||
if (!$redirectUrl && Context::get('error_return_url')) $redirectUrl = Context::get('error_return_url');
|
||||
if(!$redirectUrl && Context::get('error_return_url'))
|
||||
{
|
||||
$redirectUrl = Context::get('error_return_url');
|
||||
}
|
||||
$this->_setInputValueToSession();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -540,7 +623,10 @@
|
|||
}
|
||||
|
||||
$_SESSION['XE_VALIDATOR_ERROR'] = $error;
|
||||
if ($message != 'success') $_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
|
||||
if($message != 'success')
|
||||
{
|
||||
$_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
|
||||
}
|
||||
$_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
|
||||
|
||||
if(Context::get('xeVirtualRequestMethod') != 'xml')
|
||||
|
|
@ -559,10 +645,22 @@
|
|||
* */
|
||||
function _setInputErrorToContext()
|
||||
{
|
||||
if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR')) Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
|
||||
if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE')) Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']);
|
||||
if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE')) Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
|
||||
if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL')) Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']);
|
||||
if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR'))
|
||||
{
|
||||
Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
|
||||
}
|
||||
if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE'))
|
||||
{
|
||||
Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']);
|
||||
}
|
||||
if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE'))
|
||||
{
|
||||
Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
|
||||
}
|
||||
if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL'))
|
||||
{
|
||||
Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']);
|
||||
}
|
||||
|
||||
$this->_clearErrorSession();
|
||||
}
|
||||
|
|
@ -587,7 +685,10 @@
|
|||
{
|
||||
$requestVars = Context::getRequestVars();
|
||||
unset($requestVars->act, $requestVars->mid, $requestVars->vid, $requestVars->success_return_url, $requestVars->error_return_url);
|
||||
foreach($requestVars AS $key=>$value) $_SESSION['INPUT_ERROR'][$key] = $value;
|
||||
foreach($requestVars AS $key => $value)
|
||||
{
|
||||
$_SESSION['INPUT_ERROR'][$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -595,25 +696,32 @@
|
|||
* @param ModuleObject $oModule module instance
|
||||
* @return void
|
||||
* */
|
||||
function displayContent($oModule = NULL) {
|
||||
function displayContent($oModule = NULL)
|
||||
{
|
||||
// If the module is not set or not an object, set error
|
||||
if(!$oModule || !is_object($oModule)) {
|
||||
if(!$oModule || !is_object($oModule))
|
||||
{
|
||||
$this->error = 'msg_module_is_not_exists';
|
||||
$this->httpStatusCode = '404';
|
||||
}
|
||||
|
||||
// If connection to DB has a problem even though it's not install module, set error
|
||||
if($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == false) {
|
||||
if($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE)
|
||||
{
|
||||
$this->error = 'msg_dbconnect_failed';
|
||||
}
|
||||
|
||||
// Call trigger after moduleHandler proc
|
||||
$output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
|
||||
if(!$output->toBool()) $this->error = $output->getMessage();
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$this->error = $output->getMessage();
|
||||
}
|
||||
|
||||
// Use message view object, if HTML call
|
||||
$methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
|
||||
if(!isset($methodList[Context::getRequestMethod()])) {
|
||||
if(!isset($methodList[Context::getRequestMethod()]))
|
||||
{
|
||||
|
||||
if($_SESSION['XE_VALIDATOR_RETURN_URL'])
|
||||
{
|
||||
|
|
@ -625,10 +733,11 @@
|
|||
}
|
||||
|
||||
// If error occurred, handle it
|
||||
if($this->error) {
|
||||
if($this->error)
|
||||
{
|
||||
// display content with message module instance
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($this->error);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -640,11 +749,14 @@
|
|||
}
|
||||
|
||||
// If module was called normally, change the templates of the module into ones of the message view module
|
||||
if($oModule) {
|
||||
if($oModule)
|
||||
{
|
||||
$oModule->setTemplatePath($oMessageObject->getTemplatePath());
|
||||
$oModule->setTemplateFile($oMessageObject->getTemplateFile());
|
||||
// Otherwise, set message instance as the target module
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$oModule = $oMessageObject;
|
||||
}
|
||||
|
||||
|
|
@ -665,34 +777,44 @@
|
|||
if($layout_srl == -1)
|
||||
{
|
||||
$viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
|
||||
$oLayoutAdminModel = &getAdminModel('layout');
|
||||
$oLayoutAdminModel = getAdminModel('layout');
|
||||
$layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
|
||||
}
|
||||
|
||||
if($layout_srl && !$oModule->getLayoutFile()) {
|
||||
if($layout_srl && !$oModule->getLayoutFile())
|
||||
{
|
||||
|
||||
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
|
||||
$oLayoutModel = &getModel('layout');
|
||||
$oLayoutModel = getModel('layout');
|
||||
$layout_info = $oLayoutModel->getLayout($layout_srl);
|
||||
if($layout_info) {
|
||||
if($layout_info)
|
||||
{
|
||||
|
||||
// Input extra_vars into $layout_info
|
||||
if($layout_info->extra_var_count) {
|
||||
if($layout_info->extra_var_count)
|
||||
{
|
||||
|
||||
foreach($layout_info->extra_var as $var_id => $val) {
|
||||
if($val->type == 'image') {
|
||||
if(preg_match('/^\.\/files\/attach\/images\/(.+)/i',$val->value)) $val->value = Context::getRequestUri().substr($val->value,2);
|
||||
foreach($layout_info->extra_var as $var_id => $val)
|
||||
{
|
||||
if($val->type == 'image')
|
||||
{
|
||||
if(preg_match('/^\.\/files\/attach\/images\/(.+)/i', $val->value))
|
||||
{
|
||||
$val->value = Context::getRequestUri() . substr($val->value, 2);
|
||||
}
|
||||
}
|
||||
$layout_info->{$var_id} = $val->value;
|
||||
}
|
||||
}
|
||||
// Set menus into context
|
||||
if($layout_info->menu_count) {
|
||||
foreach($layout_info->menu as $menu_id => $menu) {
|
||||
if($layout_info->menu_count)
|
||||
{
|
||||
foreach($layout_info->menu as $menu_id => $menu)
|
||||
{
|
||||
// set default menu set(included home menu)
|
||||
if(!$menu->menu_srl || $menu->menu_srl == -1)
|
||||
{
|
||||
$oMenuAdminController = &getAdminController('menu');
|
||||
$oMenuAdminController = getAdminController('menu');
|
||||
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
|
||||
|
||||
if(file_exists($homeMenuCacheFile))
|
||||
|
|
@ -711,7 +833,10 @@
|
|||
$menu->php_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->php_file);
|
||||
}
|
||||
}
|
||||
if(file_exists($menu->php_file)) @include($menu->php_file);
|
||||
if(file_exists($menu->php_file))
|
||||
{
|
||||
@include($menu->php_file);
|
||||
}
|
||||
Context::set($menu_id, $menu);
|
||||
}
|
||||
}
|
||||
|
|
@ -724,13 +849,16 @@
|
|||
|
||||
// If layout was modified, use the modified version
|
||||
$edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
|
||||
if(file_exists($edited_layout)) $oModule->setEditedLayoutFile($edited_layout);
|
||||
if(file_exists($edited_layout))
|
||||
{
|
||||
$oModule->setEditedLayoutFile($edited_layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
$isLayoutDrop = Context::get('isLayoutDrop');
|
||||
if($isLayoutDrop)
|
||||
{
|
||||
$kind = strpos(strtolower($this->act),'admin')!==false?'admin':'';
|
||||
$kind = strpos(strtolower($this->act), 'admin') !== FALSE ? 'admin' : '';
|
||||
if($kind == 'admin')
|
||||
{
|
||||
$oModule->setLayoutFile('popup_layout');
|
||||
|
|
@ -753,7 +881,8 @@
|
|||
* @param string $module module name
|
||||
* @return string path of the module
|
||||
* */
|
||||
function getModulePath($module) {
|
||||
function getModulePath($module)
|
||||
{
|
||||
return sprintf('./modules/%s/', $module);
|
||||
}
|
||||
|
||||
|
|
@ -765,16 +894,23 @@
|
|||
* @return ModuleObject module instance (if failed it returns null)
|
||||
* @remarks if there exists a module instance created before, returns it.
|
||||
* */
|
||||
function &getModuleInstance($module, $type = 'view', $kind = '') {
|
||||
function &getModuleInstance($module, $type = 'view', $kind = '')
|
||||
{
|
||||
|
||||
if(__DEBUG__==3) $start_time = getMicroTime();
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$start_time = getMicroTime();
|
||||
}
|
||||
|
||||
$parent_module = $module;
|
||||
$kind = strtolower($kind);
|
||||
$type = strtolower($type);
|
||||
|
||||
$kinds = array('svc' => 1, 'admin' => 1);
|
||||
if(!isset($kinds[$kind])) $kind = 'svc';
|
||||
if(!isset($kinds[$kind]))
|
||||
{
|
||||
$kind = 'svc';
|
||||
}
|
||||
|
||||
$key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
|
||||
|
||||
|
|
@ -795,25 +931,39 @@
|
|||
}
|
||||
|
||||
// Get base class name and load the file contains it
|
||||
if(!class_exists($module)) {
|
||||
if(!class_exists($module))
|
||||
{
|
||||
$high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
|
||||
if(!file_exists($high_class_file)) return NULL;
|
||||
if(!file_exists($high_class_file))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
require_once($high_class_file);
|
||||
}
|
||||
|
||||
// Get the name of the class file
|
||||
if(!is_readable($class_file)) return NULL;
|
||||
if(!is_readable($class_file))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create an instance with eval function
|
||||
require_once($class_file);
|
||||
if(!class_exists($instance_name)) return NULL;
|
||||
require($class_file);
|
||||
if(!class_exists($instance_name))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
$tmp_fn = create_function('', "return new {$instance_name}();");
|
||||
$oModule = $tmp_fn();
|
||||
if(!is_object($oModule)) return NULL;
|
||||
if(!is_object($oModule))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Load language files for the class
|
||||
Context::loadLang($class_path . 'lang');
|
||||
if($extend_module) {
|
||||
if($extend_module)
|
||||
{
|
||||
Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
|
||||
}
|
||||
|
||||
|
|
@ -822,16 +972,23 @@
|
|||
$oModule->setModulePath($class_path);
|
||||
|
||||
// If the module has a constructor, run it.
|
||||
if(!isset($GLOBALS['_called_constructor'][$instance_name])) {
|
||||
$GLOBALS['_called_constructor'][$instance_name] = true;
|
||||
if(@method_exists($oModule, $instance_name)) $oModule->{$instance_name}();
|
||||
if(!isset($GLOBALS['_called_constructor'][$instance_name]))
|
||||
{
|
||||
$GLOBALS['_called_constructor'][$instance_name] = TRUE;
|
||||
if(@method_exists($oModule, $instance_name))
|
||||
{
|
||||
$oModule->{$instance_name}();
|
||||
}
|
||||
}
|
||||
|
||||
// Store the created instance into GLOBALS variable
|
||||
$GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
|
||||
}
|
||||
|
||||
if(__DEBUG__==3) $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
|
||||
if(__DEBUG__ == 3)
|
||||
{
|
||||
$GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
|
||||
}
|
||||
|
||||
// return the instance
|
||||
return $GLOBALS['_loaded_module'][$module][$type][$kind];
|
||||
|
|
@ -845,14 +1002,22 @@
|
|||
$highClassFile = FileHandler::getRealPath($highClassFile);
|
||||
|
||||
$types = explode(' ', 'view controller model api wap mobile class');
|
||||
if(!in_array($type, $types)) $type = $types[0];
|
||||
if($type == 'class') {
|
||||
if(!in_array($type, $types))
|
||||
{
|
||||
$type = $types[0];
|
||||
}
|
||||
if($type == 'class')
|
||||
{
|
||||
$instanceName = '%s';
|
||||
$classFile = '%s%s.%s.php';
|
||||
} elseif($kind == 'admin' && array_search($type, $types) < 3) {
|
||||
}
|
||||
elseif($kind == 'admin' && array_search($type, $types) < 3)
|
||||
{
|
||||
$instanceName = '%sAdmin%s';
|
||||
$classFile = '%s%s.admin.%s.php';
|
||||
} else{
|
||||
}
|
||||
else
|
||||
{
|
||||
$instanceName = '%s%s';
|
||||
$classFile = '%s%s.%s.php';
|
||||
}
|
||||
|
|
@ -869,25 +1034,39 @@
|
|||
* @param object $obj an object as a parameter to trigger
|
||||
* @return Object
|
||||
* */
|
||||
function triggerCall($trigger_name, $called_position, &$obj) {
|
||||
function triggerCall($trigger_name, $called_position, &$obj)
|
||||
{
|
||||
// skip if not installed
|
||||
if(!Context::isInstalled()) return new Object();
|
||||
if(!Context::isInstalled())
|
||||
{
|
||||
return new Object();
|
||||
}
|
||||
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleModel = getModel('module');
|
||||
$triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
|
||||
if(!$triggers || !count($triggers)) return new Object();
|
||||
if(!$triggers || !count($triggers))
|
||||
{
|
||||
return new Object();
|
||||
}
|
||||
|
||||
foreach($triggers as $item) {
|
||||
foreach($triggers as $item)
|
||||
{
|
||||
$module = $item->module;
|
||||
$type = $item->type;
|
||||
$called_method = $item->called_method;
|
||||
|
||||
$oModule = null;
|
||||
$oModule = &getModule($module, $type);
|
||||
if(!$oModule || !method_exists($oModule, $called_method)) continue;
|
||||
$oModule = NULL;
|
||||
$oModule = getModule($module, $type);
|
||||
if(!$oModule || !method_exists($oModule, $called_method))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$output = $oModule->{$called_method}($obj);
|
||||
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) return $output;
|
||||
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
unset($oModule);
|
||||
}
|
||||
|
||||
|
|
@ -899,7 +1078,8 @@
|
|||
* @param string $code
|
||||
* @return string
|
||||
* */
|
||||
function _setHttpStatusMessage($code) {
|
||||
function _setHttpStatusMessage($code)
|
||||
{
|
||||
$statusMessageList = array(
|
||||
'100' => 'Continue',
|
||||
'101' => 'Switching Protocols',
|
||||
|
|
@ -943,10 +1123,14 @@
|
|||
'505' => 'HTTP Version Not Supported',
|
||||
);
|
||||
$statusMessage = $statusMessageList[$code];
|
||||
if(!$statusMessage) $statusMessage = 'OK';
|
||||
if(!$statusMessage)
|
||||
{
|
||||
$statusMessage = 'OK';
|
||||
}
|
||||
|
||||
Context::set('http_status_code', $code);
|
||||
Context::set('http_status_message', $statusMessage);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class ModuleObject
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* 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 $module = NULL; ///< Class name of Xe Module that is identified by mid
|
||||
|
|
@ -13,23 +14,16 @@
|
|||
var $module_info = NULL; ///< an object containing the module information
|
||||
var $origin_module_info = NULL;
|
||||
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 $act = NULL; ///< a string value to contain the action name
|
||||
|
||||
var $template_path = NULL; ///< a path of directory where template files reside
|
||||
var $template_file = NULL; ///< name of template file
|
||||
|
||||
var $layout_path = ''; ///< a path of directory where layout files reside
|
||||
var $layout_file = ''; ///< name of layout file
|
||||
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 $module_config = NULL;
|
||||
var $ajaxRequestMethod = array('XMLRPC', 'JSON');
|
||||
|
||||
var $gzhandler_enable = TRUE;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +31,8 @@
|
|||
* @param string $module name of module
|
||||
* @return void
|
||||
* */
|
||||
function setModule($module) {
|
||||
function setModule($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +41,12 @@
|
|||
* @param string $path the directory path to a module directory
|
||||
* @return void
|
||||
* */
|
||||
function setModulePath($path) {
|
||||
if(substr($path,-1)!='/') $path.='/';
|
||||
function setModulePath($path)
|
||||
{
|
||||
if(substr($path, -1) != '/')
|
||||
{
|
||||
$path.='/';
|
||||
}
|
||||
$this->module_path = $path;
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +56,8 @@
|
|||
* @remark redirect_url is used only for ajax requests
|
||||
* @return void
|
||||
* */
|
||||
function setRedirectUrl($url='./', $output = NULL) {
|
||||
function setRedirectUrl($url = './', $output = NULL)
|
||||
{
|
||||
$ajaxRequestMethod = array_flip($this->ajaxRequestMethod);
|
||||
if(!isset($ajaxRequestMethod[Context::getRequestMethod()]))
|
||||
{
|
||||
|
|
@ -74,7 +74,8 @@
|
|||
* get url for redirection
|
||||
* @return string redirect_url
|
||||
* */
|
||||
function getRedirectUrl(){
|
||||
function getRedirectUrl()
|
||||
{
|
||||
return $this->get('redirect_url');
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +85,8 @@
|
|||
* @param string $type type of message (error, info, update)
|
||||
* @return void
|
||||
* */
|
||||
function setMessage($message, $type = null){
|
||||
function setMessage($message, $type = NULL)
|
||||
{
|
||||
parent::setMessage($message);
|
||||
$this->setMessageType($type);
|
||||
}
|
||||
|
|
@ -94,7 +96,8 @@
|
|||
* @param string $type type of message (error, info, update)
|
||||
* @return void
|
||||
* */
|
||||
function setMessageType($type){
|
||||
function setMessageType($type)
|
||||
{
|
||||
$this->add('message_type', $type);
|
||||
}
|
||||
|
||||
|
|
@ -102,10 +105,12 @@
|
|||
* get type of message
|
||||
* @return string $type
|
||||
* */
|
||||
function getMessageType(){
|
||||
function getMessageType()
|
||||
{
|
||||
$type = $this->get('message_type');
|
||||
$typeList = array('error' => 1, 'info' => 1, 'update' => 1);
|
||||
if (!isset($typeList[$type])){
|
||||
if(!isset($typeList[$type]))
|
||||
{
|
||||
$type = $this->getError() ? 'error' : 'info';
|
||||
}
|
||||
return $type;
|
||||
|
|
@ -117,18 +122,19 @@
|
|||
* Tpl as the common run of the refresh.html ..
|
||||
* @return void
|
||||
* */
|
||||
function setRefreshPage() {
|
||||
function setRefreshPage()
|
||||
{
|
||||
$this->setTemplatePath('./common/tpl');
|
||||
$this->setTemplateFile('refresh');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sett to set the action name
|
||||
* @param string $act
|
||||
* @return void
|
||||
* */
|
||||
function setAct($act) {
|
||||
function setAct($act)
|
||||
{
|
||||
$this->act = $act;
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +144,8 @@
|
|||
* @param object $xml_info object containing module description
|
||||
* @return void
|
||||
* */
|
||||
function setModuleInfo($module_info, $xml_info) {
|
||||
function setModuleInfo($module_info, $xml_info)
|
||||
{
|
||||
// The default variable settings
|
||||
$this->mid = $module_info->mid;
|
||||
$this->module_srl = $module_info->module_srl;
|
||||
|
|
@ -150,30 +157,41 @@
|
|||
$is_logged = Context::get('is_logged');
|
||||
$logged_info = Context::get('logged_info');
|
||||
// module model create an object
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleModel = getModel('module');
|
||||
// permission settings. access, manager(== is_admin) are fixed and privilege name in XE
|
||||
$module_srl = Context::get('module_srl');
|
||||
if(!$module_info->mid && !is_array($module_srl) && preg_match('/^([0-9]+)$/',$module_srl)) {
|
||||
if(!$module_info->mid && !is_array($module_srl) && preg_match('/^([0-9]+)$/', $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);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$grant = $oModuleModel->getGrant($module_info, $logged_info, $xml_info);
|
||||
// have at least access grant
|
||||
if(substr_count($this->act, 'Member') || substr_count($this->act, 'Communication'))
|
||||
{
|
||||
$grant->access = 1;
|
||||
}
|
||||
}
|
||||
// display no permission if the current module doesn't have an access privilege
|
||||
//if(!$grant->access) return $this->stop("msg_not_permitted");
|
||||
// checks permission and action if you don't have an admin privilege
|
||||
if(!$grant->manager) {
|
||||
if(!$grant->manager)
|
||||
{
|
||||
// get permission types(guest, member, manager, root) of the currently requested action
|
||||
$permission_target = $xml_info->permission->{$this->act};
|
||||
// check manager if a permission in module.xml otherwise action if no permission
|
||||
if(!$permission_target && substr_count($this->act, 'Admin')) $permission_target = 'manager';
|
||||
if(!$permission_target && substr_count($this->act, 'Admin'))
|
||||
{
|
||||
$permission_target = 'manager';
|
||||
}
|
||||
// Check permissions
|
||||
switch($permission_target) {
|
||||
switch($permission_target)
|
||||
{
|
||||
case 'root' :
|
||||
case 'manager' :
|
||||
$this->stop('msg_is_not_administrator');
|
||||
|
|
@ -194,7 +212,10 @@
|
|||
|
||||
$this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
|
||||
|
||||
if(method_exists($this, 'init')) $this->init();
|
||||
if(method_exists($this, 'init'))
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -202,15 +223,16 @@
|
|||
* @param string $msg_code an error code
|
||||
* @return ModuleObject $this
|
||||
* */
|
||||
function stop($msg_code) {
|
||||
function stop($msg_code)
|
||||
{
|
||||
// flag setting to stop the proc processing
|
||||
$this->stop_proc = true;
|
||||
$this->stop_proc = TRUE;
|
||||
// Error handling
|
||||
$this->setError(-1);
|
||||
$this->setMessage($msg_code);
|
||||
// Error message display by message module
|
||||
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
|
||||
$oMessageObject = &ModuleHandler::getModuleInstance('message',$type);
|
||||
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
|
||||
$oMessageObject->setError(-1);
|
||||
$oMessageObject->setMessage($msg_code);
|
||||
$oMessageObject->dispMessage();
|
||||
|
|
@ -226,8 +248,12 @@
|
|||
* @param string name of file
|
||||
* @return void
|
||||
* */
|
||||
function setTemplateFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
function setTemplateFile($filename)
|
||||
{
|
||||
if(substr($filename, -5) != '.html')
|
||||
{
|
||||
$filename .= '.html';
|
||||
}
|
||||
$this->template_file = $filename;
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +261,8 @@
|
|||
* retrieve the directory path of the template directory
|
||||
* @return string
|
||||
* */
|
||||
function getTemplateFile() {
|
||||
function getTemplateFile()
|
||||
{
|
||||
return $this->template_file;
|
||||
}
|
||||
|
||||
|
|
@ -244,9 +271,16 @@
|
|||
* @param string path of template directory.
|
||||
* @return void
|
||||
* */
|
||||
function setTemplatePath($path) {
|
||||
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
|
||||
if(substr($path,-1)!='/') $path .= '/';
|
||||
function setTemplatePath($path)
|
||||
{
|
||||
if(substr($path, 0, 1) != '/' && substr($path, 0, 2) != './')
|
||||
{
|
||||
$path = './' . $path;
|
||||
}
|
||||
if(substr($path, -1) != '/')
|
||||
{
|
||||
$path .= '/';
|
||||
}
|
||||
$this->template_path = $path;
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +288,8 @@
|
|||
* retrieve the directory path of the template directory
|
||||
* @return string
|
||||
* */
|
||||
function getTemplatePath() {
|
||||
function getTemplatePath()
|
||||
{
|
||||
return $this->template_path;
|
||||
}
|
||||
|
||||
|
|
@ -263,8 +298,12 @@
|
|||
* @param string name of file
|
||||
* @return void
|
||||
* */
|
||||
function setEditedLayoutFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
function setEditedLayoutFile($filename)
|
||||
{
|
||||
if(substr($filename, -5) != '.html')
|
||||
{
|
||||
$filename .= '.html';
|
||||
}
|
||||
$this->edited_layout_file = $filename;
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +311,8 @@
|
|||
* retreived the file name of edited_layout_file
|
||||
* @return string
|
||||
* */
|
||||
function getEditedLayoutFile() {
|
||||
function getEditedLayoutFile()
|
||||
{
|
||||
return $this->edited_layout_file;
|
||||
}
|
||||
|
||||
|
|
@ -281,8 +321,12 @@
|
|||
* @param string name of file
|
||||
* @return void
|
||||
* */
|
||||
function setLayoutFile($filename) {
|
||||
if(substr($filename,-5)!='.html') $filename .= '.html';
|
||||
function setLayoutFile($filename)
|
||||
{
|
||||
if(substr($filename, -5) != '.html')
|
||||
{
|
||||
$filename .= '.html';
|
||||
}
|
||||
$this->layout_file = $filename;
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +334,8 @@
|
|||
* get the file name of the layout file
|
||||
* @return string
|
||||
* */
|
||||
function getLayoutFile() {
|
||||
function getLayoutFile()
|
||||
{
|
||||
return $this->layout_file;
|
||||
}
|
||||
|
||||
|
|
@ -298,9 +343,16 @@
|
|||
* set the directory path of the layout directory
|
||||
* @param string path of layout directory.
|
||||
* */
|
||||
function setLayoutPath($path) {
|
||||
if(substr($path,0,1)!='/' && substr($path,0,2)!='./') $path = './'.$path;
|
||||
if(substr($path,-1)!='/') $path .= '/';
|
||||
function setLayoutPath($path)
|
||||
{
|
||||
if(substr($path, 0, 1) != '/' && substr($path, 0, 2) != './')
|
||||
{
|
||||
$path = './' . $path;
|
||||
}
|
||||
if(substr($path, -1) != '/')
|
||||
{
|
||||
$path .= '/';
|
||||
}
|
||||
$this->layout_path = $path;
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +360,8 @@
|
|||
* set the directory path of the layout directory
|
||||
* @return string
|
||||
* */
|
||||
function getLayoutPath() {
|
||||
function getLayoutPath()
|
||||
{
|
||||
return $this->layout_path;
|
||||
}
|
||||
|
||||
|
|
@ -316,13 +369,18 @@
|
|||
* excute the member method specified by $act variable
|
||||
* @return boolean true : success false : fail
|
||||
* */
|
||||
function proc() {
|
||||
function proc()
|
||||
{
|
||||
// pass if stop_proc is true
|
||||
if($this->stop_proc) return false;
|
||||
if($this->stop_proc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// trigger call
|
||||
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
|
||||
if(!$triggerOutput->toBool()) {
|
||||
if(!$triggerOutput->toBool())
|
||||
{
|
||||
$this->setError($triggerOutput->getError());
|
||||
$this->setMessage($triggerOutput->getMessage());
|
||||
return false;
|
||||
|
|
@ -330,13 +388,15 @@
|
|||
|
||||
// execute an addon(call called_position as before_module_proc)
|
||||
$called_position = 'before_module_proc';
|
||||
$oAddonController = &getController('addon');
|
||||
$oAddonController = getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
|
||||
@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))
|
||||
{
|
||||
// Check permissions
|
||||
if($this->module_srl && !$this->grant->access){
|
||||
if($this->module_srl && !$this->grant->access)
|
||||
{
|
||||
$this->stop("msg_not_permitted_act");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -364,19 +424,21 @@
|
|||
}
|
||||
}
|
||||
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleModel = getModel('module');
|
||||
$oModuleModel->syncSkinInfoToModuleInfo($this->module_info);
|
||||
Context::set('module_info', $this->module_info);
|
||||
// Run
|
||||
$output = $this->{$this->act}();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// trigger call
|
||||
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
|
||||
if(!$triggerOutput->toBool()) {
|
||||
if(!$triggerOutput->toBool())
|
||||
{
|
||||
$this->setError($triggerOutput->getError());
|
||||
$this->setMessage($triggerOutput->getMessage());
|
||||
return false;
|
||||
|
|
@ -384,26 +446,34 @@
|
|||
|
||||
// execute an addon(call called_position as after_module_proc)
|
||||
$called_position = 'after_module_proc';
|
||||
$oAddonController = &getController('addon');
|
||||
$oAddonController = getController('addon');
|
||||
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
|
||||
@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->setMessage($output->getMessage());
|
||||
|
||||
if (!$output->toBool()) return false;
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// execute api methos of the module if view action is and result is XMLRPC or JSON
|
||||
if($this->module_info->module_type == 'view'){
|
||||
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
|
||||
if($this->module_info->module_type == 'view')
|
||||
{
|
||||
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON')
|
||||
{
|
||||
$oAPI = getAPI($this->module_info->module, 'api');
|
||||
if(method_exists($oAPI, $this->act)) {
|
||||
if(method_exists($oAPI, $this->act))
|
||||
{
|
||||
$oAPI->{$this->act}($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue