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)) {
106 $jsonstr =
'{"triggercode":'.json_encode($action).
',"object":'.json_encode($object).
'}';
107 $response =
getURLContent($tmpobject->url,
'POST', $jsonstr);
108 if (empty($response[
'curl_error_no']) && $response[
'http_code'] >= 200 && $response[
'http_code'] < 300) {
112 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);
116 if (!empty($errors)) {
Class to stock current configuration.
$conf db
API class for accounts.
Class to manage Dolibarr users.
$conf db name
Only used if Module[ID]Name translation string is not found.
Class of triggers for Webhook module.
getURLContent($url, $postorget= 'GET', $param= '', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage translations.
Class that all the triggers must extend.
__construct($db)
Constructor.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarrr business event is done.
getDesc()
Trigger description.