dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
16  */
17 
21 abstract class DolibarrTriggers
22 {
23 
28  protected $db;
29 
34  public $name = '';
35 
40  public $description = '';
41 
46  public $version = self::VERSION_DEVELOPMENT;
47 
52  public $picto = 'technic';
53 
58  public $family = '';
59 
66  public $error = '';
67 
72  public $errors = array();
73 
74  const VERSION_DEVELOPMENT = 'development';
75  const VERSION_EXPERIMENTAL = 'experimental';
76  const VERSION_DOLIBARR = 'dolibarr';
77 
83  public function __construct(DoliDB $db)
84  {
85 
86  $this->db = $db;
87 
88  if (empty($this->name))
89  {
90  $this->name = preg_replace('/^Interface/i', '', get_class($this));
91  }
92  }
93 
99  public function getName()
100  {
101  return $this->name;
102  }
103 
109  public function getDesc()
110  {
111  return $this->description;
112  }
113 
119  public function getVersion()
120  {
121  global $langs;
122  $langs->load("admin");
123 
124  if ($this->version == self::VERSION_DEVELOPMENT) {
125  return $langs->trans("VersionDevelopment");
126  } elseif ($this->version == self::VERSION_EXPERIMENTAL) {
127  return $langs->trans("VersionExperimental");
128  } elseif ($this->version == self::VERSION_DOLIBARR) {
129  return DOL_VERSION;
130  } elseif ($this->version) {
131  return $this->version;
132  } else {
133  return $langs->trans("Unknown");
134  }
135  }
136 
148  abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf);
149 }
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:41
Class to manage Dolibarr database access.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
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.