|
31 | 31 | * --------------------------------------------------------------------- |
32 | 32 | */ |
33 | 33 |
|
34 | | - |
35 | 34 | Html::header( |
36 | 35 | __('GLPI Inventory', 'glpiinventory'), |
37 | 36 | '', |
|
44 | 43 |
|
45 | 44 | $agentmodule = new PluginGlpiinventoryAgentmodule(); |
46 | 45 |
|
47 | | -if (isset($_POST["agent_add"])) { |
48 | | - $agentmodule->getFromDB($_POST['id']); |
49 | | - $a_agentList = importArrayFromDB($agentmodule->fields['exceptions']); |
50 | | - $a_agentList[] = $_POST['agent_to_add'][0]; |
51 | | - $input = []; |
52 | | - $input['exceptions'] = exportArrayToDB($a_agentList); |
53 | | - $input['id'] = $_POST['id']; |
54 | | - $agentmodule->update($input); |
55 | | - Html::back(); |
56 | | -} elseif (isset($_POST["agent_delete"])) { |
57 | | - $agentmodule->getFromDB($_POST['id']); |
58 | | - $a_agentList = importArrayFromDB($agentmodule->fields['exceptions']); |
59 | | - foreach ($a_agentList as $key => $value) { |
60 | | - if ($value == $_POST['agent_to_delete'][0]) { |
61 | | - unset($a_agentList[$key]); |
62 | | - } |
63 | | - } |
64 | | - $input = []; |
65 | | - $input['exceptions'] = exportArrayToDB($a_agentList); |
66 | | - $input['id'] = $_POST['id']; |
67 | | - $agentmodule->update($input); |
| 46 | +if (isset($_POST["update"])) { |
| 47 | + $agentmodule->updateModules($_POST); |
68 | 48 | Html::back(); |
69 | | -} elseif (isset($_POST["updateexceptions"])) { |
70 | | - $a_modules = $agentmodule->find(); |
71 | | - foreach ($a_modules as $data) { |
72 | | - $a_agentList = importArrayFromDB($data['exceptions']); |
73 | | - $agentModule = 0; |
74 | | - if ( |
75 | | - isset($_POST['activation-' . $data['modulename']]) |
76 | | - && $_POST['activation-' . $data['modulename']] != 0 |
77 | | - ) { |
78 | | - $agentModule = 1; |
79 | | - } |
80 | | - $agentModuleBase = 0; |
81 | | - if (in_array($_POST['id'], $a_agentList)) { |
82 | | - $agentModuleBase = 1; |
83 | | - } |
84 | | - if ($data['is_active'] == 0) { |
85 | | - if ($agentModule == 1 && $agentModuleBase == 0) { |
86 | | - $a_agentList[] = $_POST['id']; |
87 | | - } elseif ($agentModule == 0 && $agentModuleBase == 1) { |
88 | | - foreach ($a_agentList as $key => $value) { |
89 | | - if ($value == $_POST['id']) { |
90 | | - unset($a_agentList[$key]); |
91 | | - } |
92 | | - } |
93 | | - } |
94 | | - } elseif ($data['is_active'] == 1) { |
95 | | - if ($agentModule == 1 && $agentModuleBase == 1) { |
96 | | - foreach ($a_agentList as $key => $value) { |
97 | | - if ($value == $_POST['id']) { |
98 | | - unset($a_agentList[$key]); |
99 | | - } |
100 | | - } |
101 | | - } elseif ($agentModule == 0 && $agentModuleBase == 0) { |
102 | | - $a_agentList[] = $_POST['id']; |
103 | | - } |
104 | | - } |
105 | | - $data['exceptions'] = exportArrayToDB($a_agentList); |
106 | | - $agentmodule->update($data); |
107 | | - } |
108 | | - |
109 | | - Html::back(); |
110 | | -} elseif (isset($_POST["update"])) { |
111 | | - $agentmodule->getFromDB($_POST['id']); |
112 | | - $input = []; |
113 | | - if ( |
114 | | - isset($_POST['activation']) |
115 | | - && $_POST['activation'] |
116 | | - ) { |
117 | | - $input['is_active'] = 1; |
118 | | - } else { |
119 | | - $input['is_active'] = 0; |
120 | | - } |
121 | | - if ($agentmodule->fields['is_active'] != $input['is_active']) { |
122 | | - $a_agentList = []; |
123 | | - $input['exceptions'] = exportArrayToDB($a_agentList); |
124 | | - } |
125 | | - $input['id'] = $_POST['id']; |
126 | | - |
127 | | - $agentmodule->update($input); |
| 49 | +} elseif (isset($_POST["update_exceptions"])) { |
| 50 | + $agentmodule->updateForAgent($_POST); |
128 | 51 | Html::back(); |
129 | 52 | } |
130 | 53 |
|
131 | | -Html::footer(); |
| 54 | +return; |
0 commit comments