#16 에디터 컴포넌트에 그룹별 사용 권한을 적용할 수 있도록 코드 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3475 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-01-07 03:40:36 +00:00
parent 1740ebb83c
commit 566a3ff8b5
5 changed files with 68 additions and 12 deletions

View file

@ -85,6 +85,9 @@
unset($extra_vars->component_name);
unset($extra_vars->module);
unset($extra_vars->act);
unset($extra_vars->body);
if($extra_vars->target_group) $extra_vars->target_group = explode('|@|', $extra_vars->target_group);
$args->component_name = $component_name;
$args->extra_vars = serialize($extra_vars);

View file

@ -34,10 +34,16 @@
function dispEditorAdminSetupComponent() {
$component_name = Context::get('component_name');
// 에디터 컴포넌트의 정보를 구함
$oEditorModel = &getModel('editor');
$component = $oEditorModel->getComponent($component_name);
Context::set('component', $component);
// 그룹 설정을 위한 그룹 목록을 구함
$oMemberModel = &getModel('member');
$group_list = $oMemberModel->getGroups();
Context::set('group_list', $group_list);
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('setup_component');
$this->setLayoutFile("popup_layout");

View file

@ -246,6 +246,15 @@
// 파일목록을 구함
$downloaded_list = FileHandler::readDir($this->module_path.'components');
// 로그인 여부 및 소속 그룹 구함
$is_logged = Context::get('is_logged');
if($is_logged) {
$logged_info = Context::get('logged_info');
if($logged_info->group_list && is_array($logged_info->group_list)) {
$group_list = array_keys($logged_info->group_list);
} else $group_list = array();
}
// DB 목록을 loop돌면서 xml정보까지 구함
if(!is_array($db_list)) $db_list = array($db_list);
foreach($db_list as $component) {
@ -259,10 +268,33 @@
$xml_info = $this->getComponentXmlInfo($component_name);
$xml_info->enabled = $component->enabled;
if($component->extra_vars && $xml_info->extra_vars) {
if($component->extra_vars) {
$extra_vars = unserialize($component->extra_vars);
foreach($xml_info->extra_vars as $key => $val) {
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
// 사용권한이 있으면 권한 체크
if($extra_vars->target_group) {
// 사용권한이 체크되어 있는데 로그인이 되어 있지 않으면 무조건 사용 중지
if(!$is_logged) continue;
// 대상 그룹을 구해서 현재 로그인 사용자의 그룹과 비교
$target_group = $extra_vars->target_group;
unset($extra_vars->target_group);
$is_granted = false;
foreach($group_list as $group_srl) {
if(in_array($group_srl, $target_group)) {
$is_granted = true;
break;
}
}
if(!$is_granted) continue;
}
// 에디터 컴포넌트의 설정 정보를 체크
if($xml_info->extra_vars) {
foreach($xml_info->extra_vars as $key => $val) {
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
}
}
}
@ -309,13 +341,24 @@
$xml_info = $this->getComponentXmlInfo($component_name);
$xml_info->enabled = $component->enabled;
$xml_info->target_group = array();
if($component->extra_vars) {
$extra_vars = unserialize($component->extra_vars);
foreach($xml_info->extra_vars as $key => $val) {
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
if($extra_vars->target_group) {
$xml_info->target_group = $extra_vars->target_group;
unset($extra_vars->target_group);
}
if($xml_info->extra_vars) {
foreach($xml_info->extra_vars as $key => $val) {
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
}
}
}
return $xml_info;
}

View file

@ -75,13 +75,7 @@
<td class="tahoam">{$xml_info->version}</td>
<td class="blue"><a href="{$xml_info->author->link}" onclick="window.open(this.href);return false;">{$xml_info->author->name}</a></td>
<td class="tahoma">{$xml_info->author->date}</td>
<td class="red">
<!--@if($xml_info->extra_vars)-->
<a href="#" onclick="doSetupComponent('{$component_name}'); return false;">{$lang->cmd_setup}</a>
<!--@else-->
&nbsp;
<!--@end-->
</td>
<td class="red"><a href="#" onclick="doSetupComponent('{$component_name}'); return false;">{$lang->cmd_setup}</a></td>
<td>
<!--@if($xml_info->enabled=='Y')-->
<a href="#" onclick="doDisableComponent('{$component_name}');return false;" class="blue">{$lang->cmd_enable}</a>

View file

@ -34,6 +34,16 @@
</td>
</tr>
<!--@end-->
<tr>
<th scope="row">{$lang->grant}</th>
<td>
<!--@foreach($group_list as $key => $val)-->
<div class="fl"><input type="checkbox" name="target_group" value="{$key}" <!--@if(in_array($key, $component->target_group))-->checked="checked"<!--@end--> id="group_{$key}"> <label for="group_{$key}">{$val->title}</label> &nbsp;</div>
<!--@end-->
</td>
</tr>
</table>
</div>