diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index bc26f05611b..0e20662837d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -432,10 +432,11 @@ class Contact extends CommonObject /** * Add a contact into database * - * @param User $user Object user that create - * @return int <0 if KO, >0 if OK + * @param User $user Object user that create + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK */ - public function create($user) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -513,7 +514,7 @@ class Contact extends CommonObject } } - if (!$error) { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_CREATE', $user); if ($result < 0) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 941b992bdc8..bc62db57465 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -872,10 +872,11 @@ class Societe extends CommonObject * Create third party in database. * $this->code_client = -1 and $this->code_fournisseur = -1 means automatic assignement. * - * @param User $user Object of user that ask creation - * @return int >=0 if OK, <0 if KO + * @param User $user Object of user that ask creation + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int >=0 if OK, <0 if KO */ - public function create(User $user) + public function create(User $user, $notrigger = 0) { global $langs, $conf, $mysoc; @@ -1009,7 +1010,7 @@ class Societe extends CommonObject $this->add_commercial($user, $user->id); } - if ($ret >= 0) { + if ($ret >= 0 && !$notrigger) { // Call trigger $result = $this->call_trigger('COMPANY_CREATE', $user); if ($result < 0) { @@ -1052,12 +1053,13 @@ class Societe extends CommonObject /** * Create a contact/address from thirdparty * - * @param User $user Object user - * @param int $no_email 1=Do not send mailing, 0=Ok to recieve mailling - * @param array $tags Array of tag to affect to contact - * @return int <0 if KO, >0 if OK + * @param User $user Object user + * @param int $no_email 1=Do not send mailing, 0=Ok to recieve mailling + * @param array $tags Array of tag to affect to contact + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <0 if KO, >0 if OK */ - public function create_individual(User $user, $no_email = 0, $tags = array()) + public function create_individual(User $user, $no_email = 0, $tags = array(), $notrigger = 0) { global $conf; @@ -1085,7 +1087,7 @@ class Societe extends CommonObject $this->setUpperOrLowerCase(); $contact->phone_pro = $this->phone; - $contactId = $contact->create($user); + $contactId = $contact->create($user, $notrigger); if ($contactId < 0) { $error++; $this->error = $contact->error;