dolibarr  17.0.4
workstationusergroup.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
29 {
31  public $table_element = 'workstation_workstation_usergroup';
32 
34  public $element = 'workstationusergroup';
35 
39  public $fields = array(
40  'fk_workstation' => array('type' => 'integer'),
41  'fk_usergroup' => array('type' => 'integer')
42  );
43 
47  public $fk_workstation;
48 
52  public $fk_usergroup;
53 
54 
60  public function __construct($db)
61  {
62  global $langs;
63 
64  $this->db = $db;
65 
66  // Unset fields that are disabled
67  foreach ($this->fields as $key => $val) {
68  if (isset($val['enabled']) && empty($val['enabled'])) {
69  unset($this->fields[$key]);
70  }
71  }
72 
73  // Translate some data of arrayofkeyval
74  if (is_object($langs)) {
75  foreach ($this->fields as $key => $val) {
76  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
77  foreach ($val['arrayofkeyval'] as $key2 => $val2) {
78  $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
79  }
80  }
81  }
82  }
83  }
84 
91  public static function getAllGroupsOfWorkstation($fk_workstation)
92  {
93  global $db;
94 
95  $obj = new self($db);
96  return parent::getAllItemsLinkedByObjectID($fk_workstation, 'fk_usergroup', 'fk_workstation', $obj->table_element);
97  }
98 
105  public static function deleteAllGroupsOfWorkstation($fk_workstation)
106  {
107  global $db;
108 
109  $obj = new self($db);
110  return parent::deleteAllItemsLinkedByObjectID($fk_workstation, 'fk_workstation', $obj->table_element);
111  }
112 }
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to link User groups and Workstations.
static deleteAllGroupsOfWorkstation($fk_workstation)
Function used to remove all usergroups linked to a workstation.
static getAllGroupsOfWorkstation($fk_workstation)
Function used to get an array with all usergroups linked to a workstation.
__construct($db)
WorkstationUserGroup constructor.
$conf db
API class for accounts.
Definition: inc.php:41