首页 > 代码库 > php中权限系统的分配和权限配置文件的读取

php中权限系统的分配和权限配置文件的读取

            //从qx.php 中读取数据              $data=  require (__dir__.‘/../qx.php‘);//读取controller目录下面的qx.php //qx.php中的字段                         //下面是测试的数据           /*            $result=array(                array(‘name‘=> ‘affairsapproval‘,‘desc‘=>‘事务审批‘,‘value‘=>‘0‘),                array(‘name‘=> ‘leaveapplyapproval‘,‘desc‘=>‘请假审批‘,‘value‘=>‘0‘),                            );*/                        $newresult=array();               /*foreach ($data as $key => $value) {                                 /*$new=array(‘key‘=>$key,‘value‘=>$value,‘check‘=>‘0‘);                                 $newresult=array_merge_recursive($new,array(‘key‘=>$key,‘value‘=>$value,‘check‘=>‘0‘));             } */              $i=0;             $userid = $this->input->get(‘userid‘);             $userqx = $this->db->get_where(‘qx‘,array(‘userid‘=>$userid))->result_array();             if(empty($userqx[0])){                 foreach ($data as $key => $value) {                    $newarray[$i] = array(                                    ‘value‘=>$value,                                        ‘key‘=>$key,                                    ‘checked‘=>false                                );                    $i++;                 }             }else{                 foreach($userqx[0] as $key =>$val){                                      if($key!=‘act‘&&$key!=‘id‘&&$key!=‘userid‘){                                             $newarray[$i] = array(                                           ‘value‘=>$data[$key],                                           ‘key‘=>$key,                                           ‘checked‘=>($val!=1)?false:true                                       );                        $i++;                    }                 }             }                        $output->data=http://www.mamicode.com/$newarray; 

 

权限配置文件:

$qx = array();$qx[‘affairsapproval‘]=‘事务审批‘;$qx[‘leaveapplyapproval‘] = ‘请假审批‘;$qx[‘customprocess‘]=‘自定义流程‘;$qx[‘addcustomprocess‘]=‘新增自定义流程‘; $qx[‘systemadmin‘]=‘系统管理员‘; $qx[‘systemsync‘]=‘系统同步数据‘; $qx[‘systemmanagement‘]=‘系统管理‘; $qx[‘checkwork‘]=‘行政考勤‘; $qx[‘requestapproval‘]=‘行政申请单‘; $qx[‘notice‘]=‘公司通知‘;$qx[‘houtai‘]=‘后台‘;return $qx; 

 

php中权限系统的分配和权限配置文件的读取