28 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
47 $this->numero = 68305;
50 $this->rights_class =
'webhook';
54 $this->family =
"interface";
57 $this->module_position =
'90';
62 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
67 $this->descriptionlong =
"WebhookDescription";
70 $this->version =
'experimental';
75 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
81 $this->picto =
'webhook';
84 $this->module_parts = array(
120 'moduleforexternal' => 0,
125 $this->dirs = array(
"/webhook/temp");
128 $this->config_page_url = array(
"webhook.php");
132 $this->hidden =
false;
134 $this->depends = array();
135 $this->requiredby = array();
136 $this->conflictwith = array();
139 $this->langfiles = array();
142 $this->phpmin = array(7, 0);
143 $this->need_dolibarr_version = array(11, -3);
146 $this->warnings_activation = array();
147 $this->warnings_activation_ext = array();
156 $this->
const = array();
164 if (!isset($conf->webhook) || !isset($conf->webhook->enabled)) {
165 $conf->webhook =
new stdClass();
166 $conf->webhook->enabled = 0;
170 $this->tabs = array();
198 $this->dictionaries = array();
225 $this->boxes = array(
236 $this->cronjobs = array(
258 $this->rights = array();
262 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
263 $this->rights[$r][1] =
'Read objects of Webhook';
264 $this->rights[$r][4] =
'webhook_target';
265 $this->rights[$r][5] =
'read';
267 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
268 $this->rights[$r][1] =
'Create/Update objects of Webhook';
269 $this->rights[$r][4] =
'webhook_target';
270 $this->rights[$r][5] =
'write';
272 $this->rights[$r][0] = $this->numero . sprintf(
"%02d", $r + 1);
273 $this->rights[$r][1] =
'Delete objects of Webhook';
274 $this->rights[$r][4] =
'webhook_target';
275 $this->rights[$r][5] =
'delete';
280 $this->menu = array();
463 public function init($options =
'')
465 global $conf, $langs;
467 $result = $this->
_load_tables(
'/install/mysql/tables/',
'webhook');
483 $this->
remove($options);
489 $myTmpObjects = array();
490 $myTmpObjects[
'Webhook_target'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
492 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
493 if ($myTmpObjectKey ==
'Webhook_target') {
496 if ($myTmpObjectArray[
'includerefgeneration']) {
497 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/'.$moduledir.
'/template_webhook_targets.odt';
498 $dirodt = DOL_DATA_ROOT.
'/doctemplates/'.$moduledir;
499 $dest = $dirodt.
'/template_webhook_targets.odt';
501 if (file_exists($src) && !file_exists($dest)) {
502 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
504 $result =
dol_copy($src, $dest, 0, 0);
506 $langs->load(
"errors");
507 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
512 $sql = array_merge($sql, array(
513 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".$this->
db->escape(strtolower($myTmpObjectKey)).
"' AND entity = ".((
int) $conf->entity),
514 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")",
515 "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),
516 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".$this->
db->escape(strtolower($myTmpObjectKey)).
"', ".((
int) $conf->entity).
")"
521 return $this->
_init($sql, $options);
532 public function remove($options =
'')
535 return $this->
_remove($sql, $options);
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module Webhook.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.