diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 900d7d690c6..62c75e67996 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -457,11 +457,11 @@ class Categorie /** * Vérifie si une catégorie porte le label $label */ - function already_exists($label) + function already_exists($label, $catmere) { $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"; + $sql.= " WHERE c.label = '".$label."' AND c.rowid = ca.fk_categorie_fille 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 9c1bb7658ba..ddb4f9e2fc4 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"],$_POST["catsMeres"]) // 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"],$_POST["catsMeres"])) // 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;