diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 95e94660621..900d7d690c6 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -457,10 +457,11 @@ class Categorie /** * Vérifie si une catégorie porte le label $label */ - function already_exists ($label) + function already_exists($label) { - $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX."categorie "; - $sql .= "WHERE label = '".$label."'"; + $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"; $res = $this->db->query ($sql); $res = $this->db->fetch_array ($res); diff --git a/htdocs/categories/create.php b/htdocs/categories/create.php index 3f2cee1d547..34295a9277e 100644 --- a/htdocs/categories/create.php +++ b/htdocs/categories/create.php @@ -139,14 +139,14 @@ print '
".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"
"; $OK = false; } -/* else if ($c->already_exists ($_POST["nom"])) + else if ($c->already_exists($_POST["nom"]) { // on regarde si le champ nom n'est pas déjà dans la table catégorie (rappel: un nom est unique dans la table catégorie // nb a déjà été renseigné, il contient le nombre de catégories echo "".$langs->trans ("ErrCatAlreadyExists")."
"; $OK = false; } -*/ + if ($_POST["description"] == '') { echo "".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Description")."\"
";