Skip to content

Commit 371b74b

Browse files
trasherstonebuzz
andauthored
Rework agents modules configuration page (#840)
* Rework agents modules configuration page Make more simple, Switch to Twig * Nolabel * CS * Update changelog * Fix agent tab part; add tests * CS * Fix test * minor UI fix * minor UI fix: force small width for two first column --------- Co-authored-by: Stanislas Kita <[email protected]>
1 parent 18cfb29 commit 371b74b

File tree

6 files changed

+363
-259
lines changed

6 files changed

+363
-259
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [1.6.4] - UNRELEASED
99

10+
- Rework the whole agents module configuration page
1011
- Fix URL for ressource (ajax/ front/ pics/ etc .. )
1112
- Fix several wrong URLs (still using PHP_SELF)
1213

front/agentmodule.form.php

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* ---------------------------------------------------------------------
3232
*/
3333

34-
3534
Html::header(
3635
__('GLPI Inventory', 'glpiinventory'),
3736
'',
@@ -44,88 +43,12 @@
4443

4544
$agentmodule = new PluginGlpiinventoryAgentmodule();
4645

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);
6848
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);
12851
Html::back();
12952
}
13053

131-
Html::footer();
54+
return;

0 commit comments

Comments
 (0)