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;
71 if (empty($conf->notification) || !isModEnabled(
'notification')) {
75 if (!is_object($hookmanager)) {
76 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
79 $hookmanager->initHooks(array(
'notification'));
81 $parameters = array();
82 $reshook = $hookmanager->executeHooks(
'notifsupported', $parameters, $object, $action);
83 if (empty($reshook)) {
84 if (!empty($hookmanager->resArray[
'arrayofnotifsupported'])) {
85 $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray[
'arrayofnotifsupported']);
90 if (!in_array($action, $this->listofmanagedevents)) {
94 dol_syslog(
"Trigger '".$this->
name.
"' for action '".$action.
"' launched by ".__FILE__.
". id=".$object->id);
96 $notify =
new Notify($this->db);
97 $notify->send($action, $object);
109 global $conf, $action;
112 if (!is_object($hookmanager)) {
113 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
116 $hookmanager->initHooks(array(
'notification'));
118 $parameters = array();
120 $reshook = $hookmanager->executeHooks(
'notifsupported', $parameters, $object, $action);
121 if (empty($reshook)) {
122 if (!empty($hookmanager->resArray[
'arrayofnotifsupported'])) {
123 $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray[
'arrayofnotifsupported']);
130 $sql =
"SELECT rowid, code, contexts, label, description, elementtype";
131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger";
132 $sql .= $this->db->order(
"rang, elementtype, code");
134 dol_syslog(
"getListOfManagedEvents Get list of notifications", LOG_DEBUG);
135 $resql = $this->db->query($sql);
137 $num = $this->db->num_rows($resql);
140 $obj = $this->db->fetch_object($resql);
144 if (in_array($obj->code, $this->listofmanagedevents)) {
150 $element = $obj->elementtype;
153 if ($element ==
'order_supplier' && !isModEnabled(
'supplier_order')) {
155 } elseif ($element ==
'invoice_supplier' && !isModEnabled(
'supplier_invoice')) {
157 } elseif ($element ==
'withdraw' && !isModEnabled(
'prelevement')) {
159 } elseif ($element ==
'shipping' && !isModEnabled(
'expedition')) {
161 } elseif ($element ==
'member' && !isModEnabled(
'adherent')) {
163 } elseif (($element ==
'expense_report' || $element ==
'expensereport') && !isModEnabled(
'expensereport')) {
165 } elseif (!in_array($element, array(
'order_supplier',
'invoice_supplier',
'withdraw',
'shipping',
'member',
'expense_report',
'expensereport')) && empty($conf->$element->enabled)) {
171 $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.