mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 20:12:14 +09:00
배열 자동 인식
This commit is contained in:
parent
9ec088b4db
commit
cda2dd8fa7
2 changed files with 37 additions and 33 deletions
|
|
@ -170,40 +170,32 @@ class ModuleObject extends Object
|
||||||
// variable module config
|
// variable module config
|
||||||
$this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
|
$this->module_config = $oModuleModel->getModuleConfig($this->module, $module_info->site_srl);
|
||||||
|
|
||||||
|
// Proceeding <permission check> of module.xml
|
||||||
$permission_check = $xml_info->permission_check->{$this->act};
|
$permission_check = $xml_info->permission_check->{$this->act};
|
||||||
|
|
||||||
// Get permission check key
|
|
||||||
if(strpos($permission_check->key, '.') !== false)
|
|
||||||
{
|
|
||||||
list($check_key_type, $check_key) = explode('.', $permission_check->key);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$check_key = $permission_check->key;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If permission check target is not the current module
|
// If permission check target is not the current module
|
||||||
if($check_key && $check_module_srl = Context::get($check_key))
|
if($permission_check->key && $check_module_srl = Context::get($permission_check->key))
|
||||||
{
|
{
|
||||||
// If value is string
|
|
||||||
if($permission_check->array === '' && !is_array($check_module_srl))
|
|
||||||
{
|
|
||||||
if(($grant = $this->checkPermissionKey($check_module_srl, $check_key_type)) === false)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If value is array
|
// If value is array
|
||||||
else
|
if(is_array($check_module_srl) || preg_match('/,|\|@\|/', $check_module_srl, $delimiter))
|
||||||
{
|
{
|
||||||
|
// Convert string to array. delimiter is ,(comma) or |@|
|
||||||
if(!is_array($check_module_srl))
|
if(!is_array($check_module_srl))
|
||||||
{
|
{
|
||||||
$check_module_srl = explode($permission_check->array, $check_module_srl);
|
if($delimiter[0])
|
||||||
|
{
|
||||||
|
$check_module_srl = explode($delimiter[0], $check_module_srl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$check_module_srl = array($check_module_srl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check and Stop
|
||||||
foreach($check_module_srl as $target_srl)
|
foreach($check_module_srl as $target_srl)
|
||||||
{
|
{
|
||||||
if($this->checkPermissionKey($target_srl, $check_key_type, $xml_info) === false)
|
if($this->checkPermissionBySrl($target_srl, $permission_check->type, $xml_info) === false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +203,15 @@ class ModuleObject extends Object
|
||||||
|
|
||||||
$checked = true;
|
$checked = true;
|
||||||
}
|
}
|
||||||
|
// If value is string
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// only check, and return grant information
|
||||||
|
if(($grant = $this->checkPermissionBySrl($check_module_srl, $permission_check->type)) === false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get grant information of user
|
// Get grant information of user
|
||||||
|
|
@ -237,13 +238,13 @@ class ModuleObject extends Object
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check permission key
|
* Check permission by target_srl
|
||||||
* @param string $target_srl as module_srl. It may be a reference serial number
|
* @param string $target_srl as module_srl. It may be a reference serial number
|
||||||
* @param string $key_type module name. get module_srl from module
|
* @param string $type module name. get module_srl from module
|
||||||
* @param object $xml_info object containing module description. and if used, check permission
|
* @param object $xml_info object containing module description. and if used, check permission
|
||||||
* @return mixed fail : false, success : true or object
|
* @return mixed fail : false, success : true or object
|
||||||
* */
|
* */
|
||||||
function checkPermissionKey($target_srl, $key_type = null, $xml_info = null)
|
function checkPermissionBySrl($target_srl, $type = null, $xml_info = null)
|
||||||
{
|
{
|
||||||
if(!preg_match('/^([0-9]+)$/', $target_srl))
|
if(!preg_match('/^([0-9]+)$/', $target_srl))
|
||||||
{
|
{
|
||||||
|
|
@ -251,13 +252,13 @@ class ModuleObject extends Object
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($key_type)
|
if($type)
|
||||||
{
|
{
|
||||||
if($key_type == 'document')
|
if($type == 'document')
|
||||||
{
|
{
|
||||||
$target_srl = getModel('document')->getDocument($target_srl, false, false)->get('module_srl');
|
$target_srl = getModel('document')->getDocument($target_srl, false, false)->get('module_srl');
|
||||||
}
|
}
|
||||||
if($key_type == 'comment')
|
if($type == 'comment')
|
||||||
{
|
{
|
||||||
$target_srl = getModel('comment')->getComment($target_srl)->get('module_srl');
|
$target_srl = getModel('comment')->getComment($target_srl)->get('module_srl');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -846,15 +846,18 @@ class moduleModel extends module
|
||||||
$action = $permission->attrs->action;
|
$action = $permission->attrs->action;
|
||||||
$target = $permission->attrs->target;
|
$target = $permission->attrs->target;
|
||||||
$check = $permission->attrs->check ?: 'module_srl';
|
$check = $permission->attrs->check ?: 'module_srl';
|
||||||
$check_array = isset($permission->attrs->check_array) ? $permission->attrs->check_array : '';
|
|
||||||
|
|
||||||
$info->permission->{$action} = $target;
|
$info->permission->{$action} = $target;
|
||||||
$info->permission_check->{$action}->key = $check;
|
$info->permission_check->{$action}->key = $check;
|
||||||
$info->permission_check->{$action}->array = $check_array;
|
|
||||||
|
if(strpos($check, '.') !== false)
|
||||||
|
{
|
||||||
|
list($info->permission_check->{$action}->type, $info->permission_check->{$action}->key) = explode('.', $check);
|
||||||
|
}
|
||||||
|
|
||||||
$buff[] = sprintf('$info->permission->%s = \'%s\';', $action, $target);
|
$buff[] = sprintf('$info->permission->%s = \'%s\';', $action, $target);
|
||||||
$buff[] = sprintf('$info->permission_check->%s->key = \'%s\';', $action, $check);
|
$buff[] = sprintf('$info->permission_check->%s->key = \'%s\';', $action, $info->permission_check->{$action}->key);
|
||||||
$buff[] = sprintf('$info->permission_check->%s->array = \'%s\';', $action, $check_array);
|
$buff[] = sprintf('$info->permission_check->%s->type = \'%s\';', $action, $info->permission_check->{$action}->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for admin menus
|
// for admin menus
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue