Revision e1c378c0
Ajout de groupes pour les techniciens
Change-Id: If870608da01779b6b922ca57dae7aa36a5566138
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2392
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
src/plugins/vigilo/inc/abstractmonitoreditem.class.php | ||
---|---|---|
49 | 49 |
$entity = new Entity(); |
50 | 50 |
$entity->getFromDB($this->item->fields["entities_id"]); |
51 | 51 |
|
52 |
// Association de l'objet à son emplacement et à son entité. |
|
52 | 53 |
$candidates = array( |
53 | 54 |
'Locations' => $location, |
54 | 55 |
'Entities' => $entity, |
55 | 56 |
); |
56 |
|
|
57 | 57 |
foreach ($candidates as $type => $candidate) { |
58 |
if ('N/A' === $candidate->getName()) {
|
|
58 |
if (NOT_AVAILABLE === $candidate->getName()) {
|
|
59 | 59 |
continue; |
60 | 60 |
} |
61 | 61 |
|
... | ... | |
67 | 67 |
$this->children[] = new VigiloGroup($groupName); |
68 | 68 |
} |
69 | 69 |
|
70 |
// Association de l'objet à son équipementier. |
|
70 | 71 |
$manufacturer = new Manufacturer(); |
71 | 72 |
$manufacturer->getFromDB($this->item->fields["manufacturers_id"]); |
72 |
if ('N/A' !== $manufacturer->getName()) {
|
|
73 |
if (NOT_AVAILABLE !== $manufacturer->getName()) {
|
|
73 | 74 |
$this->children[] = new VigiloGroup("/Manufacturers/" . $manufacturer->getName()); |
74 | 75 |
} |
76 |
|
|
77 |
// Association de l'objet à son technicien. |
|
78 |
$technician = new User(); |
|
79 |
$technician->getFromDB($this->item->fields["users_id_tech"]); |
|
80 |
if (NOT_AVAILABLE !== $technician->getName()) { |
|
81 |
$this->children[] = new VigiloGroup("/Technicians/" . $technician->getName()); |
|
82 |
} |
|
75 | 83 |
} |
76 | 84 |
|
77 | 85 |
protected function selectAddress() |
src/plugins/vigilo/inc/groups.class.php | ||
---|---|---|
10 | 10 |
'Entities' => new VigiloGroups('Entities'), |
11 | 11 |
'Manufacturers' => new VigiloGroups('Manufacturers'), |
12 | 12 |
'Locations' => new VigiloGroups('Locations'), |
13 |
'Technicians' => new VigiloGroups('Technicians'), |
|
13 | 14 |
); |
14 | 15 |
|
15 | 16 |
$this->getManufacturers(); |
16 | 17 |
$this->getEntities(); |
17 | 18 |
$this->getLocations(); |
19 |
$this->getTechnicians(); |
|
18 | 20 |
} |
19 | 21 |
|
20 | 22 |
public function getName() |
... | ... | |
63 | 65 |
} |
64 | 66 |
} |
65 | 67 |
|
68 |
protected function getTechnicians() |
|
69 |
{ |
|
70 |
global $DB; |
|
71 |
|
|
72 |
// Ce serait plus propre d'utiliser la surcouche de GLPI |
|
73 |
// pour récupérer l'information, mais cela serait aussi |
|
74 |
// beaucoup plus coûteux (plus d'appels à la BDD, etc.). |
|
75 |
|
|
76 |
$query = <<<SQL |
|
77 |
SELECT DISTINCT u.name |
|
78 |
FROM glpi_users u |
|
79 |
JOIN ( |
|
80 |
SELECT users_id_tech |
|
81 |
FROM glpi_computers |
|
82 |
UNION ALL |
|
83 |
SELECT users_id_tech |
|
84 |
FROM glpi_networkequipments |
|
85 |
UNION ALL |
|
86 |
SELECT users_id_tech |
|
87 |
FROM glpi_printers |
|
88 |
) as a1 on a1.users_id_tech = u.id; |
|
89 |
SQL; |
|
90 |
foreach ($DB->request($query) as $row) { |
|
91 |
$this->groups['Technicians'][] = $row['name']; |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
66 | 95 |
public function __toString() |
67 | 96 |
{ |
68 | 97 |
$out = "<groups>\n"; |
src/plugins/vigilo/vigilo_hooks.php | ||
---|---|---|
48 | 48 |
$item->fields['vigilo_template'] = null; |
49 | 49 |
} |
50 | 50 |
|
51 |
// Si la mise à jour modifie le technicien associé à la machine, |
|
52 |
// il peut-être nécessaire de mettre à jour les groupes de Vigilo. |
|
53 |
if (!empty($item->fields['users_id_tech'])) { |
|
54 |
$this->updateGroups(null); |
|
55 |
} |
|
56 |
|
|
51 | 57 |
$this->update($item); |
52 | 58 |
} |
53 | 59 |
|
... | ... | |
59 | 65 |
$query = "DELETE FROM `glpi_plugin_vigilo_template` WHERE `id` = $id;"; |
60 | 66 |
$DB->query($query); |
61 | 67 |
$this->unmonitor($item->getField('name')); |
68 |
|
|
69 |
// Si la mise à jour modifie le technicien associé à la machine, |
|
70 |
// il peut-être nécessaire de mettre à jour les groupes de Vigilo. |
|
71 |
if (!empty($item->fields['users_id_tech'])) { |
|
72 |
$this->updateGroups(null); |
|
73 |
} |
|
62 | 74 |
} |
63 | 75 |
|
64 | 76 |
// Méthodes outils / annexes |
Also available in: Unified diff