From 7ebd18bc25d2b58826984867c1b80886ffa53c5b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Feb 2006 19:28:21 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20on=20pouvait=20cr=E9er=20des=20cat=E9gor?= =?UTF-8?q?ies=20principales=20avec=20le=20m=EAme=20nom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/categories/categorie.class.php | 7 ++++++- htdocs/categories/create.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index c7572ee9f86..864037e2aef 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -461,7 +461,12 @@ class Categorie { $sql = "SELECT count(c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_association as ca"; - $sql.= " WHERE c.label = '".$label."' AND c.rowid = ca.fk_categorie_fille AND ca.fk_categorie_mere = '".$catmere."'"; + $sql.= " WHERE c.label = '".$label."'"; + if ($catmere) + { + $sql.= " AND c.rowid = ca.fk_categorie_fille"; + $sql.= " AND ca.fk_categorie_mere = '".$catmere."'"; + } $res = $this->db->query ($sql); $res = $this->db->fetch_array ($res); diff --git a/htdocs/categories/create.php b/htdocs/categories/create.php index 498da080ed2..030d784859c 100644 --- a/htdocs/categories/create.php +++ b/htdocs/categories/create.php @@ -139,7 +139,7 @@ print ''; echo "

".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"

"; $OK = false; } - else if ($c->already_exists($_POST["nom"],$cats_meres)) // on regarde si le nom n'existe pas déjà en tant que catégorie ou sous-catégorie + else if ($c->already_exists($_POST["nom"],$cat_mere)) // on regarde si le nom n'existe pas déjà en tant que catégorie ou sous-catégorie { echo "

".$langs->trans ("ErrCatAlreadyExists")."

"; $OK = false;