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