29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
48 $this->numero = 68305;
51 $this->rights_class =
'webhook';
55 $this->family =
"interface";
58 $this->module_position =
'90';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
68 $this->descriptionlong =
"WebhookDescription";
71 $this->editor_name =
'Editor name';
72 $this->editor_url =
'https://www.example.com';
75 $this->version =
'development';
80 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
86 $this->picto =
'webhook';
89 $this->module_parts = array(
125 'moduleforexternal' => 0,
130 $this->dirs = array(
"/webhook/temp");
133 $this->config_page_url = array(
"webhook.php");
137 $this->hidden =
false;
139 $this->depends = array();
140 $this->requiredby = array();
141 $this->conflictwith = array();
144 $this->langfiles = array(
"webhook");
147 $this->phpmin = array(5, 6);
148 $this->need_dolibarr_version = array(11, -3);
151 $this->warnings_activation = array();
152 $this->warnings_activation_ext = array();
161 $this->
const = array();
169 if (!isset($conf->webhook) || !isset($conf->webhook->enabled)) {
170 $conf->webhook =
new stdClass();
171 $conf->webhook->enabled = 0;
175 $this->tabs = array();
203 $this->dictionaries = array();
230 $this->boxes = array(
241 $this->cronjobs = array(
263 $this->rights = array();
267 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
268 $this->rights[$r][1] =
'Read objects of Webhook';
269 $this->rights[$r][4] =
'webhook_target';
270 $this->rights[$r][5] =
'read';
272 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
273 $this->rights[$r][1] =
'Create/Update objects of Webhook';
274 $this->rights[$r][4] =
'webhook_target';
275 $this->rights[$r][5] =
'write';
277 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
278 $this->rights[$r][1] =
'Delete objects of Webhook';
279 $this->rights[$r][4] =
'webhook_target';
280 $this->rights[$r][5] =
'delete';
285 $this->menu = array();
468 public function init($options =
'')
470 global $conf, $langs;
472 $result = $this->
_load_tables(
'/install/mysql/tables/',
'webhook');
488 $this->
remove($options);
494 $myTmpObjects = array();
495 $myTmpObjects[
'Webhook_target'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
497 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
498 if ($myTmpObjectKey ==
'Webhook_target') {
501 if ($myTmpObjectArray[
'includerefgeneration']) {
502 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_webhook_targets.odt';
503 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
504 $dest = $dirodt.
'/template_webhook_targets.odt';
506 if (file_exists($src) && !file_exists($dest)) {
507 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
509 $result =
dol_copy($src, $dest, 0, 0);
511 $langs->load(
"errors");
512 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
517 $sql = array_merge($sql, array(
518 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->
db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
519 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
520 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey).
"_odt' AND type = '".$this->
db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
521 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
526 return $this->
_init($sql, $options);
537 public function remove($options =
'')
540 return $this->
_remove($sql, $options);