diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 3e7e1ac2080..e79c39a1955 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -97,6 +97,10 @@ class Contacts extends DolibarrApi $this->contact->fetchRoles(); } + if (isModEnabled('mailing')) { + $this->contact->getNoEmail(); + } + return $this->_cleanObjectDatas($this->contact); } @@ -141,6 +145,10 @@ class Contacts extends DolibarrApi $this->contact->fetchRoles(); } + if (isModEnabled('mailing')) { + $this->contact->getNoEmail(); + } + return $this->_cleanObjectDatas($this->contact); } @@ -250,6 +258,9 @@ class Contacts extends DolibarrApi if ($includeroles) { $contact_static->fetchRoles(); } + if (isModEnabled('mailing')) { + $contact_static->getNoEmail(); + } $obj_ret[] = $this->_cleanObjectDatas($contact_static); } @@ -285,6 +296,9 @@ class Contacts extends DolibarrApi if ($this->contact->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating contact", array_merge(array($this->contact->error), $this->contact->errors)); } + if (isModEnabled('mailing') && !empty($this->contact->email) && isset($this->contact->no_email)) { + $this->contact->setNoEmail($this->contact->no_email); + } return $this->contact->id; } @@ -317,6 +331,10 @@ class Contacts extends DolibarrApi $this->contact->$field = $value; } + if (isModEnabled('mailing') && !empty($this->contact->email) && isset($this->contact->no_email)) { + $this->contact->setNoEmail($this->contact->no_email); + } + if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) { return $this->get($id); }