diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php index 98fcf7e5ad54a2685bd60b40d9e100b9cdd0edfb..62a7564e7fb6e06c2d99a7caa175f6eb4c9d0919 100644 --- a/htdocs/actioncomm.class.php +++ b/htdocs/actioncomm.class.php @@ -35,47 +35,46 @@ class ActionComm { - var $id; - var $db; - - var $type_id; - var $type_code; - var $type; - var $label; - var $date; - var $priority; - var $user; - var $author; - var $societe; - var $contact; - var $note; - var $percent; - var $error; - - /** - * \brief Constructeur - * \param db Handler d'acc�s base de donn�e - */ - function ActionComm($db) + var $id; + var $db; + + var $type_id; + var $type_code; + var $type; + var $label; + var $date; + var $priority; + var $user; + var $author; + var $societe; + var $contact; + var $note; + var $percent; + var $error; + + /** + * \brief Constructeur + * \param db Handler d'acc�s base de donn�e + */ + function ActionComm($db) { - $this->db = $db; - $this->societe = new Societe($db); - $this->author = new User($db); - if (class_exists("Contact")) - { - $this->contact = new Contact($db); - } + $this->db = $db; + $this->societe = new Societe($db); + $this->author = new User($db); + if (class_exists("Contact")) + { + $this->contact = new Contact($db); + } } - /** - * \brief Ajout d'une action en base (et eventuellement dans webcalendar) - * \param author auteur de la creation de l'action - * \param webcal ressource webcalendar: 0=on oublie webcal, 1=on ajoute une entr�e g�n�rique dans webcal, objet=ajout de l'objet dans webcal - * \return int id de l'action cr��e, < 0 si erreur - */ - function add($author, $webcal=0) + /** + * \brief Ajout d'une action en base + * \param author auteur de la creation de l'action + * \return int id de l'action cr��e, < 0 si erreur + */ + function add($author) { - global $conf; + global $langs,$conf; dolibarr_syslog("ActionComm::add"); @@ -98,30 +97,11 @@ class ActionComm { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm"); - if ($conf->webcal->enabled) { - - // Appel a webcal - dolibarr_syslog("ActionComm::ajout entree dans webcal"); - - // Si webcal demand� et non d�fini en tant qu'objet, on le construit - if (! is_object($webcal) && $webcal == 1) - { - $webcal=new ActionComm($this->db); - $webcal->date=$this->date; - $webcal->duree=0; - $webcal->texte=$this->societe; - $webcal->desc="Action ".$this->type_code."\n".$this->note; - } - - // Ajoute entr�e dans webcal - if (is_object($webcal)) - { - $result=$webcal->add($author,$webcal->date,$webcal->texte,$webcal->desc); - if ($result < 0) { - $this->error="Echec insertion dans webcal: ".$webcal->error; - } - } - } + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); + $interface=new Interfaces($this->db); + $interface->run_triggers('ACTION_CREATE',$this,$author,$langs,$conf); + // Fin appel triggers return $this->id; } diff --git a/htdocs/includes/triggers/interface_demo.class.php b/htdocs/includes/triggers/interface_demo.class.php index d624efd3ed66ada1371e8ed9d2b460c2fca375b6..c59078da664cc2181ac5ef65ff62a24207058122 100644 --- a/htdocs/includes/triggers/interface_demo.class.php +++ b/htdocs/includes/triggers/interface_demo.class.php @@ -32,7 +32,7 @@ /** - \class interface_demo + \class InterfaceDemo \brief Classe des fonctions triggers des actions personalis�es du workflow */ @@ -42,7 +42,7 @@ class InterfaceDemo /** * \brief Constructeur. - * \param DB handler d'acc�s base + * \param DB Handler d'acc�s base */ function InterfaceDemo($DB) { @@ -88,15 +88,16 @@ class InterfaceDemo } /** - * \brief Fonction appel�e lors du d�clenchement d'un �v�nement Dolibarr. - * D'autres fonctions run_trigger peuvent etre pr�sentes dans includes/triggers - * \param action Code de l'evenement - * \param object Objet concern� - * \param user Objet user - * \param lang Objet lang - * \param conf Objet conf + * \brief Fonction appel�e lors du d�clenchement d'un �v�nement Dolibarr. + * D'autres fonctions run_trigger peuvent etre pr�sentes dans includes/triggers + * \param action Code de l'evenement + * \param object Objet concern� + * \param user Objet user + * \param lang Objet lang + * \param conf Objet conf + * \return int <0 si ko, 0 si aucune action faite, >0 si ok */ - function run_trigger($action,$object,$user,$lang,$conf) + function run_trigger($action,$object,$user,$langs,$conf) { // Mettre ici le code � ex�cuter en r�action de l'action // Les donn�es de l'action sont stock�es dans $object @@ -188,7 +189,9 @@ class InterfaceDemo else { dolibarr_syslog("Trigger '".$this->name."' for action '$action' was ran but no handler found for this action."); + return -1; } + return 0; } } diff --git a/htdocs/includes/triggers/interface_webcal.class.php b/htdocs/includes/triggers/interface_webcal.class.php index 6386a7e9ab0fccb7be2c1a6658d0f49753abf0b3..f933b72f55598d1f11233700f34f366b26896513 100644 --- a/htdocs/includes/triggers/interface_webcal.class.php +++ b/htdocs/includes/triggers/interface_webcal.class.php @@ -35,7 +35,7 @@ include_once(DOL_DOCUMENT_ROOT.'/lib/webcal.class.php'); /** \class InterfaceWebCal - \brief Classe des fonctions triggers des actions personalis�es du workflow + \brief Classe des fonctions triggers des actions webcalendar */ class InterfaceWebCal @@ -46,7 +46,7 @@ class InterfaceWebCal /** * \brief Constructeur. - * \param DB handler d'acc�s base + * \param DB Handler d'acc�s base */ function InterfaceWebCal($DB) { @@ -99,7 +99,7 @@ class InterfaceWebCal * \param user Objet user * \param lang Objet lang * \param conf Objet conf - * \return int <0 si ko, >0 si ok + * \return int <0 si ko, 0 si aucune action faite, >0 si ok */ function run_trigger($action,$object,$user,$langs,$conf) { @@ -160,6 +160,7 @@ class InterfaceWebCal } } + return 0; } }