NEW Support contact in post() document API

When uploading a document via the API, add the modulepart "contact". By this, documents linked to a contact can be uploaded.
This commit is contained in:
Jakub Stříbrný 2023-03-15 16:00:20 +01:00
parent 388889a0e3
commit 0093954437

View File

@ -666,13 +666,22 @@ class Documents extends DolibarrApi
$modulepart = 'propale';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$object = new Propal($this->db);
} elseif ($modulepart == 'contact' || $modulepart == 'socpeople') {
$modulepart = 'contact';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$object = new Contact($this->db);
$fetchbyid = true;
} else {
// TODO Implement additional moduleparts
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
}
if (is_object($object)) {
$result = $object->fetch('', $ref);
if ($fetchbyid) {
$result = $object->fetch($ref);
} else {
$result = $object->fetch('', $ref);
}
if ($result == 0) {
throw new RestException(404, "Object with ref '".$ref."' was not found.");