26 require_once DOL_DOCUMENT_ROOT.
'/core/triggers/dolibarrtriggers.class.php';
27 include_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) || empty($conf->notification->enabled)) {
73 if (!in_array($action, $this->listofmanagedevents)) {
77 dol_syslog(
"Trigger '".$this->
name.
"' for action '$action' launched by ".__FILE__.
". id=".$object->id);
80 $notify->send($action, $object);
97 if (!is_object($hookmanager)) {
98 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
101 $hookmanager->initHooks(array(
'notification'));
103 $reshook = $hookmanager->executeHooks(
'notifsupported', $parameters, $object, $action);
104 if (empty($reshook)) {
105 if (!empty($hookmanager->resArray[
'arrayofnotifsupported'])) {
106 $this->listofmanagedevents = array_merge($this->listofmanagedevents, $hookmanager->resArray[
'arrayofnotifsupported']);
113 $sql =
"SELECT rowid, code, label, description, elementtype";
114 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_action_trigger";
115 $sql .= $this->
db->order(
"rang, elementtype, code");
117 dol_syslog(
"getListOfManagedEvents Get list of notifications", LOG_DEBUG);
123 $obj = $this->
db->fetch_object(
$resql);
127 if (in_array($obj->code, $this->listofmanagedevents)) {
133 $element = $obj->elementtype;
136 if ($element ==
'order_supplier' && ((empty($conf->fournisseur->enabled) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))) {
138 } elseif ($element ==
'invoice_supplier' && ((empty($conf->fournisseur->enabled) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_invoice->enabled))) {
140 } elseif ($element ==
'withdraw' && empty($conf->prelevement->enabled)) {
142 } elseif ($element ==
'shipping' && empty($conf->expedition->enabled)) {
144 } elseif ($element ==
'member' && empty($conf->adherent->enabled)) {
146 } elseif (($element ==
'expense_report' || $element ==
'expensereport') && empty($conf->expensereport->enabled)) {
148 } elseif (!in_array($element, array(
'order_supplier',
'invoice_supplier',
'withdraw',
'shipping',
'member',
'expense_report',
'expensereport')) && empty($conf->$element->enabled)) {
154 $ret[] = array(
'rowid'=>$obj->rowid,
'code'=>$obj->code,
'label'=>$obj->label,
'description'=>$obj->description,
'elementtype'=>$obj->elementtype);