Fix: Corrige creation categorie

This commit is contained in:
Laurent Destailleur 2008-02-15 00:26:52 +00:00
parent c3c507a122
commit 00448a43d5
2 changed files with 18 additions and 9 deletions

View File

@ -325,10 +325,10 @@ class Categorie
}
/**
* Ajout d'un objet à la catégorie
* retour : 1 : OK
* -1 : erreur SQL
* -2 : id non renseign
* \brief Link an object to the category
* \param obj Object to link to category
* \param type Type of category
* \return int 1 : OK, -1 : erreur SQL, -2 : id non renseign, -3 : Already linked
*/
function add_type($obj,$type)
{
@ -346,7 +346,15 @@ class Categorie
}
else
{
$this->error=$this->db->error().' sql='.$sql;
if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->lasterrno();
return -3;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
}
return -1;
}
}

View File

@ -49,7 +49,7 @@ else
accessforbidden();
}
// S<EFBFBD>curit<EFBFBD> d'acc<63>s client et commerciaux
// Securite d'acces client et commerciaux
$objectid = restrictedArea($user, $type, $objectid);
@ -58,7 +58,7 @@ $objectid = restrictedArea($user, $type, $objectid);
* Actions
*/
//Suppression d'un objet d'une cat<EFBFBD>gorie
//Suppression d'un objet d'une categorie
if ($_REQUEST["removecat"])
{
if ($_REQUEST["socid"] && $user->rights->societe->creer)
@ -77,7 +77,7 @@ if ($_REQUEST["removecat"])
$result=$cat->del_type($object,$type);
}
//Ajoute d'un objet dans une cat<EFBFBD>gorie
//Ajoute d'un objet dans une categorie
if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
{
if ($_REQUEST["socid"] && $user->rights->societe->creer)
@ -101,7 +101,8 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0)
}
else
{
$mesg='<div class="error">'.$langs->trans("Error").' '.$cat->error.'</div>';
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="warning">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
else $mesg='<div class="error">'.$langs->trans("Error").' '.$cat->error.'</div>';
}
}