dolibarr 19.0.4
dolibarrtriggers.class.php
1<?php
2/* Copyright (C) 2014 Marcos GarcĂ­a <marcosgdf@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
21abstract class DolibarrTriggers
22{
27 protected $db;
28
33 public $name = '';
34
39 public $description = '';
40
45 public $version = self::VERSION_DEVELOPMENT;
46
51 public $picto = 'technic';
52
57 public $family = '';
58
65 public $error = '';
66
71 public $errors = array();
72
76 const VERSION_DEVELOPMENT = 'development';
77
81 const VERSION_EXPERIMENTAL = 'experimental';
82
86 const VERSION_DOLIBARR = 'dolibarr';
87
93 public function __construct(DoliDB $db)
94 {
95 $this->db = $db;
96
97 if (empty($this->name)) {
98 $this->name = preg_replace('/^Interface/i', '', get_class($this));
99 }
100 }
101
107 public function getName()
108 {
109 return $this->name;
110 }
111
117 public function getDesc()
118 {
119 return $this->description;
120 }
121
127 public function getVersion()
128 {
129 global $langs;
130 $langs->load("admin");
131
132 if ($this->version == self::VERSION_DEVELOPMENT) {
133 return $langs->trans("VersionDevelopment");
134 } elseif ($this->version == self::VERSION_EXPERIMENTAL) {
135 return $langs->trans("VersionExperimental");
136 } elseif ($this->version == self::VERSION_DOLIBARR) {
137 return DOL_VERSION;
138 } elseif ($this->version) {
139 return $this->version;
140 } else {
141 return $langs->trans("Unknown");
142 }
143 }
144
151 public function setErrorsFromObject($object)
152 {
153 if (!empty($object->error)) {
154 $this->errors = array_merge($this->errors, array($object->error));
155 }
156 if (!empty($object->errors)) {
157 $this->errors = array_merge($this->errors, $object->errors);
158 }
159 }
160
172 abstract public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf);
173}
Class to stock current configuration.
Class to manage Dolibarr database access.
Class that all the triggers must extend.
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarrr business event is done.
getName()
Returns the name of the trigger file.
getDesc()
Returns the description of trigger file.
__construct(DoliDB $db)
Constructor.
setErrorsFromObject($object)
setErrorsFromObject
getVersion()
Returns the version of the trigger file.
Class to manage translations.
Class to manage Dolibarr users.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124