Skip to content

Commit

Permalink
Fix #5843 best way fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanjo Menent committed Oct 7, 2016
1 parent b7b18e3 commit 298e5ce
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions htdocs/categories/class/categorie.class.php
Expand Up @@ -558,6 +558,7 @@ function add_type($obj,$type)
global $user,$langs,$conf;

$error=0;
$trigger=true;

if ($this->id == -1) return -2;

Expand Down Expand Up @@ -598,12 +599,16 @@ function add_type($obj,$type)
{
$cat = new Categorie($this->db);
$cat->id=$objparent->fk_parent;
$result=$cat->add_type($obj, $type);
if ($result < 0)
{
$this->error=$cat->error;
$error++;
}

if (! $cat->containsObject($type,$obj->id)) {
$result=$cat->add_type($obj, $type);
if ($result < 0) {
$this->error=$cat->error;
$error++;
}
} else {
$trigger=false;
}
}
}
}
Expand All @@ -624,10 +629,13 @@ function add_type($obj,$type)
$this->linkto=$obj;

// Call trigger
$result=$this->call_trigger('CATEGORY_LINK',$user);
if ($result < 0) { $error++; }
// End call triggers

if ($trigger) {
$result = $this->call_trigger('CATEGORY_LINK', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (! $error)
{
$this->db->commit();
Expand Down

0 comments on commit 298e5ce

Please sign in to comment.