Revision 925171f8
[#1637] Propagation du nom du template
Evite que le nom du template Vigilo associé à la machine ne soit perdu
lorsqu'on modifie un objet rattaché à la machine (IPAddress,
NetworkName, SoftwareInstallation, etc.).
Change-Id: I6e4b7df2d926547bf19afc8de6e2469caf54867c
Refs: #1637
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2576
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
src/plugins/vigilo/vigilo_hooks.php | ||
---|---|---|
6 | 6 |
// concernant les équipements supportés. |
7 | 7 |
public function preItemUpdate($item) |
8 | 8 |
{ |
9 |
global $DB; |
|
10 |
|
|
11 |
$id = $item->getID(); |
|
12 |
$query = <<<SQL |
|
13 |
SELECT `template` |
|
14 |
FROM glpi_plugin_vigilo_template |
|
15 |
WHERE `id` = $id; |
|
16 |
SQL; |
|
17 |
|
|
18 |
$item->fields['vigilo_template'] = 0; |
|
19 |
$result = $DB->query($query); |
|
20 |
if ($result) { |
|
21 |
$tpl = $DB->result($result, 0, "template"); |
|
22 |
$templates = PluginVigiloTemplate::getTemplates(); |
|
23 |
$index = array_search($tpl, $templates, true); |
|
24 |
if (false !== $index) { |
|
25 |
$item->fields['vigilo_template'] = $index; |
|
26 |
} |
|
27 |
} |
|
9 |
$index = PluginVigiloTemplate::getTemplateIndexForItem($item); |
|
10 |
$item->fields['vigilo_template'] = (int) $index; |
|
28 | 11 |
} |
29 | 12 |
|
30 | 13 |
public function itemAddOrUpdate($item) |
... | ... | |
43 | 26 |
ON DUPLICATE KEY UPDATE `template` = '$template'; |
44 | 27 |
SQL; |
45 | 28 |
$DB->query($query); |
46 |
$item->fields['vigilo_template'] = $templates[$tplId]; |
|
47 |
} else { |
|
48 |
$item->fields['vigilo_template'] = null; |
|
49 | 29 |
} |
50 | 30 |
|
51 | 31 |
// Si la mise à jour modifie le technicien associé à la machine, |
Also available in: Unified diff