Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

### Added

- Handle multiple SCCM configuration

## [2.5.1] - 2025-10-07

Compatible with GLPI 11.0.x
Expand Down
49 changes: 38 additions & 11 deletions front/config.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,52 @@
* -------------------------------------------------------------------------
*/

include(__DIR__ . '/../../../inc/includes.php');
require_once(__DIR__ . '/../inc/config.class.php');


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

Session::checkRight(PluginSccmConfig::$rightname, UPDATE);
$config = new PluginSccmConfig();

if (isset($_POST["update"])) {
if (isset($_POST['add'])) {
$config->check(-1, CREATE, $_POST);
if (($newID = $config->add($_POST)) && $_SESSION['glpibackcreated']) {
Html::redirect($config->getLinkURL());
}

Html::back();
} elseif (isset($_POST['purge'])) {
$config->check($_POST['id'], PURGE);
$config->delete($_POST, true);
$config->redirectToList();
} elseif (isset($_POST['update'])) {
$config->check($_POST['id'], UPDATE);
$config->update($_POST);

$sccm_db = new PluginSccmSccmdb();
if ($sccm_db->connect()) {
if ($sccm_db->connect((int) $_POST['id'])) {
Session::addMessageAfterRedirect(__s("Login successful", "sccm"), false, INFO, false);
} else {
Session::addMessageAfterRedirect(__s("Incorrect login", "sccm"), false, ERROR, false);
}

Html::back();
}
} elseif (isset($_POST['test_connection'])) {
$config->check($_POST['id'], READ);
$sccm_db = new PluginSccmSccmdb();
if ($sccm_db->connect((int) $_POST['id'])) {
$sccm_db->disconnect();
Session::addMessageAfterRedirect(__s('Connection successful!', 'sccm'), false, INFO);
} else {
Session::addMessageAfterRedirect(__s('Connection failed. Check your settings.', 'sccm'), false, ERROR);
}

$menus = ['config', PluginSccmMenu::class];
PluginSccmConfig::displayFullPageForItem($_GET['id'], $menus, $_GET);
Html::back();
} else {
Html::header(
PluginSccmConfig::getTypeName(Session::getPluralNumber()),
'',
'config',
'PluginSccmMenu',
);

$config->display(['id' => (int) ($_GET['id'] ?? -1)]);

Html::footer();
}
48 changes: 48 additions & 0 deletions front/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* -------------------------------------------------------------------------
* SCCM plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of SCCM.
*
* SCCM is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SCCM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SCCM. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @author François Legastelois
* @author Teclib
* @copyright Copyright (C) 2014-2026 by SCCM plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @license GPLv3+ https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/sccm
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\AccessDeniedHttpException;

Session::checkRight(PluginSccmConfig::$rightname, UPDATE);
Session::checkRight(PluginSccmConfig::$rightname, READ);

Html::header(
PluginSccmConfig::getTypeName(Session::getPluralNumber()),
'',
'config',
'PluginSccmMenu',
);

Search::show(PluginSccmConfig::class);

Html::footer();
13 changes: 13 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
use function Safe\rmdir;
use function Safe\scandir;
use function Safe\unlink;
use function Safe\glob;
use function Safe\rename;

function plugin_sccm_install()
{
Expand All @@ -48,6 +50,7 @@ function plugin_sccm_install()
mkdir(GLPI_PLUGIN_DOC_DIR . '/sccm/xml');
}


$migration = new Migration(PLUGIN_SCCM_VERSION);

require __DIR__ . '/inc/config.class.php';
Expand All @@ -57,6 +60,16 @@ function plugin_sccm_install()

$migration->executeMigration();

// Migrate existing flat XML files to per-config subdirectory (config id=1)
$xml_root = GLPI_PLUGIN_DOC_DIR . '/sccm/xml/';
if (!is_dir($xml_root . '1')) {
mkdir($xml_root . '1', 0755, true);
}

foreach (glob($xml_root . '*.ocs') as $file) {
rename($file, $xml_root . '1/' . basename((string) $file));
}

return true;
}

Expand Down
Loading
Loading