Merge pull request #17822 from frederic34/zapier_create_contacts

add more capabilities for zapier
This commit is contained in:
Laurent Destailleur
2021-06-11 19:51:01 +02:00
committed by GitHub
13 changed files with 758 additions and 14 deletions

View File

@@ -1043,7 +1043,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
$regType = array();
if (preg_match('/\{(t+)\}/i', $mask, $regType)) {
$masktype = $regType[1];
$masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask)
$masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdparty typent_code (where n is length in mask)
$masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask
} else {
$masktype = '';

View File

@@ -174,8 +174,27 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// Contacts
case 'CONTACT_CREATE':
$resql = $this->db->query($sql);
while ($resql && $obj = $this->db->fetch_array($resql)) {
$cleaned = cleanObjectDatas(dol_clone($object));
$json = json_encode($cleaned);
// call the zapierPostWebhook() function
zapierPostWebhook($obj['url'], $json);
}
$logtriggeraction = true;
break;
case 'CONTACT_MODIFY':
$resql = $this->db->query($sql);
while ($resql && $obj = $this->db->fetch_array($resql)) {
$cleaned = cleanObjectDatas(dol_clone($object));
$json = json_encode($cleaned);
// call the zapierPostWebhook() function
zapierPostWebhook($obj['url'], $json);
}
$logtriggeraction = true;
break;
case 'CONTACT_DELETE':
break;
case 'CONTACT_ENABLEDISABLE':
break;
// Products
@@ -320,10 +339,28 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'LINEFICHINTER_DELETE':
// Members
// case 'MEMBER_CREATE':
case 'MEMBER_CREATE':
$resql = $this->db->query($sql);
while ($resql && $obj = $this->db->fetch_array($resql)) {
$cleaned = cleanObjectDatas(dol_clone($object));
$json = json_encode($cleaned);
// call the zapierPostWebhook() function
zapierPostWebhook($obj['url'], $json);
}
$logtriggeraction = true;
break;
case 'MEMBER_MODIFY':
$resql = $this->db->query($sql);
while ($resql && $obj = $this->db->fetch_array($resql)) {
$cleaned = cleanObjectDatas(dol_clone($object));
$json = json_encode($cleaned);
// call the zapierPostWebhook() function
zapierPostWebhook($obj['url'], $json);
}
$logtriggeraction = true;
break;
// case 'MEMBER_VALIDATE':
// case 'MEMBER_SUBSCRIPTION':
// case 'MEMBER_MODIFY':
// case 'MEMBER_NEW_PASSWORD':
// case 'MEMBER_RESILIATE':
// case 'MEMBER_DELETE':

View File

@@ -75,7 +75,7 @@ class Contacts extends DolibarrApi
throw new RestException(401, 'No permission to read contacts');
}
if ($id == 0) {
if ($id === 0) {
$result = $this->contact->initAsSpecimen();
} else {
$result = $this->contact->fetch($id);