dolibarr  7.0.0-beta
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  $this->db = $db;
86 
87  if (empty($this->name))
88  {
89  $this->name = preg_replace('/^Interface/i', '', get_class($this));
90  }
91  }
92 
98  public function getName()
99  {
100  return $this->name;
101  }
102 
108  public function getDesc()
109  {
110  return $this->description;
111  }
112 
118  public function getVersion()
119  {
120  global $langs;
121  $langs->load("admin");
122 
123  if ($this->version == self::VERSION_DEVELOPMENT) {
124  return $langs->trans("VersionDevelopment");
125  } elseif ($this->version == self::VERSION_EXPERIMENTAL) {
126  return $langs->trans("VersionExperimental");
127  } elseif ($this->version == self::VERSION_DOLIBARR) {
128  return DOL_VERSION;
129  } elseif ($this->version) {
130  return $this->version;
131  } else {
132  return $langs->trans("Unknown");
133  }
134  }
135 
147  abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf);
148 
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:39
Class to manage Dolibarr database access.
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
getName()
Returns the name of the trigger file.
getDesc()
Returns the description of trigger file.
__construct(DoliDB $db)
Constructor.