优化新增用户组

master
chenzhi 4 years ago
parent 8f7405bb17
commit 7355546a58

@ -27,7 +27,7 @@ class AuthManagerController extends AdminController{
//需要新增的节点必然位于$nodes
$nodes = $this->returnNodes(false);
$AuthRule = M('AuthRule');
$AuthRule = SM('AuthRule');
$map = array('module'=>'admin','type'=>array('in','1,2'));//status全部取出,以进行更新
//需要更新和删除的节点必然位于$rules
$rules = $AuthRule->where($map)->order('name')->select();
@ -128,7 +128,7 @@ class AuthManagerController extends AdminController{
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public function editGroup(){
$auth_group = M('AuthGroup')->where( array('module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) )
$auth_group = SM('AuthGroup')->where( array('module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) )
->find( (int)$_GET['id'] );
$this->assign('auth_group',$auth_group);
$this->meta_title = '编辑用户组';
@ -151,9 +151,9 @@ class AuthManagerController extends AdminController{
->getfield('id,id,title,rules');
$node_list = $this->returnNodes();
$map = array('module'=>'admin','type'=>AuthRuleModel::RULE_MAIN,'status'=>1);
$main_rules = M('AuthRule')->where($map)->getField('name,id');
$main_rules = SM('AuthRule')->where($map)->getField('name,id');
$map = array('module'=>'admin','type'=>AuthRuleModel::RULE_URL,'status'=>1);
$child_rules = M('AuthRule')->where($map)->getField('name,id');
$child_rules = SM('AuthRule')->where($map)->getField('name,id');
$this->assign('main_rules', $main_rules);
$this->assign('auth_rules', $child_rules);
@ -205,40 +205,30 @@ class AuthManagerController extends AdminController{
}
}
if(isset($_POST['rules'])){
$isrules = true;
if(!empty($ruleiddata)){
$_POST['rules'] = array_merge($_POST['rules'],$ruleiddata);
}
sort($_POST['rules']);
$_POST['rules'] = implode( ',' , array_unique($_POST['rules']));
}else{
$isrules = false;
$_POST['rules'] = '';
}
$_POST['module'] = 'admin';
$_POST['type'] = AuthGroupModel::TYPE_ADMIN;
$AuthGroup = D('AuthGroup');
$AuthGroup = SM('AuthGroup');
$data = $AuthGroup->create();
if ( $data ) {
if ( empty($data['id']) ) {
if(!IS_SUBSITE){
\Think\Log::actionLog('AuthManager/createGroup','authGroup',1);
}
$r = $AuthGroup->syncAdd($data);
\Think\Log::actionLog('AuthManager/createGroup','authGroup',1);
$r = $AuthGroup->add($data);
addOperationLog(array(
"op_type"=>0,
"key"=> $_POST['title'],
"url"=>U("AuthManager/index")
));
}else{
if(!IS_SUBSITE){
\Think\Log::actionLog('AuthManager/editGroup','authGroup',1);
}
if($isrules){
$r = SM("auth_group","sys_")->save($data);
}else{
$r = $AuthGroup->where("id={$data['id']}")->syncSave($data);
}
\Think\Log::actionLog('AuthManager/editGroup','authGroup',1);
$r = SM("auth_group","sys_")->save($data);
//操作日志不传title表示是访问授权
$oparr = array(

@ -5,16 +5,14 @@
<h3 class="page_title">角色权限</h3>
<p class="description_text">说明:可以设置管理账号的不同操作权限</p>
</div>
<if condition="!IS_SUBSITE">
<div class="cf top_nav_list">
<div class="fl button_list">
<a id="add-group" class="" href="{:U('createGroup')}"><span class="button_icon button_icon1"></span>新增</a>
<a url="{:U('changestatus?method=resumeGroup')}" class="ajax-post" target-form="ids" ><span class="button_icon button_icon4"></span>正常</a>
<a url="{:U('changestatus?method=forbidGroup')}" class="ajax-post" target-form="ids" ><span class="button_icon button_icon5"></span>禁用</a>
<a url="{:U('changestatus?method=deleteGroup')}" class="ajax-post confirm" target-form="ids" ><span class="button_icon button_icon2"></span>删除</a>
</div>
<div class="cf top_nav_list">
<div class="fl button_list">
<a id="add-group" class="" href="{:U('createGroup')}"><span class="button_icon button_icon1"></span>新增</a>
<a url="{:U('changestatus?method=resumeGroup')}" class="ajax-post" target-form="ids" ><span class="button_icon button_icon4"></span>正常</a>
<a url="{:U('changestatus?method=forbidGroup')}" class="ajax-post" target-form="ids" ><span class="button_icon button_icon5"></span>禁用</a>
<a url="{:U('changestatus?method=deleteGroup')}" class="ajax-post confirm" target-form="ids" ><span class="button_icon button_icon2"></span>删除</a>
</div>
</if>
</div>
<!-- 数据列表 -->
<div class="data_list">
<table class="">
@ -52,9 +50,9 @@
</td>
<td>
<a href="{:U('AuthManager/access?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >访问授权</a>
<a href="{:U('AuthManager/user?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >成员授权</a>
<if condition="!IS_SUBSITE">
<a href="{:U('AuthManager/category?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >分类授权</a>
<a href="{:U('AuthManager/user?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >成员授权</a>
<a href="{:U('AuthManager/dataempower?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >数据授权</a>
<if condition="$vo['id'] eq 11 or $vo['id'] eq 12 or $vo['id'] eq 21">
<a href="{:U('AuthManager/AuthMarketMember?group_name='.$vo['title'].'&group_id='.$vo['id'])}" >市场专员分成</a>
@ -66,14 +64,12 @@
<else /><span class="disabled_status">{:get_status_title($vo['status'])}</span></eq>
</td>
<td>
<if condition="!IS_SUBSITE">
<eq name="vo.status" value="1">
<a href="{:U('AuthManager/changeStatus?method=forbidGroup&id='.$vo['id'])}" class="ajax-get">禁用</a>
<else/>
<a href="{:U('AuthManager/changeStatus?method=resumeGroup&id='.$vo['id'])}" class="ajax-get">正常</a>
</eq>
<a href="{:U('AuthManager/changeStatus?method=deleteGroup&id='.$vo['id'])}" class="confirm ajax-get">删除</a>
</if>
<eq name="vo.status" value="1">
<a href="{:U('AuthManager/changeStatus?method=forbidGroup&id='.$vo['id'])}" class="ajax-get">禁用</a>
<else/>
<a href="{:U('AuthManager/changeStatus?method=resumeGroup&id='.$vo['id'])}" class="ajax-get">正常</a>
</eq>
<a href="{:U('AuthManager/changeStatus?method=deleteGroup&id='.$vo['id'])}" class="confirm ajax-get">删除</a>
</td>
</tr>
</volist>

@ -114,7 +114,7 @@ class Log {
$user_id = is_login();
//查询行为,判断是否执行
$action_info = M('Action')->getByName($action);
$action_info = SM('Action')->getByName($action);
if($action_info['status'] != 1){
return '该行为被禁用或删除';
}
@ -166,6 +166,6 @@ class Log {
$data['remark'] = '操作url'.$_SERVER['REQUEST_URI'];
}
M('ActionLog')->add($data);
SM('ActionLog')->add($data);
}
}
Loading…
Cancel
Save