fix: possibilit de crer des sous catgories ayant le mme nom

This commit is contained in:
Regis Houssin 2006-02-20 18:36:10 +00:00
parent bfccefd66c
commit ca070a0efe
2 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -139,7 +139,7 @@ print '<tr><td valign="top" width="30%">';
echo "<p>".$langs->trans ("ErrForgotField")." \"".$langs->trans ("Label")."\"</p>";
$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 "<p>".$langs->trans ("ErrCatAlreadyExists")."</p>";
$OK = false;