26require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
35 public $listofmanagedevents = array();
46 $this->
name = preg_replace(
'/^Interface/i',
'', get_class($this));
47 $this->family =
"notification";
48 $this->
description =
"Triggers of this module send Email notifications according to Notification module setup.";
50 $this->version = self::VERSION_DOLIBARR;
51 $this->picto =
'email';
53 $this->listofmanagedevents = Notify::$arrayofnotifsupported;
69 if (empty($conf->notification) || !isModEnabled(
'notification')) {
74 if (!in_array($action, $this->listofmanagedevents)) {
78 dol_syslog(
"Trigger '".$this->
name.
"' for action '".$action.
"' launched by ".__FILE__.
". id=".$object->id);
80 $notify =
new Notify($this->db);
81 $notify->send($action, $object);
94 global $conf, $action;
97 if (!is_object($hookmanager)) {
98 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
101 $hookmanager->initHooks(array(
'notification'));
103 $parameters = array();
104 $object =
new stdClass();
105 $reshook = $hookmanager->executeHooks(
'notifsupported', $parameters, $object, $action);
106 if (empty($reshook)) {
107 if (!empty($hookmanager->resArray[
'arrayofnotifsupported'])) {
108 $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray[
'arrayofnotifsupported']);
115 $sql =
"SELECT rowid, code, contexts, label, description, elementtype";
116 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger";
117 $sql .= $this->db->order(
"rang, elementtype, code");
119 dol_syslog(
"getListOfManagedEvents Get list of notifications", LOG_DEBUG);
120 $resql = $this->db->query($sql);
122 $num = $this->db->num_rows($resql);
125 $obj = $this->db->fetch_object($resql);
129 if (in_array($obj->code, $this->listofmanagedevents)) {
135 $element = $obj->elementtype;
138 if ($element ==
'order_supplier' && !isModEnabled(
'supplier_order')) {
140 } elseif ($element ==
'invoice_supplier' && !isModEnabled(
'supplier_invoice')) {
142 } elseif ($element ==
'withdraw' && !isModEnabled(
'prelevement')) {
144 } elseif ($element ==
'shipping' && !isModEnabled(
'expedition')) {
146 } elseif ($element ==
'member' && !isModEnabled(
'adherent')) {
148 } elseif (($element ==
'expense_report' || $element ==
'expensereport') && !isModEnabled(
'expensereport')) {
150 } elseif (!in_array($element, array(
'order_supplier',
'invoice_supplier',
'withdraw',
'shipping',
'member',
'expense_report',
'expensereport')) && empty($conf->$element->enabled)) {
156 $ret[] = array(
'rowid'=>$obj->rowid,
'code'=>$obj->code,
'contexts'=>$obj->contexts,
'label'=>$obj->label,
'description'=>$obj->description,
'elementtype'=>$obj->elementtype);
Class to stock current configuration.
Class that all the triggers must extend.
Class of triggers for notification module.
__construct($db)
Constructor.
getListOfManagedEvents()
Return list of events managed by notification module.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarrr business event is done.
Class to manage notifications.
Class to manage translations.
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.