mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Set standalone attribute to 'auto' if new class syntax is used in module.xml
- 새로 추가된 클래스 문법 사용시 standalone 속성 기본값은 true가 아닌 auto로 지정
- standalone 속성의 의미는 아래와 같음
- true: 항상 접근 허용 (기존 방식으로 선언한 액션의 기본값)
- false: mid가 소속 모듈과 일치하거나, admin 모듈인 경우에만 접근 허용
- auto: module 또는 mid가 소속 모듈과 일치하거나, admin 모듈인 경우에만 접근 허용
(즉, false와 비슷하지만 exec_json 함수 등에서 module+act로 호출하는 경우에는
mid가 없더라도 module만 일치하면 호출할 수 있도록 허용하여 개발 편의를 높임)
- 단, global_route 속성이 있는 경우 standalone 속성 기본값은 true임
(전역 짧은주소는 mid 없이 호출될 수밖에 없으므로)
This commit is contained in:
parent
f98964467c
commit
741a714abd
3 changed files with 38 additions and 9 deletions
|
|
@ -80,9 +80,9 @@ class ModuleActionParser extends BaseParser
|
|||
{
|
||||
// Parse permissions.
|
||||
$action_name = trim($action['name']);
|
||||
$action_type = trim($action['type']);
|
||||
$action_class = trim($action['class']);
|
||||
$permission = trim($action['permission']);
|
||||
$action_type = trim($action['type'] ?? '');
|
||||
$action_class = trim($action['class'] ?? '');
|
||||
$permission = trim($action['permission'] ?? '');
|
||||
$permission_info = (object)['target' => '', 'check_var' => '', 'check_type' => ''];
|
||||
if ($permission)
|
||||
{
|
||||
|
|
@ -101,18 +101,17 @@ class ModuleActionParser extends BaseParser
|
|||
{
|
||||
$methods = ['POST'];
|
||||
}
|
||||
/*
|
||||
elseif ($action_type === 'view' || starts_with('disp', $action_name))
|
||||
elseif ($action_class && starts_with('disp', $action_name))
|
||||
{
|
||||
$methods = ['GET'];
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
$methods = ['GET', 'POST'];
|
||||
}
|
||||
|
||||
// Parse routes.
|
||||
$global_route = (trim($action['global_route']) ?: trim($action['global-route'])) === 'true' ? 'true' : 'false';
|
||||
$route_attr = trim($action['route']);
|
||||
$route_tags = $action->route ?: [];
|
||||
$route_arg = [];
|
||||
|
|
@ -136,6 +135,28 @@ class ModuleActionParser extends BaseParser
|
|||
}
|
||||
}
|
||||
|
||||
// Parse the standalone attribute.
|
||||
if ($global_route === 'true')
|
||||
{
|
||||
$standalone = 'true';
|
||||
}
|
||||
elseif ($action_class)
|
||||
{
|
||||
$standalone = trim($action['standalone']);
|
||||
if (!$standalone || !in_array($standalone, ['true', 'false', 'auto']))
|
||||
{
|
||||
$standalone = 'auto';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$standalone = trim($action['standalone']);
|
||||
if (!$standalone || !in_array($standalone, ['true', 'false', 'auto']))
|
||||
{
|
||||
$standalone = 'true';
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically determine the type for custom classes.
|
||||
if ($action_class && !$action_type)
|
||||
{
|
||||
|
|
@ -162,10 +183,10 @@ class ModuleActionParser extends BaseParser
|
|||
$action_info->ruleset = trim($action['ruleset']);
|
||||
$action_info->method = implode('|', $methods);
|
||||
$action_info->route = $route_arg;
|
||||
$action_info->standalone = trim($action['standalone']) === 'false' ? 'false' : 'true';
|
||||
$action_info->standalone = $standalone;
|
||||
$action_info->check_csrf = (trim($action['check_csrf']) ?: trim($action['check-csrf'])) === 'false' ? 'false' : 'true';
|
||||
$action_info->meta_noindex = (trim($action['meta_noindex']) ?: trim($action['meta-noindex'])) === 'true' ? 'true' : 'false';
|
||||
$action_info->global_route = (trim($action['global_route']) ?: trim($action['global-route'])) === 'true' ? 'true' : 'false';
|
||||
$action_info->global_route = $global_route;
|
||||
$info->action->{$action_name} = $action_info;
|
||||
|
||||
// Set the menu name and index settings.
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
<action name="procTestSubmitData" type="controller" standalone="false" check-csrf="false" ruleset="submitData" />
|
||||
<action name="dispTestAdminIndex" type="view" admin_index="true" menu_name="test" menu_index="true" />
|
||||
<action name="procTestAdminSubmitData" type="controller" permission="manager" check_var="module_srl" check_type="thisisatest" method="GET|POST" />
|
||||
<action name="dispTestStandalone1" class="Namespace\ClassName" route="test/standalone1" method="GET" />
|
||||
<action name="dispTestStandalone2" class="Namespace\ClassName" route="test/standalone2" method="GET" standalone="false" />
|
||||
<action name="dispTestStandalone3" type="view" route="test/standalone3" method="GET" global-route="true" />
|
||||
<action name="dispTestErrorHandler" type="view" standalone="true" error-handlers="404" />
|
||||
</actions>
|
||||
<menus>
|
||||
|
|
|
|||
|
|
@ -35,8 +35,13 @@ class ModuleActionParserTest extends \Codeception\TestCase\Test
|
|||
$this->assertEquals('GET|POST', $info->action->procTestAdminSubmitData->method);
|
||||
$this->assertEquals([], $info->action->procTestAdminSubmitData->route);
|
||||
|
||||
// Standalone attribute
|
||||
$this->assertEquals('auto', $info->action->dispTestStandalone1->standalone);
|
||||
$this->assertEquals('false', $info->action->dispTestStandalone2->standalone);
|
||||
$this->assertEquals('true', $info->action->dispTestStandalone3->standalone);
|
||||
|
||||
// Routes
|
||||
$this->assertEquals(4, count($info->route->GET));
|
||||
$this->assertEquals(7, count($info->route->GET));
|
||||
$this->assertEquals('dispTestView', $info->route->GET['#^(?P<document_srl>[0-9]+)$#u']);
|
||||
$this->assertEquals('dispTestView', $info->route->GET['#^(?P<document_srl>[0-9]+)/comment/(?P<comment_srl>[0-9]+)$#u']);
|
||||
$this->assertEquals('dispTestView', $info->route->GET['#^(?P<document_srl>[0-9]+)/tag/(?P<tag>[a-zA-Z0-9_]+)$#u']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue