New can view and set no_email for contacts

This commit is contained in:
ptibogxiv 2022-08-20 13:16:04 +02:00 committed by GitHub
parent f95612d9a5
commit e8faeabbe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,6 +97,10 @@ class Contacts extends DolibarrApi
$this->contact->fetchRoles(); $this->contact->fetchRoles();
} }
if (isModEnabled('mailing')) {
$this->contact->getNoEmail();
}
return $this->_cleanObjectDatas($this->contact); return $this->_cleanObjectDatas($this->contact);
} }
@ -141,6 +145,10 @@ class Contacts extends DolibarrApi
$this->contact->fetchRoles(); $this->contact->fetchRoles();
} }
if (isModEnabled('mailing')) {
$this->contact->getNoEmail();
}
return $this->_cleanObjectDatas($this->contact); return $this->_cleanObjectDatas($this->contact);
} }
@ -250,6 +258,9 @@ class Contacts extends DolibarrApi
if ($includeroles) { if ($includeroles) {
$contact_static->fetchRoles(); $contact_static->fetchRoles();
} }
if (isModEnabled('mailing')) {
$contact_static->getNoEmail();
}
$obj_ret[] = $this->_cleanObjectDatas($contact_static); $obj_ret[] = $this->_cleanObjectDatas($contact_static);
} }
@ -285,6 +296,9 @@ class Contacts extends DolibarrApi
if ($this->contact->create(DolibarrApiAccess::$user) < 0) { if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating contact", array_merge(array($this->contact->error), $this->contact->errors)); 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; return $this->contact->id;
} }
@ -317,6 +331,10 @@ class Contacts extends DolibarrApi
$this->contact->$field = $value; $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')) { if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
return $this->get($id); return $this->get($id);
} }