From f670f71df9a538a9c7e625bff6d1c3c004b37a78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Oct 2020 19:14:03 +0100 Subject: [PATCH] Fix scrutinizer --- htdocs/categories/card.php | 8 +++++--- htdocs/categories/class/categorie.class.php | 20 ++++++++++---------- htdocs/categories/edit.php | 4 +++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 4c17c56c9d0..6598387c36a 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -41,8 +41,8 @@ if (!$user->rights->categorie->lire) accessforbidden(); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $origin = GETPOST('origin', 'alpha'); -$catorigin = GETPOST('catorigin', 'int'); -$type = GETPOST('type', 'alpha'); +$catorigin = GETPOST('catorigin', 'int'); +$type = GETPOST('type', 'aZ09'); $urlfrom = GETPOST('urlfrom', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -73,6 +73,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); +$error = 0; + /* * Actions @@ -127,7 +129,7 @@ if ($action == 'add' && $user->rights->categorie->creer) $object->label = $label; $object->color = $color; $object->description = dol_htmlcleanlastbr($description); - $object->socid = ($socid ? $socid : 'null'); + $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; $object->type = $type; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 8d9b96976cd..086e14b27d0 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -424,17 +424,17 @@ class Categorie extends CommonObject $sql .= " fk_user_creat"; $sql .= ") VALUES ("; $sql .= (int) $this->fk_parent.","; - $sql .= "'".$this->db->escape($this->label)."',"; - $sql .= "'".$this->db->escape($this->description)."',"; - $sql .= "'".$this->db->escape($this->color)."',"; + $sql .= "'".$this->db->escape($this->label)."', "; + $sql .= "'".$this->db->escape($this->description)."', "; + $sql .= "'".$this->db->escape($this->color)."', "; if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { - $sql .= ($this->socid != -1 ? $this->socid : 'null').","; + $sql .= ($this->socid > 0 ? $this->socid : 'null').", "; } - $sql .= "'".$this->db->escape($this->visible)."',"; - $sql .= $this->db->escape($type).","; - $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; - $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').","; - $sql .= (int) $conf->entity.","; + $sql .= "'".$this->db->escape($this->visible)."', "; + $sql .= $this->db->escape($type).", "; + $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').", "; + $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').", "; + $sql .= (int) $conf->entity.", "; $sql .= "'".$this->db->idate($now)."', "; $sql .= (int) $user->id; $sql .= ")"; @@ -516,7 +516,7 @@ class Categorie extends CommonObject $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { - $sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null'); + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->socid : 'null'); } $sql .= ", visible = ".(int) $this->visible; $sql .= ", fk_parent = ".(int) $this->fk_parent; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index a06517c8cda..4b4eaffeb57 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -65,6 +65,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); +$error = 0; + /* * Actions @@ -81,7 +83,7 @@ if ($action == 'update' && $user->rights->categorie->creer) { $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; - $object->socid = ($socid ? $socid : 'null'); + $object->socid = ($socid > 0 ? $socid : 0); $object->visible = $visible; $object->fk_parent = $parent != -1 ? $parent : 0;