From e8faeabbe10f97962d04b654a5b5a87528475dde Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 20 Aug 2022 13:16:04 +0200 Subject: [PATCH 1/3] New can view and set no_email for contacts --- htdocs/societe/class/api_contacts.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 3e7e1ac2080..bfb66f1c83c 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -96,6 +96,10 @@ class Contacts extends DolibarrApi if ($includeroles) { $this->contact->fetchRoles(); } + + if (isModEnabled('mailing')) { + $this->contact->getNoEmail(); + } return $this->_cleanObjectDatas($this->contact); } @@ -140,6 +144,10 @@ class Contacts extends DolibarrApi if ($includeroles) { $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)) { + $this->contact->setNoEmail($this->contact->no_email); + } return $this->contact->id; } @@ -316,6 +330,10 @@ class Contacts extends DolibarrApi } $this->contact->$field = $value; } + + if (isModEnabled('mailing') && !empty($this->contact->email)) { + $this->contact->setNoEmail($this->contact->no_email); + } if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) { return $this->get($id); From 73321f081279e1bd105009d9d2a8f075d74cf646 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 20 Aug 2022 11:16:54 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/societe/class/api_contacts.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index bfb66f1c83c..4c7833c8b4e 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -96,7 +96,7 @@ class Contacts extends DolibarrApi if ($includeroles) { $this->contact->fetchRoles(); } - + if (isModEnabled('mailing')) { $this->contact->getNoEmail(); } @@ -144,7 +144,7 @@ class Contacts extends DolibarrApi if ($includeroles) { $this->contact->fetchRoles(); } - + if (isModEnabled('mailing')) { $this->contact->getNoEmail(); } @@ -330,7 +330,7 @@ class Contacts extends DolibarrApi } $this->contact->$field = $value; } - + if (isModEnabled('mailing') && !empty($this->contact->email)) { $this->contact->setNoEmail($this->contact->no_email); } From a4fa76eef491ff3c13448f0a6dbb9ef67bc3ad6a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 20 Aug 2022 13:24:38 +0200 Subject: [PATCH 3/3] Update api_contacts.class.php --- htdocs/societe/class/api_contacts.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 4c7833c8b4e..e79c39a1955 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -296,7 +296,7 @@ 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)) { + if (isModEnabled('mailing') && !empty($this->contact->email) && isset($this->contact->no_email)) { $this->contact->setNoEmail($this->contact->no_email); } return $this->contact->id; @@ -331,7 +331,7 @@ class Contacts extends DolibarrApi $this->contact->$field = $value; } - if (isModEnabled('mailing') && !empty($this->contact->email)) { + if (isModEnabled('mailing') && !empty($this->contact->email) && isset($this->contact->no_email)) { $this->contact->setNoEmail($this->contact->no_email); }