dolibarr  13.0.2
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 
21 abstract 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 
96  $this->db = $db;
97 
98  if (empty($this->name)) {
99  $this->name = preg_replace('/^Interface/i', '', get_class($this));
100  }
101  }
102 
108  public function getName()
109  {
110  return $this->name;
111  }
112 
118  public function getDesc()
119  {
120  return $this->description;
121  }
122 
128  public function getVersion()
129  {
130  global $langs;
131  $langs->load("admin");
132 
133  if ($this->version == self::VERSION_DEVELOPMENT) {
134  return $langs->trans("VersionDevelopment");
135  } elseif ($this->version == self::VERSION_EXPERIMENTAL) {
136  return $langs->trans("VersionExperimental");
137  } elseif ($this->version == self::VERSION_DOLIBARR) {
138  return DOL_VERSION;
139  } elseif ($this->version) {
140  return $this->version;
141  } else {
142  return $langs->trans("Unknown");
143  }
144  }
145 
157  public abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf);
158 }
Class to stock current configuration.
Definition: conf.class.php:33
getVersion()
Returns the version of the trigger file.
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage Dolibarr database access.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
$conf db
API class for accounts.
Definition: inc.php:54
runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
Function called when a Dolibarrr business event is done.
Class to manage translations.
Class that all the triggers must extend.
getName()
Returns the name of the trigger file.
getDesc()
Returns the description of trigger file.
__construct(DoliDB $db)
Constructor.