dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
31{
33 public $table_element = 'workstation_workstation_usergroup';
34
36 public $element = 'workstationusergroup';
37
41 public $fields = array(
42 'fk_workstation' => array('type' => 'integer', 'label' => 'Workstation', 'enabled' => 1, 'position' => 10, 'visible' => 1),
43 'fk_usergroup' => array('type' => 'integer', 'label' => 'UserGroup', 'enabled' => 1, 'position' => 20, 'visible' => 1),
44 );
45
49 public $fk_workstation;
50
54 public $fk_usergroup;
55
56
62 public function __construct($db)
63 {
64 global $langs;
65
66 $this->db = $db;
67
68 // Unset fields that are disabled
69 foreach ($this->fields as $key => $val) {
70 if (isset($val['enabled']) && empty($val['enabled'])) {
71 unset($this->fields[$key]);
72 }
73 }
74
75 // Translate some data of arrayofkeyval
76 if (is_object($langs)) {
77 foreach ($this->fields as $key => $val) {
78 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
79 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
80 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
81 }
82 }
83 }
84 }
85 }
86
93 public static function getAllGroupsOfWorkstation($fk_workstation)
94 {
95 global $db;
96
97 $obj = new self($db);
98 return parent::getAllItemsLinkedByObjectID($fk_workstation, 'fk_usergroup', 'fk_workstation', $obj->table_element);
99 }
100
107 public static function deleteAllGroupsOfWorkstation($fk_workstation)
108 {
109 global $db;
110
111 $obj = new self($db);
112 return parent::deleteAllItemsLinkedByObjectID($fk_workstation, 'fk_workstation', $obj->table_element);
113 }
114}
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.