From 90c923a94b0e9e3ca87273825a0643c3b6be3a1e Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 24 Sep 2022 14:53:29 +0200 Subject: [PATCH] update code toward php8 compliance --- htdocs/product/ajax/products.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- .../class/propalmergepdfproduct.class.php | 16 ++++++++-------- htdocs/product/composition/card.php | 8 ++++---- htdocs/product/stock/card.php | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 1896c801c50..b2ce6e48c09 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -106,7 +106,7 @@ if ($action == 'fetch' && !empty($id)) { $thirdpartytemp->fetch($socid); //Load translation description and label - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $newlang = $thirdpartytemp->default_lang; if (!empty($newlang)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ccc3a05c51f..0460642c746 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1203,7 +1203,7 @@ class Product extends CommonObject $this->id = $id; // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { if ($this->setMultiLangs($user) < 0) { $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; @@ -2495,7 +2495,7 @@ class Product extends CommonObject $this->fetch_optionals(); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS) && empty($ignore_lang_load)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($ignore_lang_load)) { $this->getMultiLangs(); } diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index b4b85c3852a..84b6cbe7123 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -107,7 +107,7 @@ class Propalmergepdfproduct extends CommonObject $sql = "INSERT INTO ".$this->db->prefix()."propal_merge_pdf_product("; $sql .= "fk_product,"; $sql .= "file_name,"; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= "lang,"; } $sql .= "fk_user_author,"; @@ -116,7 +116,7 @@ class Propalmergepdfproduct extends CommonObject $sql .= ") VALUES ("; $sql .= " ".(!isset($this->fk_product) ? 'NULL' : ((int) $this->fk_product)).","; $sql .= " ".(!isset($this->file_name) ? 'NULL' : "'".$this->db->escape($this->file_name)."'").","; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " ".(!isset($this->lang) ? 'NULL' : "'".$this->db->escape($this->lang)."'").","; } $sql .= " ".((int) $user->id).","; @@ -186,7 +186,7 @@ class Propalmergepdfproduct extends CommonObject $this->fk_product = $obj->fk_product; $this->file_name = $obj->file_name; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->lang = $obj->lang; } $this->fk_user_author = $obj->fk_user_author; @@ -233,7 +233,7 @@ class Propalmergepdfproduct extends CommonObject $sql .= " FROM ".$this->db->prefix()."propal_merge_pdf_product as t"; $sql .= " WHERE t.fk_product = ".((int) $product_id); - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($lang)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($lang)) { $sql .= " AND t.lang = '".$this->db->escape($lang)."'"; } @@ -248,7 +248,7 @@ class Propalmergepdfproduct extends CommonObject $line->fk_product = $obj->fk_product; $line->file_name = $obj->file_name; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $line->lang = $obj->lang; } $line->fk_user_author = $obj->fk_user_author; @@ -258,7 +258,7 @@ class Propalmergepdfproduct extends CommonObject $line->import_key = $obj->import_key; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $this->lines[$obj->file_name.'_'.$obj->lang] = $line; } else { $this->lines[$obj->file_name] = $line; @@ -311,7 +311,7 @@ class Propalmergepdfproduct extends CommonObject $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; $sql .= " file_name=".(isset($this->file_name) ? "'".$this->db->escape($this->file_name)."'" : "null").","; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " lang=".(isset($this->lang) ? "'".$this->db->escape($this->lang)."'" : "null").","; } $sql .= " fk_user_mod=".$user->id; @@ -403,7 +403,7 @@ class Propalmergepdfproduct extends CommonObject $sql = "DELETE FROM ".$this->db->prefix()."propal_merge_pdf_product"; $sql .= " WHERE fk_product = ".((int) $product_id); - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($lang_id)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($lang_id)) { $sql .= " AND lang = '".$this->db->escape($lang_id)."'"; } diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 47cc741fb22..c10b5abe93e 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -157,12 +157,12 @@ if ($action == 'search') { $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type as type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.tms as datem, p.tobatch'; $sql .= ', p.tosell as status, p.tobuy as status_buy'; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= ', pl.label as labelm, pl.description as descriptionm'; } $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; @@ -170,7 +170,7 @@ if ($action == 'search') { // For natural search $params = array('p.ref', 'p.label', 'p.description', 'p.note'); // multilang - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (getDolGlobalInt('MAIN_MULTILANGS')) { $params[] = 'pl.label'; $params[] = 'pl.description'; $params[] = 'pl.note'; @@ -682,7 +682,7 @@ if ($id > 0 || !empty($ref)) { print ''.$productstatic->getNomUrl(1, '', 24).''; $labeltoshow = $objp->label; - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->labelm)) { + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($objp->labelm)) { $labeltoshow = $objp->labelm; } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 999c1993a4f..095eaee313f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -692,7 +692,7 @@ if ($action == 'create') { $objp = $db->fetch_object($resql); // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + if (getDolGlobalInt('MAIN_MULTILANGS')) { // si l'option est active $sql = "SELECT label"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product = ".((int) $objp->rowid);