Cleaner code to avoid to log when nothing is done

This commit is contained in:
Laurent Destailleur 2016-09-12 19:58:43 +02:00
parent 1f9aa856d5
commit efb05fda6a
2 changed files with 24 additions and 25 deletions

View File

@ -44,6 +44,21 @@ class Notify
// Les codes actions sont definis dans la table llx_notify_def
// codes actions supported are
public $arrayofnotifsupported = array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'FICHINTER_VALIDATE',
'FICHINTER_ADD_CONTACT',
'ORDER_SUPPLIER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE',
'SHIPPING_VALIDATE'
);
/**
* Constructor
*
@ -265,9 +280,11 @@ class Notify
{
global $user,$conf,$langs,$mysoc,$dolibarr_main_url_root;
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0;
dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id);
$langs->load("other");
@ -286,26 +303,6 @@ class Notify
$link = '';
$num = 0;
if (! in_array(
$notifcode,
array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'FICHINTER_VALIDATE',
'FICHINTER_ADD_CONTACT',
'ORDER_SUPPLIER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE',
'SHIPPING_VALIDATE'
)
)
)
{
return 0;
}
$oldref=(empty($object->oldref)?$object->ref:$object->oldref);
$newref=(empty($object->newref)?$object->ref:$object->newref);

View File

@ -63,11 +63,13 @@ class InterfaceNotification extends DolibarrTriggers
{
if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify = new Notify($this->db);
if (! in_array($notifcode, $notify->arrayofnotifsupported)) return 0;
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
$notify = new Notify($this->db);
$notify->send($action, $object);
return 1;