fix error management

This commit is contained in:
Lucas Marcouiller 2022-05-20 17:03:36 +02:00
parent 86b4c97287
commit 2b84dc39de
3 changed files with 7 additions and 5 deletions

View File

@ -3754,7 +3754,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', 'recurring',
'shapes', 'square', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice',
'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda',
'uncheck', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation',
'uncheck', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook',
'conferenceorbooth', 'eventorganization'
))) {
$fakey = $pictowithouttext;
@ -3805,7 +3805,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'title_agenda'=>'calendar-alt',
'uncheck'=>'times', 'uparrow'=>'share', 'vat'=>'money-check-alt', 'vcard'=>'address-card',
'jabber'=>'comment-o',
'website'=>'globe-americas', 'workstation'=>'pallet',
'website'=>'globe-americas', 'workstation'=>'pallet', 'webhook'=>'bullseye',
'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram'
);
if ($pictowithouttext == 'off') {

View File

@ -469,8 +469,8 @@ class modWebhook extends DolibarrModules
{
global $conf, $langs;
//$result = $this->_load_tables('/install/mysql/tables/', 'webhook');
$result = $this->_load_tables('/webhook/sql/');
$result = $this->_load_tables('/install/mysql/tables/', 'webhook');
//$result = $this->_load_tables('/webhook/sql/');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

View File

@ -93,6 +93,7 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
if (empty($conf->webhook) || empty($conf->webhook->enabled)) {
return 0; // If module is not enabled, we do nothing
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
// Or you can execute some code here
$nbPosts = 0;
@ -104,10 +105,11 @@ class InterfaceWebhookTriggers extends DolibarrTriggers
if (is_array($actionarray) && in_array($action, $actionarray)) {
$jsonstr = '{"triggercode":'.json_encode($action).',"object":'.json_encode($object).'}';
$response = getURLContent($tmpobject->url, 'POST', $jsonstr);
if (empty($response['curl_error_no'])) {
if (empty($response['curl_error_no']) && $response['http_code'] >= 200 && $response['http_code'] < 300) {
$nbPosts ++;
} else {
$errors ++;
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);
}
}
}