|
@@ -313,67 +313,100 @@ class Auth
|
|
|
$user['auth_data'] = 'all';
|
|
|
$user['top'] = 'all';
|
|
|
} else {
|
|
|
- $role = Dever::db('manage/role')->get(array('where_id' => $user['role']));
|
|
|
-
|
|
|
- if ($role) {
|
|
|
- $user['oper'] = array();
|
|
|
- $user['auth'] = array();
|
|
|
- $user['auth_data'] = array();
|
|
|
- $user['self'] = 2;
|
|
|
- $top = array();
|
|
|
- foreach ($role as $k => $v) {
|
|
|
- if ($v['oper']) {
|
|
|
- if (strpos($v['oper'], ',') !== false) {
|
|
|
- $user['oper'] += explode(',', $v['oper']);
|
|
|
- } else {
|
|
|
- $user['oper'][] = $v['oper'];
|
|
|
- }
|
|
|
- }
|
|
|
- if ($v['auth']) {
|
|
|
- $user['auth'][] = $v['auth'];
|
|
|
- }
|
|
|
- if ($v['auth_data']) {
|
|
|
- $user['auth_data'][] = $v['auth_data'];
|
|
|
- }
|
|
|
- if (!$user['top'] && $v['top']) {
|
|
|
- $top[] = $v['top'];
|
|
|
- }
|
|
|
- if ($v['self'] == 1) {
|
|
|
- $user['self'] = $v['self'];
|
|
|
- }
|
|
|
- }
|
|
|
+ $user = $this->role($user);
|
|
|
+ }
|
|
|
|
|
|
- $user['oper'] = implode(',', $user['oper']);
|
|
|
- $user['auth'] = implode(',', $user['auth']);
|
|
|
- $user['auth_data'] = implode(',', $user['auth_data']);
|
|
|
+ $this->save->add($this->name, $user, 3600 * 24 * 7);
|
|
|
+ }
|
|
|
|
|
|
- if (!$user['top'] && $top) {
|
|
|
- $user['top'] = implode(',', $top);
|
|
|
+ /**
|
|
|
+ * get_role
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ private function role($user)
|
|
|
+ {
|
|
|
+ $role = Dever::db('manage/role')->get(array('where_id' => $user['role']));
|
|
|
+
|
|
|
+ if ($role) {
|
|
|
+ $user['oper'] = array();
|
|
|
+ $user['auth'] = array();
|
|
|
+ $user['auth_data'] = array();
|
|
|
+ $user['self'] = 2;
|
|
|
+ $top = array();
|
|
|
+ foreach ($role as $k => $v) {
|
|
|
+ if ($v['oper']) {
|
|
|
+ if (strpos($v['oper'], ',') !== false) {
|
|
|
+ $user['oper'] += explode(',', $v['oper']);
|
|
|
+ } else {
|
|
|
+ $user['oper'][] = $v['oper'];
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if (strpos($user['oper'], 'all') !== false) {
|
|
|
- $user['oper'] = 'all';
|
|
|
+ if ($v['auth']) {
|
|
|
+ $user['auth'][] = $v['auth'];
|
|
|
}
|
|
|
-
|
|
|
- if (strpos($user['auth'], 'all') !== false) {
|
|
|
- $user['auth'] = 'all';
|
|
|
+ if ($v['auth_data']) {
|
|
|
+ $user['auth_data'][] = $v['auth_data'];
|
|
|
}
|
|
|
-
|
|
|
- if (strpos($user['auth_data'], 'all') !== false) {
|
|
|
- $user['auth_data'] = 'all';
|
|
|
+ if (!$user['top'] && $v['top']) {
|
|
|
+ $top[] = $v['top'];
|
|
|
}
|
|
|
-
|
|
|
- if (strpos($user['top'], 'all') !== false) {
|
|
|
- $user['top'] = 'all';
|
|
|
- } elseif ($user['top']) {
|
|
|
- # 这块暂时不用
|
|
|
- //$top = explode(',', $user['top']);
|
|
|
- //Dever::load('manage/top.update_action', $top[0]);
|
|
|
+ if ($v['self'] == 1) {
|
|
|
+ $user['self'] = $v['self'];
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ $user['oper'] = implode(',', $user['oper']);
|
|
|
+ $user['auth'] = implode(',', $user['auth']);
|
|
|
+ $user['auth_data'] = implode(',', $user['auth_data']);
|
|
|
+
|
|
|
+ if (!$user['top'] && $top) {
|
|
|
+ $user['top'] = implode(',', $top);
|
|
|
+ }
|
|
|
+
|
|
|
+ $user['oper'] = $this->super($user['oper']);
|
|
|
+ $user['auth'] = $this->super($user['auth']);
|
|
|
+ $user['auth_data'] = $this->super($user['auth_data']);
|
|
|
+ $user['top'] = $this->super($user['top']);
|
|
|
+ if ($user['top'] != 'all') {
|
|
|
+ # 这块暂时不用
|
|
|
+ //$top = explode(',', $user['top']);
|
|
|
+ //Dever::load('manage/top.update_action', $top[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ if (strpos($user['oper'], 'all') !== false) {
|
|
|
+ $user['oper'] = 'all';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strpos($user['auth'], 'all') !== false) {
|
|
|
+ $user['auth'] = 'all';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strpos($user['auth_data'], 'all') !== false) {
|
|
|
+ $user['auth_data'] = 'all';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strpos($user['top'], 'all') !== false) {
|
|
|
+ $user['top'] = 'all';
|
|
|
+ } elseif ($user['top']) {
|
|
|
+ # 这块暂时不用
|
|
|
+ //$top = explode(',', $user['top']);
|
|
|
+ //Dever::load('manage/top.update_action', $top[0]);
|
|
|
+ }
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
- $this->save->add($this->name, $user, 3600 * 24 * 7);
|
|
|
+ return $user;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function super($auth)
|
|
|
+ {
|
|
|
+ return $auth;
|
|
|
+ if ($auth == 'all' || strpos($auth, 'all,') !== false) {
|
|
|
+ $auth = 'all';
|
|
|
+ }
|
|
|
+ return $auth;
|
|
|
}
|
|
|
|
|
|
/**
|