33 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/webhook/class/target.class.php';
50 $this->
name = preg_replace(
'/^Interface/i',
'', get_class($this));
51 $this->family =
"demo";
54 $this->version =
'development';
55 $this->picto =
'webhook';
75 return $this->description;
93 if (empty($conf->webhook) || empty($conf->webhook->enabled)) {
96 require_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
101 $static_object =
new Target($this->db);
102 $target_url = $static_object->fetchAll();
103 foreach ($target_url as $key => $tmpobject) {
104 $actionarray = explode(
",", $tmpobject->trigger_codes);
105 if (is_array($actionarray) && in_array($action, $actionarray)) {
107 $resobject =
new stdClass();
108 $resobject->triggercode = $action;
109 $resobject->object =
dol_clone($object, 2);
111 if (property_exists($resobject->object,
'fields')) {
112 unset($resobject->object->fields);
114 if (property_exists($resobject->object,
'error')) {
115 unset($resobject->object->error);
117 if (property_exists($resobject->object,
'errors')) {
118 unset($resobject->object->errors);
121 $jsonstr = json_encode($resobject);
123 $response =
getURLContent($tmpobject->url,
'POST', $jsonstr, 1, array(), array(
'http',
'https'), 0, -1);
124 if (empty($response[
'curl_error_no']) && $response[
'http_code'] >= 200 && $response[
'http_code'] < 300) {
128 dol_syslog(
"Failed to get url with httpcode=".(!empty($response[
'http_code']) ? $response[
'http_code'] :
"").
" curl_error_no=".(!empty($response[
'curl_error_no']) ? $response[
'curl_error_no'] :
""), LOG_DEBUG);
132 if (!empty($errors)) {