优化加入组别

master
chenzhi 4 years ago
parent 7355546a58
commit 2ad1ff5434

@ -265,7 +265,7 @@ class AuthManagerController extends AdminController{
}else{
$ids = $_REQUEST['id'];
}
$lr = M("AuthGroup")->field('title,status')->where("id in ({$ids})")->select();
$lr = SM("AuthGroup")->field('title,status')->where("id in ({$ids})")->select();
$status = 0;
$op_name ='';
$op_type =1;
@ -309,7 +309,7 @@ class AuthManagerController extends AdminController{
"status"=>$status
];
// dd($savedata);
$res = D("AuthGroup")->where("id in ({$ids})")->syncSave($savedata);
$res = SM("AuthGroup")->where("id in ({$ids})")->save($savedata);
if($res !==false ){
$this->success($msg['success'],$msg['url'],$msg['ajax']);
}else{
@ -329,14 +329,14 @@ class AuthManagerController extends AdminController{
$this->error('参数错误');
}
$auth_group = M('AuthGroup')->where( array('status'=>array('egt','0'),'module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) )
$auth_group = SM('AuthGroup')->where( array('status'=>array('egt','0'),'module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) )
->getfield('id,id,title,rules');
$prefix = C('DB_PREFIX');
$l_table = $prefix.(AuthGroupModel::MEMBER);
$r_table = $prefix.(AuthGroupModel::AUTH_GROUP_ACCESS);
$model = M()->table( $l_table.' m' )->join ( $r_table.' a ON m.uid=a.uid' );
$model = SM()->table( $l_table.' m' )->join ( $r_table.' a ON m.uid=a.uid' );
$_REQUEST = array();
$list = $this->lists($model,array('a.group_id'=>$group_id,'m.status'=>array('egt',0)),'m.uid asc','m.uid,m.nickname,m.last_login_time,m.last_login_ip,m.status');
$list = $this->lists($model,array('a.group_id'=>$group_id,'m.status'=>array('egt',0)),'m.uid asc','m.uid,m.nickname,m.last_login_time,m.last_login_ip,m.status',true,true);
int_to_string($list);
$this->assign( '_list', $list );
$this->assign('auth_group', $auth_group);
@ -408,7 +408,7 @@ class AuthManagerController extends AdminController{
}
$AuthGroup = D('AuthGroup');
if(is_numeric($uid)){
if ( is_administrator($uid) ) {
if ( $uid == 1 ) {
$this->error('该用户为超级管理员');
}
if( !M('Member')->where(array('uid'=>$uid))->find() ){

@ -53,7 +53,7 @@ class AuthGroupModel extends Model {
$uid = is_array($uid)?implode(',',$uid):trim($uid,',');
$gid = is_array($gid)?$gid:explode( ',',trim($gid,',') );
$Access = M(self::AUTH_GROUP_ACCESS);
$Access = SM(self::AUTH_GROUP_ACCESS);
if( isset($_REQUEST['batch']) ){
//为单个用户批量添加用户组时,先删除旧数据
$del = $Access->where( array('uid'=>array('in',$uid)) )->delete();
@ -65,7 +65,7 @@ class AuthGroupModel extends Model {
if( $del!==false ){
foreach ($uid_arr as $u){
//判断用户id是否合法
if(M('Member')->getFieldByUid($u,'uid') == false){
if(SM('Member')->getFieldByUid($u,'uid') == false){
$this->error = "编号为{$u}的账号不存在!";
return false;
}
@ -246,7 +246,7 @@ class AuthGroupModel extends Model {
* @author 朱亚杰 <xcoolcc@gmail.com>
*/
public function removeFromGroup($uid,$gid){
return M(self::AUTH_GROUP_ACCESS)->where( array( 'uid'=>$uid,'group_id'=>$gid) )->delete();
return SM(self::AUTH_GROUP_ACCESS)->where( array( 'uid'=>$uid,'group_id'=>$gid) )->delete();
}
/**

Loading…
Cancel
Save