wugg 2 years ago
parent
commit
7421ab0625
2 changed files with 35 additions and 9 deletions
  1. 1 1
      .env
  2. 34 8
      app/admin/controller/Base.php

+ 1 - 1
.env

@@ -1 +1 @@
-APP_DEBUG = false
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai


[LANG]
default_lang = zh-cn
+APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai


[LANG]
default_lang = zh-cn

+ 34 - 8
app/admin/controller/Base.php

@@ -40,21 +40,47 @@ class Base extends \app\BaseController
         $action=[];
         $role =Db::name("role_action")->where(["role_id"=>$uid['roleid'],"status"=>1])->find();
         $action['action_conllect']=isset($role['action_conllect'])? $role['action_conllect']:'';
-        $action['write'][]=$uid;
+        $action['write'][]=$this->uid;
         $group=[];
-       // $group = Db::name("role_group")->where("FIND_IN_SET($uid,group_user) >0")->column("id");
-        $share =Db::name("role_share")->where(["is_del"=>0,"status"=>1])->whereOr(["to_user"=>$this->uid,"to_group"=>$group])->select();
+       $group = Db::name("role_group")->where("FIND_IN_SET($this->uid,group_user) > 0")->column("id");
+     //  echo  Db::name("role_group")->getLastSql();
+        $where="to_user=$this->uid";
+        if(!empty($group)){
+            $where.="  or to_group in (".implode(",",$group).")";
+        }
+       // var_dump($group);
+        $share =Db::name("role_share")->where(["is_del"=>0,"status"=>1])->where($where) ->select();
+      //  echo Db::name("role_share")->getLastSql();
         if(!empty($share)){
             foreach ($share as $value){
-                if($value['action_collect']!=''){
-                    $act =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect']),"action_code"=>'001'])->column("id");
-                    $action['action_conllect'].=empty($act)?"":",".implode(",",$act);
-                }
                 if($value['action']==1){
-                    if($value['share_user']!="")  $action['write'][]=$value['share_user'];
+                    if($value['share_user']!=""){
+                        $action['write'][]=$value['share_user'];
+                        $user=Db::name("user_role")->where(['uid'=>$value['share_user'],"is_del"=>0,"status"=>1])->find();
+                        if($user!=false){
+                            $role =Db::name("role_action")->where(["role_id"=>$user['roleid'],"status"=>1])->find();
+                            if($role!=false){
+                                $conlect =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect'])])->column("id");
+                                $shar=explode(",",$value['action_collect']);
+                                $wish =array_intersect($conlect,$shar);
+                                $action['action_conllect'].=empty($wish)?"":",".implode(",",$wish);
+                            }
+                        }
+
+                    }
                 }
                 if($value['action']===0){
                     if($value['share_user']!="")  $action['write'][]=$value['share_user'];
+                    if($value['action_collect']!=''){
+                        $act =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect']),"action_code"=>'001'])->column("id");
+                        $action['action_conllect'].=empty($act)?"":",".implode(",",$act);
+                    }
+                }
+                if($value['action']===''){
+                    if($value['action_collect']!=''){
+                        $act =Db::name("action")->where(['menuid'=>explode(",",$value['action_collect']),"action_code"=>'001'])->column("id");
+                        $action['action_conllect'].=empty($act)?"":",".implode(",",$act);
+                    }
                 }
             }
         }