Skip to content

Commit 3829d0e

Browse files
committed
feat(sccm): Works with multiple configurations
1 parent 5044f22 commit 3829d0e

File tree

8 files changed

+497
-244
lines changed

8 files changed

+497
-244
lines changed

front/config.form.php

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
include ('../../../inc/includes.php');
3333
require_once('../inc/config.class.php');
3434

35+
global $CFG_GLPI;
3536

3637
Session::checkRight("config", UPDATE);
3738

3839
$PluginSccmConfig = new PluginSccmConfig();
40+
global $DB;
3941

4042
if (isset($_POST["update"])) {
4143
if (array_key_exists('sccmdb_password', $_POST)) {
@@ -45,18 +47,38 @@
4547

4648
$PluginSccmConfig->update($_POST);
4749

48-
$sccmDB = new PluginSccmSccmdb();
49-
if ($sccmDB->connect()) {
50-
Session::addMessageAfterRedirect("Connexion réussie !.", false, INFO, false);
50+
Toolbox::logInFile('sccm', "Updating configuration ".$_POST['sccm_config_name']." ".$_POST['id']." ...\n", true);
51+
52+
$sccmDB = new PluginSccmSccmdb();
53+
$sccmDB->testConfiguration($_POST['id']);
54+
55+
Html::redirect(PluginSccmConfig::searchUrl());
56+
} else if (isset($_POST["add"])) {
57+
Toolbox::logInFile('sccm', "Inserting configuration ".$_POST['sccm_config_name']." ...\n", true);
58+
$insertedId = $PluginSccmConfig->add($_POST);
59+
60+
if ($insertedId) {
61+
$sccmDB = new PluginSccmSccmdb();
62+
$sccmDB->testConfiguration($insertedId);
5163
} else {
52-
Session::addMessageAfterRedirect("Connexion incorrecte.", false, ERROR, false);
64+
Toolbox::logInFile('sccm', "Error inserting configuration ".$_POST['sccm_config_name']." ".$DB->error()." ...\n", true);
65+
Session::addMessageAfterRedirect("Error inserting configuration.", false, ERROR, false);
5366
}
5467

55-
56-
Html::back();
68+
Html::redirect(PluginSccmConfig::searchUrl());
69+
} else if (isset($_POST["purge"])) {
70+
$PluginSccmConfig->delete($_POST, 1);
71+
Html::redirect(PluginSccmConfig::searchUrl());
5772
}
5873

59-
Html::header(__("Setup - SCCM", "sccm"), $_SERVER["PHP_SELF"],
60-
"plugins", "sccm", "configuration");
61-
$PluginSccmConfig->showConfigForm($PluginSccmConfig);
74+
Html::header(
75+
PluginSccmConfig::getTypeName(),
76+
$_SERVER["PHP_SELF"],
77+
"config",
78+
PluginSccmMenu::class,
79+
"configuration"
80+
);
81+
82+
$PluginSccmConfig->display($_GET);
83+
6284
Html::footer();

front/config.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* -------------------------------------------------------------------------
5+
* SCCM plugin for GLPI
6+
* -------------------------------------------------------------------------
7+
*
8+
* LICENSE
9+
*
10+
* This file is part of SCCM.
11+
*
12+
* SCCM is free software; you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation; either version 3 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* SCCM is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU General Public License
23+
* along with SCCM. If not, see <http://www.gnu.org/licenses/>.
24+
* -------------------------------------------------------------------------
25+
* @author François Legastelois
26+
* @copyright Copyright (C) 2014-2023 by SCCM plugin team.
27+
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
28+
* @link https://github.com/pluginsGLPI/sccm
29+
* -------------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
34+
Html::header(
35+
PluginSccmConfig::getTypeName(),
36+
$_SERVER["PHP_SELF"],
37+
"config",
38+
PluginSccmMenu::class,
39+
"configuration"
40+
);
41+
42+
Search::show('PluginSccmConfig');
43+
44+
Html::footer();

0 commit comments

Comments
 (0)