fix php8 warnings

This commit is contained in:
Frédéric FRANCE 2021-03-16 21:13:15 +01:00
parent 22ed95a629
commit 4e8ea5c07e
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -2000,7 +2000,7 @@ abstract class CommonObject
if ($this->element == 'societe') { if ($this->element == 'societe') {
$aliastablesociete = 'te'; // te as table_element $aliastablesociete = 'te'; // te as table_element
} }
$restrictiononfksoc = empty($this->restrictiononfksoc) ? 0 : $this->restrictiononfksoc;
$sql = "SELECT MAX(te.".$fieldid.")"; $sql = "SELECT MAX(te.".$fieldid.")";
$sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te"; $sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
@ -2009,19 +2009,19 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
} elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
} elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
} }
if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { if ($restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
} }
$sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { if ($restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) {
$sql .= " AND sc.fk_user = ".$user->id; $sql .= " AND sc.fk_user = ".$user->id;
} }
if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { if ($restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) {
$sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)';
} }
if (!empty($filter)) { if (!empty($filter)) {
@ -2033,7 +2033,7 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
} elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
$sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
} }
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
@ -2052,16 +2052,16 @@ abstract class CommonObject
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
} }
if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') {
$sql .= ' AND te.fk_soc = '.$socid; $sql .= ' AND te.fk_soc = '.$socid;
} }
if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') {
$sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
} }
if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { if ($restrictiononfksoc && $socid && $this->element == 'societe') {
$sql .= ' AND te.rowid = '.$socid; $sql .= ' AND te.rowid = '.$socid;
} }
//print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; //print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (!$result) { if (!$result) {
@ -2079,19 +2079,19 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
} elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
} elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { } elseif ($restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
} }
if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { if ($restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
} }
$sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid == 'rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { if ($restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) {
$sql .= " AND sc.fk_user = ".$user->id; $sql .= " AND sc.fk_user = ".$user->id;
} }
if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { if ($restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) {
$sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)'; $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)';
} }
if (!empty($filter)) { if (!empty($filter)) {
@ -2103,7 +2103,7 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) { if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
} elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { } elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
$sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
} }
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
@ -2122,16 +2122,16 @@ abstract class CommonObject
$tmparray = explode('@', $this->ismultientitymanaged); $tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')'; $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
} }
if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') {
$sql .= ' AND te.fk_soc = '.$socid; $sql .= ' AND te.fk_soc = '.$socid;
} }
if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') {
$sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)'; $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
} }
if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { if ($restrictiononfksoc && $socid && $this->element == 'societe') {
$sql .= ' AND te.rowid = '.$socid; $sql .= ' AND te.rowid = '.$socid;
} }
//print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; //print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
// Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null
$result = $this->db->query($sql); $result = $this->db->query($sql);