From 411c3c6d915cd0ed939d6dfb245b7ca69ca37a5a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 20 Feb 2006 18:00:31 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20possibilit=E9=20de=20cr=E9er=20des=20sou?= =?UTF-8?q?s=20cat=E9gories=20ayant=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 | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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 ''; echo "

".$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")."\"

";