|
@@ -71,75 +71,87 @@ class Base extends \app\BaseController
|
|
|
|
|
|
public function checkRole()
|
|
|
{
|
|
|
+ if($this->level==1){
|
|
|
+ return [
|
|
|
+ 'action_conllect'=>'',
|
|
|
+ 'write'=>[],
|
|
|
+ 'platform'=>[],
|
|
|
+ 'roleid'=>$this->roleid
|
|
|
+ ];
|
|
|
|
|
|
- $uid = Db::name("user_role")->where(['uid' => $this->uid, "is_del" => 0, "status" => 1])->find();
|
|
|
- if ($uid == false) {
|
|
|
- return [];
|
|
|
- }
|
|
|
- $action = [];
|
|
|
- $this->roleid = $uid['roleid'];
|
|
|
- $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'][] = $this->uid;
|
|
|
- $group = [];
|
|
|
- $group = Db::name("role_group")->where("FIND_IN_SET($this->uid,group_user) > 0")->column("id");
|
|
|
- $where = "to_user=$this->uid";
|
|
|
- if (!empty($group)) {
|
|
|
- $where .= " or to_group in (" . implode(",", $group) . ")";
|
|
|
- }
|
|
|
+ }else {
|
|
|
+
|
|
|
+
|
|
|
+ $uid = Db::name("user_role")->where(['uid' => $this->uid, "is_del" => 0, "status" => 1])->find();
|
|
|
+ if ($uid == false) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ $action = [];
|
|
|
+ $this->roleid = $uid['roleid'];
|
|
|
+ $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'][] = $this->uid;
|
|
|
+ $group = [];
|
|
|
+ $group = Db::name("role_group")->where("FIND_IN_SET($this->uid,group_user) > 0")->column("id");
|
|
|
+ $where = "to_user=$this->uid";
|
|
|
+ if (!empty($group)) {
|
|
|
+ $where .= " or to_group in (" . implode(",", $group) . ")";
|
|
|
+ }
|
|
|
|
|
|
- $paltform = Db::name("user_platform")->where(["uid" => $this->uid, "is_del" => 0])->find();
|
|
|
- $action['platform'] = $paltform != false ? explode(",", $paltform['platform']) : [];
|
|
|
- $share = Db::name("role_share")->where(["is_del" => 0, "status" => 1])->where($where)->select();
|
|
|
- if (!empty($share)) {
|
|
|
- foreach ($share as $value) {
|
|
|
- if ($value['action'] == 1) {
|
|
|
- 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);
|
|
|
+ $paltform = Db::name("user_platform")->where(["uid" => $this->uid, "is_del" => 0])->find();
|
|
|
+ $action['platform'] = $paltform != false ? explode(",", $paltform['platform']) : [];
|
|
|
+ $share = Db::name("role_share")->where(["is_del" => 0, "status" => 1])->where($where)->select();
|
|
|
+ if (!empty($share)) {
|
|
|
+ foreach ($share as $value) {
|
|
|
+ if ($value['action'] == 1) {
|
|
|
+ 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'] === 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['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['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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //离职交接权限
|
|
|
- $resgin = Db::name("resign_info")->where([["hand_uid", "=", $this->uid], ["is_del", "=", 0], ['status', "=", 4]])
|
|
|
- ->column(['resign_uid']);
|
|
|
- if (!empty($resgin)) {
|
|
|
- $action['write'] = array_unique(array_merge($action['write'], $resgin));
|
|
|
- }
|
|
|
+ //离职交接权限
|
|
|
+ $resgin = Db::name("resign_info")->where([["hand_uid", "=", $this->uid], ["is_del", "=", 0], ['status', "=", 4]])
|
|
|
+ ->column(['resign_uid']);
|
|
|
+ if (!empty($resgin)) {
|
|
|
+ $action['write'] = array_unique(array_merge($action['write'], $resgin));
|
|
|
+ }
|
|
|
|
|
|
- // 超级管理员看到所有人的数据
|
|
|
- if ($uid['roleid'] == 1 || $uid['roleid'] == 33) {
|
|
|
- $action['write'] = [];
|
|
|
- }
|
|
|
- $action['roleid'] = $uid['roleid'];
|
|
|
- $action['action_conllect'] = implode(",", array_unique(explode(",", $action['action_conllect'])));
|
|
|
- return $action;
|
|
|
+ // 超级管理员看到所有人的数据
|
|
|
+// if ($uid['roleid'] == 1 || $uid['roleid'] == 33) {
|
|
|
+// $action['write'] = [];
|
|
|
+// }
|
|
|
|
|
|
+
|
|
|
+ $action['roleid'] = $uid['roleid'];
|
|
|
+ $action['action_conllect'] = implode(",", array_unique(explode(",", $action['action_conllect'])));
|
|
|
+ return $action;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|