fix: possibilité de créer des sous catégories ayant le même nom

This commit is contained in:
Regis Houssin 2006-02-20 18:00:31 +00:00
parent 2ef242bb35
commit 411c3c6d91
2 changed files with 6 additions and 5 deletions

View File

@ -459,8 +459,9 @@ class Categorie
*/ */
function already_exists($label) function already_exists($label)
{ {
$sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX."categorie "; $sql = "SELECT count(c.rowid)";
$sql .= "WHERE label = '".$label."'"; $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->query ($sql);
$res = $this->db->fetch_array ($res); $res = $this->db->fetch_array ($res);

View File

@ -139,14 +139,14 @@ print '<tr><td valign="top" width="30%">';
echo "<p>".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"</p>"; echo "<p>".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"</p>";
$OK = false; $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 // 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 // nb a déjà été renseigné, il contient le nombre de catégories
echo "<p>".$langs->trans ("ErrCatAlreadyExists")."</p>"; echo "<p>".$langs->trans ("ErrCatAlreadyExists")."</p>";
$OK = false; $OK = false;
} }
*/
if ($_POST["description"] == '') if ($_POST["description"] == '')
{ {
echo "<p>".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Description")."\"</p>"; echo "<p>".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Description")."\"</p>";