public function writeGroup(){ if(isset($_POST['rules'])){ sort($_POST['rules']); $_POST['rules'] = implode( ',' , array_unique($_POST['rules'])); } $_POST['module'] = 'admin'; $_POST['type'] = AuthGroupModel::TYPE_ADMIN; $AuthGroup = D('AuthGroup'); $map['aga.uid'] = UID; $currentAth = $AuthGroup->alias('ag') ->join(C('DB_PREFIX').'auth_group_access aga ON aga.group_id = ag.id') ->where($map)->find(); $rules = explode(',', $currentAth['rules']); $newRules = explode(',', $_POST['rules']); if(UID != 1){ foreach ($newRules as $key => $value) { if(!in_array($value,$rules,0)){ $this->error('操作失败!不允许自身提升授权'); } } } $data = $AuthGroup->create(); if ( $data ) { if ( empty($data['id']) ) { $r = $AuthGroup->add(); }else{ $r = $AuthGroup->save(); } if($r===false){ $this->error('操作失败'.$AuthGroup->getError()); } else{ $this->success('操作成功!',U('index')); } }else{ $this->error('操作失败'.$AuthGroup->getError()); } }

分类: web

标签: