From 5aba964726a803db02ae31533f446d0fc1ed4e8d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 28 Aug 2022 14:40:36 +0200 Subject: [PATCH] FIX php8 compatibility --- htdocs/user/class/user.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 008aaae5007..c7c10fe10cd 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -466,14 +466,14 @@ class User extends CommonObject $sql .= " LEFT JOIN ".$this->db->prefix()."c_departements as d ON u.fk_state = d.rowid"; if ($entity < 0) { - if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (!empty($user->entity))) { + if ((!isModEnabled('multicompany') || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (!empty($user->entity))) { $sql .= " WHERE u.entity IN (0, ".((int) $conf->entity).")"; } else { $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } } else { // The fetch was forced on an entity - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } else { $sql .= " WHERE u.entity IN (0, ".((int) (($entity != '' && $entity >= 0) ? $entity : $conf->entity)).")"; // search in entity provided in parameter @@ -588,7 +588,7 @@ class User extends CommonObject // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, // in such case, this admin user must be admin for ALL entities. - if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) { + if (!isModEnabled('multicompany') && $this->admin && $this->entity == 1) { $this->entity = 0; } @@ -1130,7 +1130,7 @@ class User extends CommonObject $sql .= " WHERE r.id = ur.fk_id"; if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) { // on old version, we use entity defined into table r only - $sql .= " AND r.entity IN (0,".(!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").$conf->entity.")"; + $sql .= " AND r.entity IN (0,".(isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").$conf->entity.")"; } else { // On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation. // So we must include the filter on entity on both table r. and ur. @@ -1188,7 +1188,7 @@ class User extends CommonObject $sql .= " ".$this->db->prefix()."rights_def as r"; $sql .= " WHERE r.id = gr.fk_id"; if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) { - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " AND gu.entity IN (0,".$conf->entity.")"; } else { $sql .= " AND r.entity = ".((int) $conf->entity); @@ -3661,7 +3661,7 @@ class User extends CommonObject $sql = "SELECT COUNT(DISTINCT u.rowid) as nb"; $sql .= " FROM ".$this->db->prefix()."user as u"; - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= ", ".$this->db->prefix()."usergroup_user as ug"; $sql .= " WHERE ug.entity IN (".getEntity('usergroup').")"; $sql .= " AND ug.fk_user = u.rowid";