Merge pull request #1753 from marcosgdf/triggers-refactor

Refactored Dolibarr triggers
This commit is contained in:
Laurent Destailleur 2014-07-20 04:52:27 +02:00
commit f46db55f71
11 changed files with 654 additions and 1509 deletions

View File

@ -23,6 +23,7 @@
* \brief Fichier de la classe de gestion des triggers * \brief Fichier de la classe de gestion des triggers
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/triggers/DolibarrTriggers.class.php';
/** /**
* Class to manage triggers * Class to manage triggers

View File

@ -0,0 +1,149 @@
<?php
/*
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Class that all the triggers must extend
*/
abstract class DolibarrTriggers
{
/**
* Database handler
* @var DoliDB
*/
protected $db;
/**
* Name of the trigger
* @var mixed|string
*/
public $name = '';
/**
* Description of the trigger
* @var string
*/
public $description = '';
/**
* Version of the trigger
* @var string
*/
public $version = self::VERSION_DEVELOPMENT;
/**
* Image of the trigger
* @var string
*/
public $picto = 'technic';
/**
* Category of the trigger
* @var string
*/
public $family = '';
/**
* Error reported by the trigger
* @var string
* @deprecated Use $this->errors
*/
public $error = '';
/**
* Errors reported by the trigger
* @var array
*/
public $errors = array();
const VERSION_DEVELOPMENT = 'development';
const VERSION_EXPERIMENTAL = 'experimental';
const VERSION_DOLIBARR = 'dolibarr';
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct(DoliDB $db) {
$this->db = $db;
if (!isset($this->name)) {
$this->name = preg_replace('/^Interface/i', '', get_class($this));
}
}
/**
* Returns the name of the trigger file
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Returns the description of trigger file
*
* @return string
*/
public function getDesc()
{
return $this->description;
}
/**
* Returns the version of the trigger file
*
* @return string Version of trigger file
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == self::VERSION_DEVELOPMENT) {
return $langs->trans("Development");
} elseif ($this->version == self::VERSION_EXPERIMENTAL) {
return $langs->trans("Experimental");
} elseif ($this->version == self::VERSION_DOLIBARR) {
return DOL_VERSION;
} elseif ($this->version) {
return $this->version;
} else {
return $langs->trans("Unknown");
}
}
/**
* Function called when a Dolibarrr business event is done.
* All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers
*
* @param string $action Event action code
* @param Object $object Object
* @param User $user Object user
* @param Translate $langs Object langs
* @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/
abstract function run_trigger($action, $object, User $user, Translate $langs, Conf $conf);
}

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,67 +27,12 @@
/** /**
* Class of triggers for security events * Class of triggers for security events
*/ */
class InterfaceLogevents class InterfaceLogevents extends DolibarrTriggers
{ {
var $db; public $picto = 'technic';
var $error; public $family = 'core';
public $description = "Triggers of this module allows to add security event records inside Dolibarr.";
var $date; public $version = self::VERSION_DOLIBARR;
var $duree;
var $texte;
var $desc;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "core";
$this->description = "Triggers of this module allows to add security event records inside Dolibarr.";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
$this->picto = 'technic';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
@ -97,10 +43,9 @@ class InterfaceLogevents
* @param User $user Object user * @param User $user Object user
* @param Translate $langs Object langs * @param Translate $langs Object langs
* @param conf $conf Object conf * @param conf $conf Object conf
* @param string $entity Value for instance of data (Always 1 except if module MultiCompany is installed)
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf,$entity=1) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features) if (! empty($conf->global->MAIN_LOGEVENTS_DISABLE_ALL)) return 0; // Log events is disabled (hidden features)
@ -110,8 +55,7 @@ class InterfaceLogevents
if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form) if (empty($conf->entity)) $conf->entity = $entity; // forcing of the entity if it's not defined (ex: in login form)
$this->date=dol_now(); $date = dol_now();
$this->duree=0;
// Actions // Actions
if ($action == 'USER_LOGIN') if ($action == 'USER_LOGIN')
@ -119,24 +63,24 @@ class InterfaceLogevents
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte="(UserLogged,".$object->login.")"; $text="(UserLogged,".$object->login.")";
$this->desc="(UserLogged,".$object->login.")"; $desc="(UserLogged,".$object->login.")";
} }
if ($action == 'USER_LOGIN_FAILED') if ($action == 'USER_LOGIN_FAILED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$object->trigger_mesg; // Message direct $text=$object->trigger_mesg; // Message direct
$this->desc=$object->trigger_mesg; // Message direct $desc=$object->trigger_mesg; // Message direct
} }
if ($action == 'USER_LOGOUT') if ($action == 'USER_LOGOUT')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte="(UserLogoff,".$object->login.")"; $text="(UserLogoff,".$object->login.")";
$this->desc="(UserLogoff,".$object->login.")"; $desc="(UserLogoff,".$object->login.")";
} }
if ($action == 'USER_CREATE') if ($action == 'USER_CREATE')
{ {
@ -144,8 +88,8 @@ class InterfaceLogevents
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("NewUserCreated",$object->login); $text=$langs->transnoentities("NewUserCreated",$object->login);
$this->desc=$langs->transnoentities("NewUserCreated",$object->login); $desc=$langs->transnoentities("NewUserCreated",$object->login);
} }
elseif ($action == 'USER_MODIFY') elseif ($action == 'USER_MODIFY')
{ {
@ -153,8 +97,8 @@ class InterfaceLogevents
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("EventUserModified",$object->login); $text=$langs->transnoentities("EventUserModified",$object->login);
$this->desc=$langs->transnoentities("EventUserModified",$object->login); $desc=$langs->transnoentities("EventUserModified",$object->login);
} }
elseif ($action == 'USER_NEW_PASSWORD') elseif ($action == 'USER_NEW_PASSWORD')
{ {
@ -162,8 +106,8 @@ class InterfaceLogevents
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("NewUserPassword",$object->login); $text=$langs->transnoentities("NewUserPassword",$object->login);
$this->desc=$langs->transnoentities("NewUserPassword",$object->login); $desc=$langs->transnoentities("NewUserPassword",$object->login);
} }
elseif ($action == 'USER_ENABLEDISABLE') elseif ($action == 'USER_ENABLEDISABLE')
{ {
@ -172,13 +116,13 @@ class InterfaceLogevents
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
if ($object->statut == 0) if ($object->statut == 0)
{ {
$this->texte=$langs->transnoentities("UserEnabled",$object->login); $text=$langs->transnoentities("UserEnabled",$object->login);
$this->desc=$langs->transnoentities("UserEnabled",$object->login); $desc=$langs->transnoentities("UserEnabled",$object->login);
} }
if ($object->statut == 1) if ($object->statut == 1)
{ {
$this->texte=$langs->transnoentities("UserDisabled",$object->login); $text=$langs->transnoentities("UserDisabled",$object->login);
$this->desc=$langs->transnoentities("UserDisabled",$object->login); $desc=$langs->transnoentities("UserDisabled",$object->login);
} }
} }
elseif ($action == 'USER_DELETE') elseif ($action == 'USER_DELETE')
@ -186,8 +130,8 @@ class InterfaceLogevents
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("UserDeleted",$object->login); $text=$langs->transnoentities("UserDeleted",$object->login);
$this->desc=$langs->transnoentities("UserDeleted",$object->login); $desc=$langs->transnoentities("UserDeleted",$object->login);
} }
// Groupes // Groupes
@ -196,24 +140,24 @@ class InterfaceLogevents
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("NewGroupCreated",$object->nom); $text=$langs->transnoentities("NewGroupCreated",$object->nom);
$this->desc=$langs->transnoentities("NewGroupCreated",$object->nom); $desc=$langs->transnoentities("NewGroupCreated",$object->nom);
} }
elseif ($action == 'GROUP_MODIFY') elseif ($action == 'GROUP_MODIFY')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("GroupModified",$object->nom); $text=$langs->transnoentities("GroupModified",$object->nom);
$this->desc=$langs->transnoentities("GroupModified",$object->nom); $desc=$langs->transnoentities("GroupModified",$object->nom);
} }
elseif ($action == 'GROUP_DELETE') elseif ($action == 'GROUP_DELETE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("users"); $langs->load("users");
// Initialisation donnees (date,duree,texte,desc) // Initialisation donnees (date,duree,texte,desc)
$this->texte=$langs->transnoentities("GroupDeleted",$object->nom); $text=$langs->transnoentities("GroupDeleted",$object->nom);
$this->desc=$langs->transnoentities("GroupDeleted",$object->nom); $desc=$langs->transnoentities("GroupDeleted",$object->nom);
} }
// If not found // If not found
@ -226,15 +170,13 @@ class InterfaceLogevents
*/ */
// Add entry in event table // Add entry in event table
if ($this->date)
{
include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
$event=new Events($this->db); $event=new Events($this->db);
$event->type=$action; $event->type=$action;
$event->dateevent=$this->date; $event->dateevent=$date;
$event->label=$this->texte; $event->label=$text;
$event->description=$this->desc; $event->description=$desc;
$event->user_agent=$_SERVER["HTTP_USER_AGENT"]; $event->user_agent=$_SERVER["HTTP_USER_AGENT"];
$result=$event->create($user); $result=$event->create($user);
@ -249,7 +191,6 @@ class InterfaceLogevents
dol_syslog(get_class($this).": ".$this->error, LOG_ERR); dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
return -1; return -1;
}
} }
return 0; return 0;

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com> /* Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,67 +26,16 @@
/** /**
* Class of triggers for paypal module * Class of triggers for paypal module
*/ */
class InterfacePaypalWorkflow class InterfacePaypalWorkflow extends DolibarrTriggers
{ {
var $db; public $picto = 'paypal@paypal';
public $family = 'paypal';
public $description = "Triggers of this module allows to manage paypal workflow";
public $version = self::VERSION_DOLIBARR;
/** /**
* Constructor * Function called when a Dolibarrr business event is done.
* * All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "paypal";
$this->description = "Triggers of this module allows to manage paypal workflow";
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
$this->picto = 'paypal@paypal';
}
/**
* Renvoi nom du lot de triggers
*
* @return string Nom du lot de triggers
*/
function getName()
{
return $this->name;
}
/**
* Renvoi descriptif du lot de triggers
*
* @return string Descriptif du lot de triggers
*/
function getDesc()
{
return $this->description;
}
/**
* Renvoi version du lot de triggers
*
* @return string Version du lot de triggers
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("Development");
elseif ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/**
* Fonction appelee lors du declenchement d'un evenement Dolibarr.
* D'autres fonctions run_trigger peuvent etre presentes dans core/triggers
* *
* @param string $action Event action code * @param string $action Event action code
* @param Object $object Object * @param Object $object Object
@ -94,7 +44,7 @@ class InterfacePaypalWorkflow
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
// Mettre ici le code a executer en reaction de l'action // Mettre ici le code a executer en reaction de l'action
// Les donnees de l'action sont stockees dans $object // Les donnees de l'action sont stockees dans $object

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com> /* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,63 +28,12 @@
* Class of triggers for workflow module * Class of triggers for workflow module
*/ */
class InterfaceWorkflowManager class InterfaceWorkflowManager extends DolibarrTriggers
{ {
var $db; public $picto = 'paypal@paypal';
public $family = 'core';
/** public $description = "Triggers of this module allows to manage workflows";
* Constructor public $version = self::VERSION_DOLIBARR;
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "core";
$this->description = "Triggers of this module allows to manage workflows";
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
$this->picto = 'technic';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("Development");
elseif ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
@ -96,7 +46,7 @@ class InterfaceWorkflowManager
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing if (empty($conf->workflow->enabled)) return 0; // Module not active, we do nothing

View File

@ -3,6 +3,7 @@
* Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,67 +29,12 @@
/** /**
* Class of triggered functions for agenda module * Class of triggered functions for agenda module
*/ */
class InterfaceActionsAuto class InterfaceActionsAuto extends DolibarrTriggers
{ {
var $db; public $family = 'agenda';
var $error; public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
public $version = self::VERSION_DOLIBARR;
var $date; public $picto = 'action';
var $duree;
var $texte;
var $desc;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "agenda";
$this->description = "Triggers of this module add actions in agenda according to setup made in agenda setup.";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
$this->picto = 'action';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
@ -111,40 +57,39 @@ class InterfaceActionsAuto
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
$key='MAIN_AGENDA_ACTIONAUTO_'.$action; // Module not active, we do nothing
//dol_syslog("xxxxxxxxxxx".$key); if (empty($conf->agenda->enabled)) {
return 0;
}
if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing $key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
if (empty($conf->global->$key)) return 0; // Do not log events not enabled for this action
$ok=0; // Do not log events not enabled for this action
if (empty($conf->global->$key)) {
return 0;
}
$langs->load("agenda");
// Actions // Actions
if ($action == 'COMPANY_CREATE') if ($action == 'COMPANY_CREATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
$object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
//$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client);
//$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$object->socid=$object->id; $object->socid=$object->id;
$ok=1;
} }
elseif ($action == 'COMPANY_SENTBYMAIL') elseif ($action == 'COMPANY_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("orders"); $langs->load("orders");
$langs->load("agenda");
if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR);
@ -152,14 +97,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'CONTRACT_VALIDATE') elseif ($action == 'CONTRACT_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("contracts"); $langs->load("contracts");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref);
@ -167,13 +109,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'PROPAL_VALIDATE') elseif ($action == 'PROPAL_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("propal"); $langs->load("propal");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref);
@ -181,13 +120,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'PROPAL_SENTBYMAIL') elseif ($action == 'PROPAL_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("propal"); $langs->load("propal");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
@ -199,13 +135,10 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'PROPAL_CLOSE_SIGNED') elseif ($action == 'PROPAL_CLOSE_SIGNED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("propal"); $langs->load("propal");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
@ -213,13 +146,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'PROPAL_CLOSE_REFUSED') elseif ($action == 'PROPAL_CLOSE_REFUSED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("propal"); $langs->load("propal");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
@ -227,13 +157,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'ORDER_VALIDATE') elseif ($action == 'ORDER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("orders"); $langs->load("orders");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
@ -241,13 +168,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'ORDER_SENTBYMAIL') elseif ($action == 'ORDER_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("orders"); $langs->load("orders");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
@ -259,14 +183,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_VALIDATE') elseif ($action == 'BILL_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
@ -274,14 +195,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_UNVALIDATE') elseif ($action == 'BILL_UNVALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
@ -289,14 +207,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_SENTBYMAIL') elseif ($action == 'BILL_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
@ -308,14 +223,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_PAYED') elseif ($action == 'BILL_PAYED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
// Values for this action can't be defined by caller. // Values for this action can't be defined by caller.
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
@ -324,14 +236,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_CANCEL') elseif ($action == 'BILL_CANCEL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
@ -339,14 +248,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'FICHINTER_VALIDATE') elseif ($action == 'FICHINTER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("interventions"); $langs->load("interventions");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref);
@ -356,14 +262,11 @@ class InterfaceActionsAuto
$object->sendtoid=0; $object->sendtoid=0;
$object->fk_element=0; $object->fk_element=0;
$object->elementtype=''; $object->elementtype='';
$ok=1;
} }
elseif ($action == 'FICHINTER_SENTBYMAIL') elseif ($action == 'FICHINTER_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("interventions"); $langs->load("interventions");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
@ -372,14 +275,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'FICHINTER_CLASSIFY_BILLED') elseif ($action == 'FICHINTER_CLASSIFY_BILLED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("interventions"); $langs->load("interventions");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilled",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilled",$object->ref);
@ -387,14 +287,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'SHIPPING_VALIDATE') elseif ($action == 'SHIPPING_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("sendings"); $langs->load("sendings");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",$object->ref);
@ -406,14 +303,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'SHIPPING_SENTBYMAIL') elseif ($action == 'SHIPPING_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("sendings"); $langs->load("sendings");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
@ -425,13 +319,10 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'ORDER_SUPPLIER_VALIDATE') elseif ($action == 'ORDER_SUPPLIER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("orders"); $langs->load("orders");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
@ -439,13 +330,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'ORDER_SUPPLIER_APPROVE') elseif ($action == 'ORDER_SUPPLIER_APPROVE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("orders"); $langs->load("orders");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
@ -453,13 +341,10 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'ORDER_SUPPLIER_REFUSE') elseif ($action == 'ORDER_SUPPLIER_REFUSE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("orders"); $langs->load("orders");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
@ -467,14 +352,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$langs->load("orders"); $langs->load("orders");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
@ -487,14 +369,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_SUPPLIER_VALIDATE') elseif ($action == 'BILL_SUPPLIER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
@ -502,14 +381,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$langs->load("orders"); $langs->load("orders");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
@ -522,14 +398,11 @@ class InterfaceActionsAuto
// Parameters $object->sendtoid defined by caller // Parameters $object->sendtoid defined by caller
//$object->sendtoid=0; //$object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_SUPPLIER_PAYED') elseif ($action == 'BILL_SUPPLIER_PAYED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
@ -537,14 +410,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'BILL_SUPPLIER_CANCELED') elseif ($action == 'BILL_SUPPLIER_CANCELED')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("bills"); $langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
@ -552,16 +422,13 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
// Members // Members
elseif ($action == 'MEMBER_VALIDATE') elseif ($action == 'MEMBER_VALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("members"); $langs->load("members");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref);
@ -571,14 +438,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'MEMBER_SUBSCRIPTION') elseif ($action == 'MEMBER_SUBSCRIPTION')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("members"); $langs->load("members");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref);
@ -590,18 +454,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
}
elseif ($action == 'MEMBER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }
elseif ($action == 'MEMBER_RESILIATE') elseif ($action == 'MEMBER_RESILIATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("members"); $langs->load("members");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref);
@ -611,14 +468,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif ($action == 'MEMBER_DELETE') elseif ($action == 'MEMBER_DELETE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("members"); $langs->load("members");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref);
@ -628,16 +482,13 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
// Projects // Projects
elseif ($action == 'PROJECT_CREATE') elseif ($action == 'PROJECT_CREATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("projects"); $langs->load("projects");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref);
@ -646,15 +497,12 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
// Project tasks // Project tasks
elseif($action == 'TASK_CREATE') { elseif($action == 'TASK_CREATE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("projects"); $langs->load("projects");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
@ -664,14 +512,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif($action == 'TASK_MODIFY') { elseif($action == 'TASK_MODIFY') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("projects"); $langs->load("projects");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref);
@ -680,14 +525,11 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
elseif($action == 'TASK_DELETE') { elseif($action == 'TASK_DELETE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other"); $langs->load("other");
$langs->load("projects"); $langs->load("projects");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref);
@ -696,7 +538,6 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;
$ok=1;
} }
// The trigger was enabled but we are missing the implementation, let the log know // The trigger was enabled but we are missing the implementation, let the log know
@ -706,9 +547,9 @@ class InterfaceActionsAuto
return 0; return 0;
} }
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
// Add entry in event table // Add entry in event table
if ($ok)
{
$now=dol_now(); $now=dol_now();
if(isset($_SESSION['listofnames'])) if(isset($_SESSION['listofnames']))
@ -763,7 +604,6 @@ class InterfaceActionsAuto
dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR); dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR);
return -1; return -1;
} }
}
return 0; return 0;
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,63 +28,12 @@ require_once (DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
/** /**
* Class of triggers for ldap module * Class of triggers for ldap module
*/ */
class InterfaceLdapsynchro class InterfaceLdapsynchro extends DolibarrTriggers
{ {
var $db; public $family = 'ldap';
var $error; public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
public $version = self::VERSION_DOLIBARR;
public $picto = 'technic';
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "ldap";
$this->description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
$this->picto = 'technic';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
@ -96,7 +46,7 @@ class InterfaceLdapsynchro
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,63 +28,12 @@ require_once (DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
/** /**
* Class of triggers for MailmanSpip module * Class of triggers for MailmanSpip module
*/ */
class InterfaceMailmanSpipsynchro class InterfaceMailmanSpipsynchro extends DolibarrTriggers
{ {
var $db; public $family = 'ldap';
var $error; public $description = "Triggers of this module allows to synchronize Mailman an Spip.";
public $version = self::VERSION_DOLIBARR;
public $picto = 'technic';
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "ldap";
$this->description = "Triggers of this module allows to synchronize Mailman an Spip.";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
$this->picto = 'technic';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
@ -96,7 +46,7 @@ class InterfaceMailmanSpipsynchro
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing
@ -106,38 +56,7 @@ class InterfaceMailmanSpipsynchro
return 0; return 0;
} }
// Users if ($action == 'CATEGORY_LINK')
if ($action == 'USER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_NEW_PASSWORD')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_ENABLEDISABLE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_SETINGROUP')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_REMOVEFROMGROUP')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'CATEGORY_LINK')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -211,10 +130,6 @@ class InterfaceMailmanSpipsynchro
return $return; return $return;
} }
elseif ($action == 'MEMBER_NEW_PASSWORD')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -231,16 +146,10 @@ class InterfaceMailmanSpipsynchro
{ {
$return=1; $return=1;
} }
return $return;
} }
// If not found
/*
else
{
dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
return -1;
}
*/
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013-2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,9 +27,13 @@
/** /**
* Class of triggers for notification module * Class of triggers for notification module
*/ */
class InterfaceNotification class InterfaceNotification extends DolibarrTriggers
{ {
var $db; public $family = 'notification';
public $description = "Triggers of this module send email notifications according to Notification module setup.";
public $version = self::VERSION_DOLIBARR;
public $picto = 'email';
var $listofmanagedevents=array( var $listofmanagedevents=array(
'BILL_VALIDATE', 'BILL_VALIDATE',
'ORDER_VALIDATE', 'ORDER_VALIDATE',
@ -40,58 +44,6 @@ class InterfaceNotification
'SHIPPING_VALIDATE' 'SHIPPING_VALIDATE'
); );
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "notification";
$this->description = "Triggers of this module send email notifications according to Notification module setup.";
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
$this->picto = 'email';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
* All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers * All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers
@ -103,124 +55,76 @@ class InterfaceNotification
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing if (empty($conf->notification->enabled)) return 0; // Module not active, we do nothing
require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
if ($action == 'BILL_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$filepdf=''; // We can't add PDF as it is not generated yet.
$langs->load("other"); $langs->load("other");
switch ($action) {
case 'BILL_VALIDATE':
$dir_output = $conf->facture->dir_output;
$object_type = 'facture';
$mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated",$object->ref);
break;
$notify = new Notify($this->db); case 'ORDER_VALIDATE':
$notify->send($action, $object->socid, $mesg, 'facture', $object->id, $filepdf); $dir_output = $conf->commande->dir_output;
} $object_type = 'order';
elseif ($action == 'ORDER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$filepdf=''; // We can't add PDF as it is not generated yet.
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated",$object->ref);
break;
$notify = new Notify($this->db); case 'PROPAL_VALIDATE':
$notify->send($action, $object->socid, $mesg, 'order', $object->id, $filepdf); $dir_output = $conf->propal->dir_output;
} $object_type = 'propal';
elseif ($action == 'PROPAL_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->propal->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$filepdf=''; // We can't add PDF as it is not generated yet.
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$object->ref);
break;
$notify = new Notify($this->db); case 'FICHINTER_VALIDATE':
$notify->send($action, $object->socid, $mesg, 'propal', $object->id, $filepdf); $dir_output = $conf->facture->dir_output;
} $object_type = 'ficheinter';
elseif ($action == 'FICHINTER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$filepdf=''; // We can't add PDF as it is not generated yet.
$langs->load("other");
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref); $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref);
break;
$notify = new Notify($this->db); case 'ORDER_SUPPLIER_APPROVE':
$notify->send($action, $object->socid, $mesg, 'ficheinter', $object->id, $filepdf); $dir_output = $conf->fournisseur->dir_output.'/commande/';
} $object_type = 'order_supplier';
elseif ($action == 'ORDER_SUPPLIER_APPROVE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->getFullName($langs)); $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
$notify = new Notify($this->db); case 'ORDER_SUPPLIER_REFUSE':
$notify->send($action, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf); $dir_output = $conf->fournisseur->dir_output.'/commande/';
} $object_type = 'order_supplier';
elseif ($action == 'ORDER_SUPPLIER_REFUSE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->fournisseur->dir_output . '/commande/' . $ref . '/' . $ref . '.pdf';
if (! file_exists($filepdf)) $filepdf='';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->getFullName($langs)); $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy",$object->ref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'SHIPPING_VALIDATE':
$dir_output = $conf->expedition->dir_output.'/sending/';
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$object->ref);
break;
default:
return 0;
$notify = new Notify($this->db);
$notify->send($action, $object->socid, $mesg, 'order_supplier', $object->id, $filepdf);
} }
elseif ($action == 'SHIPPING_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$ref = dol_sanitizeFileName($object->ref); $ref = dol_sanitizeFileName($object->ref);
$filepdf = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; $pdf_path = "$dir_output/$ref/$ref.pdf";
if (! file_exists($filepdf)) $filepdf='';
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$object->ref);
if (!file_exists($pdf_path)) {
// We can't add PDF as it is not generated yet.
$filepdf = '';
} else {
$filepdf = $pdf_path;
}
$notify = new Notify($this->db); $notify = new Notify($this->db);
$notify->send($action, $object->socid, $mesg, 'expedition', $object->id, $filepdf); $notify->send($action, $object->socid, $mesg, $object_type, $object->id, $filepdf);
}
// If not found return 1;
/*
else
{
dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
return -1;
}
*/
return 0;
} }
@ -231,7 +135,7 @@ class InterfaceNotification
*/ */
function getListOfManagedEvents() function getListOfManagedEvents()
{ {
global $conf,$langs; global $conf;
$ret=array(); $ret=array();

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -32,63 +33,13 @@
/** /**
* Class of triggers for demo module * Class of triggers for demo module
*/ */
class InterfaceDemo class InterfaceDemo extends DolibarrTriggers
{ {
var $db;
/** public $family = 'demo';
* Constructor public $picto = 'technic';
* public $description = "Triggers of this module are empty functions. They have no effect. They are provided for tutorial purpose only.";
* @param DoliDB $db Database handler public $version = self::VERSION_DOLIBARR;
*/
function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "demo";
$this->description = "Triggers of this module are empty functions. They have no effect. They are provided for tutorial purpose only.";
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
$this->picto = 'technic';
}
/**
* Return name of trigger file
*
* @return string Name of trigger file
*/
function getName()
{
return $this->name;
}
/**
* Return description of trigger file
*
* @return string Description of trigger file
*/
function getDesc()
{
return $this->description;
}
/**
* Return version of trigger file
*
* @return string Version of trigger file
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("Development");
elseif ($this->version == 'experimental') return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("Unknown");
}
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
@ -101,605 +52,205 @@ class InterfaceDemo
* @param conf $conf Object conf * @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
function run_trigger($action,$object,$user,$langs,$conf) public function run_trigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
// Put here code you want to execute when a Dolibarr business events occurs. // Put here code you want to execute when a Dolibarr business events occurs.
// Data and type of action are stored into $object and $action // Data and type of action are stored into $object and $action
switch ($action) {
// Users // Users
if ($action == 'USER_LOGIN') case 'USER_LOGIN':
{ case 'USER_UPDATE_SESSION':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'USER_CREATE':
} case 'USER_CREATE_FROM_CONTACT':
elseif ($action == 'USER_UPDATE_SESSION') case 'USER_LOGIN':
{
// Warning: To increase performances, this action is triggered only if // Warning: To increase performances, this action is triggered only if
// constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1. // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'USER_UPDATE_SESSION':
} case 'USER_CREATE':
elseif ($action == 'USER_CREATE') case 'USER_CREATE_FROM_CONTACT':
{ case 'USER_MODIFY':
$object->error=$action; case 'USER_NEW_PASSWORD':
return -1; case 'USER_ENABLEDISABLE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'USER_DELETE':
} case 'USER_LOGOUT':
elseif ($action == 'USER_CREATE_FROM_CONTACT') case 'USER_SETINGROUP':
{ case 'USER_REMOVEFROMGROUP':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_NEW_PASSWORD')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_ENABLEDISABLE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_LOGOUT')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_SETINGROUP')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'USER_REMOVEFROMGROUP')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Action // Actions
elseif ($action == 'ACTION_MODIFY') case 'ACTION_MODIFY':
{ case 'ACTION_CREATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'ACTION_DELETE':
}
elseif ($action == 'ACTION_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ACTION_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Groups // Groups
elseif ($action == 'GROUP_CREATE') case 'GROUP_CREATE':
{ case 'GROUP_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'GROUP_DELETE':
}
elseif ($action == 'GROUP_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'GROUP_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Companies // Companies
elseif ($action == 'COMPANY_CREATE') case 'COMPANY_CREATE':
{ case 'COMPANY_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'COMPANY_DELETE':
}
elseif ($action == 'COMPANY_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'COMPANY_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Contacts // Contacts
elseif ($action == 'CONTACT_CREATE') case 'CONTACT_CREATE':
{ case 'CONTACT_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'CONTACT_DELETE':
} case 'CONTACT_ENABLEDISABLE':
elseif ($action == 'CONTACT_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'CONTACT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'CONTACT_ENABLEDISABLE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Products // Products
elseif ($action == 'PRODUCT_CREATE') case 'PRODUCT_CREATE':
{ case 'PRODUCT_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'PRODUCT_DELETE':
} case 'PRODUCT_PRICE_MODIFY':
elseif ($action == 'PRODUCT_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PRODUCT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PRODUCT_PRICE_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
//Stock mouvement //Stock mouvement
elseif ($action == 'STOCK_MOVEMENT') case 'STOCK_MOVEMENT':
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
//MYECMDIR //MYECMDIR
elseif ($action == 'MYECMDIR_DELETE') case 'MYECMDIR_DELETE':
{ case 'MYECMDIR_CREATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'MYECMDIR_MODIFY':
}
elseif ($action == 'MYECMDIR_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'MYECMDIR_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Customer orders // Customer orders
elseif ($action == 'ORDER_CREATE') case 'ORDER_CREATE':
{ case 'ORDER_CLONE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'ORDER_VALIDATE':
} case 'ORDER_DELETE':
elseif ($action == 'ORDER_CLONE') case 'ORDER_BUILDDOC':
{ case 'ORDER_SENTBYMAIL':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'ORDER_CLASSIFY_BILLED':
} case 'LINEORDER_INSERT':
elseif ($action == 'ORDER_VALIDATE') case 'LINEORDER_UPDATE':
{ case 'LINEORDER_DELETE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_BUILDDOC')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_CLASSIFY_BILLED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEORDER_INSERT')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEORDER_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEORDER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Supplier orders // Supplier orders
elseif ($action == 'ORDER_SUPPLIER_CREATE') case 'ORDER_SUPPLIER_CREATE':
{ case 'ORDER_SUPPLIER_CLONE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'ORDER_SUPPLIER_VALIDATE':
} case 'ORDER_SUPPLIER_DELETE':
elseif ($action == 'ORDER_SUPPLIER_CLONE') case 'ORDER_SUPPLIER_APPROVE':
{ case 'ORDER_SUPPLIER_REFUSE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'ORDER_SUPPLIER_CANCEL':
} case 'ORDER_SUPPLIER_SENTBYMAIL':
elseif ($action == 'ORDER_SUPPLIER_VALIDATE') case 'ORDER_SUPPLIER_BUILDDOC':
{ case 'LINEORDER_SUPPLIER_DISPATCH':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'LINEORDER_SUPPLIER_CREATE':
} case 'LINEORDER_SUPPLIER_UPDATE':
elseif ($action == 'ORDER_SUPPLIER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_APPROVE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_REFUSE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_CANCEL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'ORDER_SUPPLIER_BUILDDOC')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEORDER_SUPPLIER_DISPATCH')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEORDER_SUPPLIER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEORDER_SUPPLIER_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Proposals // Proposals
elseif ($action == 'PROPAL_CREATE') case 'PROPAL_CREATE':
{ case 'PROPAL_CLONE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'PROPAL_MODIFY':
} case 'PROPAL_VALIDATE':
elseif ($action == 'PROPAL_CLONE') case 'PROPAL_BUILDDOC':
{ case 'PROPAL_SENTBYMAIL':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'PROPAL_CLOSE_SIGNED':
} case 'PROPAL_CLOSE_REFUSED':
elseif ($action == 'PROPAL_MODIFY') case 'PROPAL_DELETE':
{ case 'LINEPROPAL_INSERT':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'LINEPROPAL_UPDATE':
} case 'LINEPROPAL_DELETE':
elseif ($action == 'PROPAL_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PROPAL_BUILDDOC')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PROPAL_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PROPAL_CLOSE_SIGNED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PROPAL_CLOSE_REFUSED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PROPAL_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEPROPAL_INSERT')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEPROPAL_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEPROPAL_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Contracts // Contracts
elseif ($action == 'CONTRACT_CREATE') case 'CONTRACT_CREATE':
{ case 'CONTRACT_ACTIVATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'CONTRACT_CANCEL':
} case 'CONTRACT_CLOSE':
elseif ($action == 'CONTRACT_ACTIVATE') case 'CONTRACT_DELETE':
{ case 'LINECONTRACT_CREATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'LINECONTRACT_UPDATE':
} case 'LINECONTRACT_DELETE':
elseif ($action == 'CONTRACT_CANCEL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'CONTRACT_CLOSE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'CONTRACT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINECONTRACT_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINECONTRACT_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINECONTRACT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Bills // Bills
elseif ($action == 'BILL_CREATE') case 'BILL_CREATE':
{ case 'BILL_CLONE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'BILL_MODIFY':
} case 'BILL_VALIDATE':
elseif ($action == 'BILL_CLONE') case 'BILL_UNVALIDATE':
{ case 'BILL_BUILDDOC':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'BILL_SENTBYMAIL':
} case 'BILL_CANCEL':
elseif ($action == 'BILL_MODIFY') case 'BILL_DELETE':
{ case 'BILL_PAYED':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'LINEBILL_INSERT':
} case 'LINEBILL_UPDATE':
elseif ($action == 'BILL_VALIDATE') case 'LINEBILL_DELETE':
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_UNVALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_BUILDDOC')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_CANCEL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_PAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_INSERT')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
//Supplier Bill //Supplier Bill
elseif ($action == 'BILL_SUPPLIER_CREATE') case 'BILL_SUPPLIER_CREATE':
{ case 'BILL_SUPPLIER_UPDATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'BILL_SUPPLIER_DELETE':
} case 'BILL_SUPPLIER_PAYED':
elseif ($action == 'BILL_SUPPLIER_UPDATE') case 'BILL_SUPPLIER_UNPAYED':
{ case 'BILL_SUPPLIER_VALIDATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'LINEBILL_SUPPLIER_CREATE':
} case 'LINEBILL_SUPPLIER_UPDATE':
elseif ($action == 'BILL_SUPPLIER_DELETE') case 'LINEBILL_SUPPLIER_DELETE':
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_PAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_UNPAYED')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_SUPPLIER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_SUPPLIER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_SUPPLIER_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEBILL_SUPPLIER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Payments // Payments
elseif ($action == 'PAYMENT_CUSTOMER_CREATE') case 'PAYMENT_CUSTOMER_CREATE':
{ case 'PAYMENT_SUPPLIER_CREATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'PAYMENT_ADD_TO_BANK':
} case 'PAYMENT_DELETE':
elseif ($action == 'PAYMENT_SUPPLIER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PAYMENT_ADD_TO_BANK')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PAYMENT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
//Donation //Donation
elseif ($action == 'DON_CREATE') case 'DON_CREATE':
{ case 'DON_UPDATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'DON_DELETE':
}
elseif ($action == 'DON_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'DON_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Interventions // Interventions
elseif ($action == 'FICHINTER_CREATE') case 'FICHINTER_CREATE':
{ case 'FICHINTER_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'FICHINTER_VALIDATE':
} case 'FICHINTER_DELETE':
elseif ($action == 'FICHINTER_MODIFY') case 'LINEFICHINTER_CREATE':
{ case 'LINEFICHINTER_UPDATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'LINEFICHINTER_DELETE':
}
elseif ($action == 'FICHINTER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'FICHINTER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEFICHINTER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEFICHINTER_UPDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'LINEFICHINTER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Members // Members
elseif ($action == 'MEMBER_CREATE') case 'MEMBER_CREATE':
{ case 'MEMBER_VALIDATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'MEMBER_SUBSCRIPTION':
} case 'MEMBER_MODIFY':
elseif ($action == 'MEMBER_VALIDATE') case 'MEMBER_NEW_PASSWORD':
{ case 'MEMBER_RESILIATE':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'MEMBER_DELETE':
}
elseif ($action == 'MEMBER_SUBSCRIPTION')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'MEMBER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'MEMBER_NEW_PASSWORD')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'MEMBER_RESILIATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'MEMBER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Categories // Categories
elseif ($action == 'CATEGORY_CREATE') case 'CATEGORY_CREATE':
{ case 'CATEGORY_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'CATEGORY_DELETE':
}
elseif ($action == 'CATEGORY_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'CATEGORY_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Projects // Projects
elseif ($action == 'PROJECT_CREATE') case 'PROJECT_CREATE':
{ case 'PROJECT_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'PROJECT_DELETE':
}
elseif ($action == 'PROJECT_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'PROJECT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Project tasks // Project tasks
elseif ($action == 'TASK_CREATE') case 'TASK_CREATE':
{ case 'TASK_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'TASK_DELETE':
}
elseif ($action == 'TASK_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'TASK_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Task time spent // Task time spent
elseif ($action == 'TASK_TIMESPENT_CREATE') case 'TASK_TIMESPENT_CREATE':
{ case 'TASK_TIMESPENT_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'TASK_TIMESPENT_DELETE':
}
elseif ($action == 'TASK_TIMESPENT_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'TASK_TIMESPENT_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
// Shipping // Shipping
elseif ($action == 'SHIPPING_CREATE') case 'SHIPPING_CREATE':
{ case 'SHIPPING_MODIFY':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); case 'SHIPPING_VALIDATE':
} case 'SHIPPING_SENTBYMAIL':
elseif ($action == 'SHIPPING_MODIFY') case 'SHIPPING_DELETE':
{ case 'SHIPPING_BUILDDOC':
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'SHIPPING_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'SHIPPING_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'SHIPPING_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'SHIPPING_BUILDDOC')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break;
} }
return 0; return 0;
} }
} }
?>

View File

@ -305,7 +305,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase
$localobject=new Categorie($this->savdb); $localobject=new Categorie($this->savdb);
$result=$localobject->fetch($id); $result=$localobject->fetch($id);
$result=$localobject->delete($id); $result=$localobject->delete($user);
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
$this->assertGreaterThan(0, $result); $this->assertGreaterThan(0, $result);