4 private static $elastic;
16 public static function start(
string $table =
'egotec_user', array $param = [],
bool $checkHealthy =
false) {
18 require_once(
'base/Ego_User_Elastic.php');
19 self::$elastic =
true;
24 }
catch (Exception $e) {
26 self::$elastic =
false;
35 require_once(
'base/Ego_User_Sql.php');
36 self::$elastic =
false;
46 return self::$elastic;
58 if ($search[
'no_admin'] !==
'' || $search[
'liveserver'] !==
'' || $search[
'no_singlesignon'] !==
'') {
59 switch ((
int) $search[
'no_admin']) {
61 unset($search[
'no_admin']);
64 $search[
'no_admin'] = 1;
67 $search[
'no_admin'] = 0;
80 foreach ($search as $search_param => $search_value) {
81 if (in_array($search_param, $params_to_change)) {
82 switch ($search_value) {
84 unset($search[$search_param]);
87 $search[$search_param] = 0;
90 $search[$search_param] = 1;
108 ($search[
'no_admin'] === 1 && $type ===
'admin')
109 || ($search[
'no_admin'] === 0 && $type ===
'intranet')
110 || ($search[
'user_inactive'] === 0 && $type ===
'inactive')
111 || ($search[
'user_inactive'] === 1 && $type !==
'inactive')
112 || (!empty($search[
'group_role']) && $type ===
'norelation')
113 || (!$search[
'search_deleted'] && $type ===
'trash')
129 public static function isAcceptedUser(User_SQL $user, array $group_role_rel =
null): bool {
131 $group_role_rel = $group_role_rel ?? $user->getGroupRoleRelations();
134 empty($group_role_rel)
135 || $GLOBALS[
'auth']->hasSuperuserPermission()
140 foreach ($group_role_rel as $group_id => $roles) {
142 foreach (explode(
',', $roles) as $role_id) {
144 $GLOBALS[
'auth']->hasPermission($group_id, $role_id)
166 public static function checkRightsFilter(
string $rightsFilter, User_SQL $user, array $group_role_rel =
null): bool {
168 $group_to_check = explode(
',', $rightsFilter)[0];
170 $role_to_check = explode(
',', $rightsFilter)[1];
178 $group_role_rel = $group_role_rel ?? $user->getGroupRoleRelations();
181 foreach ($group_role_rel as $user_group=>$user_roles) {
182 $groups[] = $user_group;
183 foreach (explode(
',', $user_roles) as $role) {
188 $roles = array_unique($roles);
191 if (!$group_to_check || in_array($group_to_check, $groups)) {
196 if (!$role_to_check || in_array($role_to_check, $roles)) {
200 return ($has_group && $has_role);
209 $search = self::start();
211 if (self::isElastic()) {
213 $db = new_db_connection([
214 'table' =>
'egotec_user'
218 $search->indexDelete(
false);
221 while ($record = $db->nextRecord()) {
222 $user =
new User_SQL($record[
'user_id']);
224 $user->update([],
true);
static checkLicence($ini_path)
static isAcceptedUser(User_SQL $user, array $group_role_rel=null)
static filterSearch(array $search)
static start(string $table='egotec_user', array $param=[], bool $checkHealthy=false)
static checkSearchFilter(string $type, array $search)
static checkRightsFilter(string $rightsFilter, User_SQL $user, array $group_role_rel=null)