diff --git a/front/config.form.php b/front/config.form.php index 84cc52a..00056ec 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -32,21 +32,25 @@ include(__DIR__ . '/../../../inc/includes.php'); require_once(__DIR__ . '/../inc/config.class.php'); - Session::checkRight("config", UPDATE); $config = new PluginSccmConfig(); if (isset($_POST["update"])) { - $config->update($_POST); - $sccm_db = new PluginSccmSccmdb(); - if ($sccm_db->connect()) { - Session::addMessageAfterRedirect("Connexion réussie !.", false, INFO, false); - } else { - Session::addMessageAfterRedirect("Connexion incorrecte.", false, ERROR, false); - } - - Html::back(); + $config->update($_POST); + $sccmDB = new PluginSccmSccmdb(); + $sccmDB->testConfiguration($_POST['id']); + Html::back(); +} else if (isset($_POST["add"])) { + if ($config->add($_POST)) { + if ($_SESSION['glpibackcreated']) { + Html::redirect($track->getLinkURL()); + } + } + Html::back(); +} else if (isset($_POST["purge"])) { + $config->delete($_POST, 1); + $config->redirectToList(); } $menus = ['config', PluginSccmMenu::class]; diff --git a/front/config.php b/front/config.php new file mode 100644 index 0000000..6d720c8 --- /dev/null +++ b/front/config.php @@ -0,0 +1,36 @@ +. + * ------------------------------------------------------------------------- + * @author François Legastelois + * @copyright Copyright (C) 2014-2023 by SCCM plugin team. + * @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html + * @link https://github.com/pluginsGLPI/sccm + * ------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +Html::header(PluginSccmConfig::getTypeName(), $_SERVER["PHP_SELF"], "config", PluginSccmMenu::class, "configuration"); +Search::show('PluginSccmConfig'); +Html::footer(); diff --git a/inc/config.class.php b/inc/config.class.php index b4617ab..6c45508 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -63,6 +63,7 @@ class PluginSccmConfig extends CommonDBTM { private static $_instance; + public $dohistory = true; public static function canCreate(): bool { @@ -81,39 +82,135 @@ public static function canView(): bool public static function getTypeName($nb = 0) { - return __s("Setup - SCCM", "sccm"); + return __s("SCCM", "sccm"); + } + + public static function canPurge(): bool { + return Session::haveRight('config', UPDATE); } public function getName($options = []) { - return __s("Interface - SCCM", "sccm"); + return __("Configuration", "sccm"); } public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); - if (!self::$_instance->getFromDB(1)) { - self::$_instance->getEmpty(); - } } - return self::$_instance; } - public function prepareInputForUpdate($input) + public function rawSearchOptions() { - if (isset($input["sccmdb_password"]) && !empty($input["sccmdb_password"])) { + $tab = []; + $tab[] = [ + 'id' => 'common', + 'name' => self::getTypeName(2) + ]; + + $tab[] = [ + 'id' => '1', + 'table' => $this->getTable(), + 'field' => 'sccm_config_name', + 'name' => __('Config name'), + 'massiveaction' => false, + 'datatype' => 'itemlink' + ]; + + $tab[] = [ + 'id' => '2', + 'table' => $this->getTable(), + 'field' => 'active_sync', + 'name' => __('Enabled'), + 'massiveaction' => false, + 'datatype' => 'bool' + ]; + $tab[] = [ + 'id' => '3', + 'table' => $this->getTable(), + 'field' => 'sccm_collection_name', + 'name' => __('Collection'), + 'massiveaction' => false, + 'datatype' => 'string' + ]; + $tab[] = [ + 'id' => '4', + 'table' => $this->getTable(), + 'field' => 'sccmdb_host', + 'name' => __('Db Host'), + 'massiveaction' => false, + 'datatype' => 'string' + ]; + $tab[] = [ + 'id' => '5', + 'table' => $this->getTable(), + 'field' => 'sccmdb_dbname', + 'name' => __('DB Name'), + 'massiveaction' => false, + 'datatype' => 'string' + ]; + $tab[] = [ + 'id' => '6', + 'table' => $this->getTable(), + 'field' => 'sccmdb_user', + 'name' => __('DB User'), + 'massiveaction' => false, + 'datatype' => 'string' + ]; + return $tab; + } + + public function getAllConfigurations() { + return getAllDataFromTable(self::getTable()); + } + + public function loadFirstConfiguration() { + $configurations = $this->getAllConfigurations(); + if (empty($configurations)) { + return false; + } + $this->getFromDB(array_values($configurations)[0]['id']); + + return true; + } + + public function prepareInputForUpdate($input) { + return self::handleInput($input); + } + + public function prepareInputForAdd($input) { + return self::handleInput($input); + } + + public static function handleInput($input) { + if (isset($input["sccmdb_password"]) AND !empty($input["sccmdb_password"])) { $input["sccmdb_password"] = (new GLPIKey())->encrypt($input["sccmdb_password"]); } if (array_key_exists('inventory_server_url', $input) && !empty($input['inventory_server_url'])) { - $input['inventory_server_url'] = trim((string) $input['inventory_server_url'], '/ '); + $input['inventory_server_url'] = trim($input['inventory_server_url'], '/ '); } - return $input; } + public static function isIdAutoIncrement() + { + global $DB; + + $fields = $DB->listFields('glpi_plugin_sccm_configs'); + if (isset($fields['id'])) { + $fieldData = $fields['id']; + + $extra = is_object($fieldData) ? ($fieldData->Extra ?? $fieldData->extra ?? '') : ($fieldData['Extra'] ?? $fieldData['extra'] ?? ''); + + return str_contains(strtolower($extra), "auto_increment"); + } + return false; + } + + public static function install(Migration $migration) { /** @var array $CFG_GLPI */ @@ -124,16 +221,21 @@ public static function install(Migration $migration) $default_collation = DBConnection::getDefaultCollation(); $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); - $table = 'glpi_plugin_sccm_configs'; + $table = self::getTable(); if (!$DB->tableExists($table)) { - $query = "CREATE TABLE `" . $table . "`( - `id` int {$default_key_sign} NOT NULL, + $migration->displayMessage("Installing SCCM plugin ..."); + $migration->displayMessage("Table not exists, creating ..."); + + $query = "CREATE TABLE `". $table."`( + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `sccm_config_name` VARCHAR(255) NULL, `sccmdb_host` VARCHAR(255) NULL, `sccmdb_dbname` VARCHAR(255) NULL, `sccmdb_user` VARCHAR(255) NULL, `sccmdb_password` VARCHAR(255) NULL, + `sccm_collection_name` VARCHAR(255) NULL, `inventory_server_url` VARCHAR(255) NULL, `active_sync` tinyint NOT NULL default '0', `verify_ssl_cert` tinyint NOT NULL default '0', @@ -147,18 +249,33 @@ public static function install(Migration $migration) `comment` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; + $DB->rawQuery($query); + + - $DB->doQuery($query); + // Update display preferences + $migration->updateDisplayPrefs([PluginSccmConfig::class => [1, 2, 3, 4, 5, 6]]); - $query = "INSERT INTO `{$table}` - (id, date_mod, sccmdb_host, sccmdb_dbname, - sccmdb_user, sccmdb_password, inventory_server_url) - VALUES (1, NOW(), 'srv_sccm','bdd_sccm','user_sccm','', - NULL)"; + } else { + $migration->displayMessage("Updating SCCM plugin ..."); - $DB->doQuery($query); + // Need to move ID column to auto increment. + if (!self::isIdAutoIncrement()) { + $migration->changeField("glpi_plugin_sccm_configs", "id", "id", "autoincrement"); + $migration->migrationOneTable('glpi_plugin_sccm_configs'); + // Update display preferences + $migration->updateDisplayPrefs([PluginSccmConfig::class => [1, 2, 3, 4, 5, 6]]); + } - } else { + if (!$DB->fieldExists($table, 'sccm_config_name')) { + $migration->addField("glpi_plugin_sccm_configs", "sccm_config_name", "VARCHAR(255)"); + $migration->migrationOneTable('glpi_plugin_sccm_configs'); + } + + if (!$DB->fieldExists($table, 'sccm_collection_name')) { + $migration->addField("glpi_plugin_sccm_configs", "sccm_collection_name", "VARCHAR(255)"); + $migration->migrationOneTable('glpi_plugin_sccm_configs'); + } if (!$DB->fieldExists($table, 'verify_ssl_cert')) { $migration->addField("glpi_plugin_sccm_configs", "verify_ssl_cert", "tinyint NOT NULL default '0'"); @@ -187,25 +304,28 @@ public static function install(Migration $migration) if (!$DB->fieldExists($table, 'is_password_sodium_encrypted')) { $config = self::getInstance(); - if (!empty($config->fields['sccmdb_password'])) { - $key = new GLPIKey(); - $migration->addPostQuery( - $DB->buildUpdate( - 'glpi_plugin_sccm_configs', - [ - 'sccmdb_password' => $key->encrypt( - $key->decryptUsingLegacyKey( - $config->fields['sccmdb_password'], - ), - ), - ], - [ - 'id' => 1, - ], - ), - ); - } - + $configurations = $config->getAllConfigurations(); + foreach ($configurations as $data) { + $config->getFromDB($data['id']); + if (!empty($config->fields['sccmdb_password'])) { + $key = new GLPIKey(); + $migration->addPostQuery( + $DB->buildUpdate( + 'glpi_plugin_sccm_configs', + [ + 'sccmdb_password' => $key->encrypt( + $key->decryptUsingLegacyKey( + $config->fields['sccmdb_password'] + ) + ) + ], + [ + 'id' => $data['id'], + ] + ) + ); + } + } $migration->addField("glpi_plugin_sccm_configs", "is_password_sodium_encrypted", "tinyint NOT NULL default '1'"); $migration->migrationOneTable('glpi_plugin_sccm_configs'); } @@ -220,32 +340,47 @@ public static function install(Migration $migration) $migration->migrationOneTable('glpi_plugin_sccm_configs'); } - $sccm_config = $DB->request(['FROM' => 'glpi_plugin_sccm_configs'])->current(); - $inventory_server_url = trim($sccm_config['inventory_server_url'] ?? ''); - $url_matches = []; - if ( - $inventory_server_url !== '' - && ( - preg_match('/^(?.+)\/front\/inventory\.php$/', $inventory_server_url, $url_matches) === 1 - || preg_match('/^(?.+)\/(marketplace|plugins)\/(fusioninventory)\//', $inventory_server_url, $url_matches) === 1 - ) - ) { - // Strip script path from base URL. - $inventory_server_url = $url_matches['base_url']; - if ($inventory_server_url === $CFG_GLPI['url_base']) { - $inventory_server_url = ''; - } - - $sccm_config = $DB->update( - 'glpi_plugin_sccm_configs', - [ - 'inventory_server_url' => $inventory_server_url, - ], - [ - 'id' => 1, - ], - ); + $config = self::getInstance(); + $configurations = $config->getAllConfigurations(); + foreach ($configurations as $sccm_config) { + $inventory_server_url = trim($sccm_config['inventory_server_url'] ?? ''); + $url_matches = []; + if ( + $inventory_server_url !== '' + && ( + preg_match('/^(?.+)\/front\/inventory\.php$/', $inventory_server_url, $url_matches) === 1 + || preg_match('/^(?.+)\/(marketplace|plugins)\/(fusioninventory)\//', $inventory_server_url, $url_matches) === 1 + ) + ) { + // Strip script path from base URL. + $inventory_server_url = $url_matches['base_url']; + if ($inventory_server_url === $CFG_GLPI['url_base']) { + $inventory_server_url = ''; + } + + $sccm_config = $DB->update( + 'glpi_plugin_sccm_configs', + [ + 'inventory_server_url' => $inventory_server_url, + ], + [ + 'id' => $sccm_config['id'], + ] + ); + } } + $migration->addField("glpi_plugin_sccm_configs", "is_password_sodium_encrypted", "tinyint NOT NULL default '1'"); + $migration->migrationOneTable('glpi_plugin_sccm_configs'); + } + + if (!$DB->fieldExists($table, 'use_lasthwscan')) { + $migration->addField("glpi_plugin_sccm_configs", "use_lasthwscan", "tinyint NOT NULL default '0'"); + $migration->migrationOneTable('glpi_plugin_sccm_configs'); + } + + if (!$DB->fieldExists($table, 'fusioninventory_url')) { + $migration->changeField("glpi_plugin_sccm_configs", "fusioninventory_url", "inventory_server_url", "string"); + $migration->migrationOneTable('glpi_plugin_sccm_configs'); } return true; @@ -253,16 +388,16 @@ public static function install(Migration $migration) public static function uninstall() { - /** @var DBmysql $DB */ + /** @var \DBmysql $DB */ global $DB; - - if ($DB->tableExists('glpi_plugin_sccm_configs')) { - - $query = "DROP TABLE `glpi_plugin_sccm_configs`"; - $DB->doQuery($query); + $table = self::getTable(); + if ($DB->tableExists($table)) { + $DB->queryOrDie("DROP TABLE IF EXISTS `" . self::getTable() . "`") or die($DB->error()); + $displayPref = new DisplayPreference(); + foreach ($displayPref->find(['itemtype' => PluginSccmConfig::class]) as $pref) { + $displayPref->delete($pref); + } } - - return true; } public function getFormFields(): array @@ -277,23 +412,52 @@ public function showForm($ID, array $options = []) */ global $CFG_GLPI; - $config = self::getInstance(); - $password = $config->getField('sccmdb_password'); - $password = (new GLPIKey())->decrypt($password); - $config->fields['sccmdb_password'] = $password; + if ($ID > 0 && $this->isNewItem()) { + $this->getFromDB($ID); + } + + $storedPassword = $this->getField('sccmdb_password'); + if (!empty($storedPassword)) { + $glpiKey = new GLPIKey(); + // Try sodium decryption first (GLPI 11+). If the password was stored + // with the legacy key (GLPI 10), decrypt() returns an empty string and + // logs a warning instead of throwing — fall back to the legacy method. + $decrypted = $glpiKey->decrypt($storedPassword); + if ($decrypted === '') { + $decrypted = $glpiKey->decryptUsingLegacyKey($storedPassword); + } + $this->fields['sccmdb_password'] = $decrypted; + } - $url = ($config->getField('inventory_server_url') ?: "Ex : " . $CFG_GLPI['url_base']) . '/front/inventory.php'; + $url = ($this->getField('inventory_server_url') ?: "Ex : " . $CFG_GLPI['url_base']) . '/front/inventory.php'; TemplateRenderer::getInstance()->display( '@sccm/config.html.twig', [ 'action' => Toolbox::getItemTypeFormURL(self::class), - 'item' => $config, + 'item' => $this, 'url' => $url, ], ); return true; } + + public static function searchUrl() { + global $CFG_GLPI; + return $CFG_GLPI['url_base'] . "/plugins/sccm/front/config.php";; + } + + public function defineTabs($options = []) { + + $ong = []; + $this->addDefaultFormTab($ong); + $this->addStandardTab(__CLASS__, $ong, $options); + $this->addStandardTab('Log', $ong, $options); + return $ong; + } + public static function getIcon() { + return "fa-solid fa-dice-d20"; + } } diff --git a/inc/menu.class.php b/inc/menu.class.php index 032f7cf..d047c2e 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -31,23 +31,24 @@ class PluginSccmMenu extends CommonGLPI { - public static function getTypeName($nb = 0) - { - return __s('SCCM', 'sccm'); - } + public static function getTypeName($nb = 0) { + return __('Menu', 'sccm'); + } - public static function getMenuName() - { - return __s('SCCM', 'sccm'); - } + static function getMenuName() { + return __('SCCM', 'sccm'); + } - public static function getMenuContent() - { - return [ - 'title' => self::getMenuName(), - 'page' => '/plugins/sccm/front/config.form.php', - 'icon' => 'ti ti-database-cog', - ]; - } + public static function getMenuContent() { + $menu = [ + 'title' => PluginSccmConfig::getMenuName(), + 'page' => PluginSccmConfig::getSearchURL(false), + 'icon' => PluginSccmConfig::getIcon(), + 'options' => [], + ]; + + $menu['links']['add'] = PluginSccmConfig::getFormURL(false); + return $menu; + } } diff --git a/inc/sccm.class.php b/inc/sccm.class.php index 8498dc4..e996350 100644 --- a/inc/sccm.class.php +++ b/inc/sccm.class.php @@ -35,8 +35,11 @@ class PluginSccmSccm { public $devices; - public function __construct() + public PluginSccmSccmdb $sccmdb; + + public function __construct(PluginSccmSccmdb $sccmdb) { + $this->sccmdb = $sccmdb; if (!function_exists('curl_init')) { throw new BadRequestHttpException( __s('cURL extension (PHP) is required... !!', 'sccm'), @@ -55,17 +58,10 @@ public static function getTypeName($nb = 0) return __s('SCCM', 'sccm'); } - public function getDevices($where = 0, $limit = 99999999) + public function getDevices($collection_name, $where = 0, $limit = 99999999) { - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } - - $query = self::getcomputerQuery(); + $sccm_db = $this->sccmdb; + $query = self::getcomputerQuery($collection_name); if ($where != 0) { $query .= " WHERE csd.MachineID = '" . $where . "'"; @@ -80,21 +76,14 @@ public function getDevices($where = 0, $limit = 99999999) $tab['MD-SystemName'] = strtoupper((string) $tab['MD-SystemName']); $this->devices[] = $tab; $i++; - } - - $sccm_db->disconnect(); + } } public function getDatas($type, $deviceid, $limit = 99999999) { + $sccm_db = $this->sccmdb; - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $datas = []; if ($type == 'processors') { $fields = ['Manufacturer00','Name00','NormSpeed00','AddressWidth00','CPUKey00','NumberOfCores00', 'NumberOfLogicalProcessors00']; @@ -122,23 +111,15 @@ public function getDatas($type, $deviceid, $limit = 99999999) $data[] = $tmp; $i++; } - - $sccm_db->disconnect(); + return $data; } - public function getNetwork($deviceid, $limit = 99999999) + public function getNetwork($deviceid, $limit = 99999999) { + $sccm_db = $this->sccmdb; - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } - - $query = "SELECT NeDa.IPAddress00 as \"ND-IpAddress\", + $query = "SELECT NeDa.IPAddress00 as \"ND-IpAddress\", NeDa.MACAddress00 as \"ND-MacAddress\", NeDa.IPSubnet00 as \"ND-IpSubnet\", NeDa.DefaultIPGateway00 as \"ND-IpGateway\", @@ -166,38 +147,31 @@ public function getNetwork($deviceid, $limit = 99999999) $data[] = $tmp; $i++; } - - $sccm_db->disconnect(); + return $data; } - public function getSoftware($deviceid, $limit = 99999999) + public function getSoftware($deviceid, $limit = 99999999) { - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $sccm_db = $this->sccmdb; $query = "SELECT ArPd_64.DisplayName0 as \"ArPd-DisplayName\", - ArPd_64.InstallDate0 as \"ArPd-InstallDate\", - ArPd_64.Version0 as \"ArPd-Version\", - ArPd_64.Publisher0 as \"ArPd-Publisher\" - FROM v_GS_ADD_REMOVE_PROGRAMS_64 ArPd_64 - INNER JOIN v_R_System VrS on VrS.ResourceID=ArPd_64.ResourceID - WHERE ArPd_64.ResourceID = {$deviceid} - AND (ArPd_64.DisplayName0 is not null and ArPd_64.DisplayName0 <> '') - UNION - SELECT ArPd.DisplayName0 as \"ArPd-DisplayName\", - ArPd.InstallDate0 as \"ArPd-InstallDate\", - ArPd.Version0 as \"ArPd-Version\", - ArPd.Publisher0 as \"ArPd-Publisher\" - FROM v_GS_ADD_REMOVE_PROGRAMS ArPd - INNER JOIN v_R_System VrS on VrS.ResourceID=ArPd.ResourceID - WHERE ArPd.ResourceID = {$deviceid} - AND (ArPd.DisplayName0 is not null and ArPd.DisplayName0 <> '')"; + ArPd_64.InstallDate0 as \"ArPd-InstallDate\", + ArPd_64.Version0 as \"ArPd-Version\", + ArPd_64.Publisher0 as \"ArPd-Publisher\" + FROM v_GS_ADD_REMOVE_PROGRAMS_64 ArPd_64 + INNER JOIN v_R_System VrS on VrS.ResourceID=ArPd_64.ResourceID + WHERE ArPd_64.ResourceID = {$deviceid} + AND (ArPd_64.DisplayName0 is not null and ArPd_64.DisplayName0 <> '') + UNION + SELECT ArPd.DisplayName0 as \"ArPd-DisplayName\", + ArPd.InstallDate0 as \"ArPd-InstallDate\", + ArPd.Version0 as \"ArPd-Version\", + ArPd.Publisher0 as \"ArPd-Publisher\" + FROM v_GS_ADD_REMOVE_PROGRAMS ArPd + INNER JOIN v_R_System VrS on VrS.ResourceID=ArPd.ResourceID + WHERE ArPd.ResourceID = {$deviceid} + AND (ArPd.DisplayName0 is not null and ArPd.DisplayName0 <> '')"; $result = $sccm_db->exec_query($query); @@ -215,20 +189,14 @@ public function getSoftware($deviceid, $limit = 99999999) $i++; } - $sccm_db->disconnect(); return $data; } + public function getMemories($deviceid, $limit = 99999999) { - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $sccm_db = $this->sccmdb; $query = "SELECT Capacity0 as \"Mem-Capacity\", @@ -262,32 +230,24 @@ public function getMemories($deviceid, $limit = 99999999) $data[] = $tmp; $i++; } - - $sccm_db->disconnect(); return $data; } - public function getVideos($deviceid, $limit = 99999999) + public function getVideos($deviceid, $limit = 99999999) { - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $sccm_db = $this->sccmdb; $query = " - SELECT - VideoProcessor0 as \"Vid-Chipset\", - AdapterRAM0/1024 as \"Vid-Memory\", - Name0 as \"Vid-Name\", - CONCAT(CurrentHorizontalResolution0, 'x', CurrentVerticalResolution0) as \"Vid-Resolution\", - GroupID as \"Vid-PciSlot\" - FROM v_GS_VIDEO_CONTROLLER - WHERE VideoProcessor0 is not null - AND ResourceID = '" . $deviceid . "' - ORDER BY GroupID"; + SELECT + VideoProcessor0 as \"Vid-Chipset\", + AdapterRAM0/1024 as \"Vid-Memory\", + Name0 as \"Vid-Name\", + CONCAT(CurrentHorizontalResolution0, 'x', CurrentVerticalResolution0) as \"Vid-Resolution\", + GroupID as \"Vid-PciSlot\" + FROM v_GS_VIDEO_CONTROLLER + WHERE VideoProcessor0 is not null + AND ResourceID = '" . $deviceid . "' + ORDER BY GroupID"; $result = $sccm_db->exec_query($query); @@ -305,28 +265,20 @@ public function getVideos($deviceid, $limit = 99999999) $i++; } - $sccm_db->disconnect(); return $data; } public function getSounds($deviceid, $limit = 99999999) { - - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $sccm_db = $this->sccmdb; $query = " - SELECT distinct - Description0 as \"Snd-Description\", - Manufacturer0 as \"Snd-Manufacturer\", - Name0 as \"Snd-Name\" - FROM v_GS_SOUND_DEVICE - WHERE ResourceID = '" . $deviceid . "'"; + SELECT distinct + Description0 as \"Snd-Description\", + Manufacturer0 as \"Snd-Manufacturer\", + Name0 as \"Snd-Name\" + FROM v_GS_SOUND_DEVICE + WHERE ResourceID = '" . $deviceid . "'"; $result = $sccm_db->exec_query($query); @@ -339,44 +291,34 @@ public function getSounds($deviceid, $limit = 99999999) foreach ($tab as $key => $value) { $tmp[$key] = $value; } - $data[] = $tmp; - $i++; } - $sccm_db->disconnect(); - - return $data; - } + return $data; + } public function getStorages($deviceid, $limit = 99999999) { - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $sccm_db = $this->sccmdb; $query = " - SELECT - md.SystemName00, - gld.ResourceID as \"gld-ResourceID\", - gld.Description0 as \"gld-Description\", - gld.DeviceID0 as \"gld-Partition\", - gld.FileSystem0 as \"gld-FileSystem\", - gld.Size0 as \"gld-TotalSize\", - gld.FreeSpace0 as \"gld-FreeSpace\", - gld.VolumeName0 as \"gld-MountingPoint\", - gdi.Caption0 as \"gdi-Caption\" - FROM v_GS_LOGICAL_DISK as gld - INNER JOIN v_gs_Disk as gdi on gdi.ResourceID = gld.ResourceID - LEFT JOIN Motherboard_DATA as md on gld.ResourceID = md.MachineID - WHERE gld.GroupID = gdi.GroupID - AND gld.ResourceID = '" . $deviceid . "'"; + SELECT + md.SystemName00, + gld.ResourceID as \"gld-ResourceID\", + gld.Description0 as \"gld-Description\", + gld.DeviceID0 as \"gld-Partition\", + gld.FileSystem0 as \"gld-FileSystem\", + gld.Size0 as \"gld-TotalSize\", + gld.FreeSpace0 as \"gld-FreeSpace\", + gld.VolumeName0 as \"gld-MountingPoint\", + gdi.Caption0 as \"gdi-Caption\" + FROM v_GS_LOGICAL_DISK as gld + INNER JOIN v_gs_Disk as gdi on gdi.ResourceID = gld.ResourceID + LEFT JOIN Motherboard_DATA as md on gld.ResourceID = md.MachineID + WHERE gld.GroupID = gdi.GroupID + AND gld.ResourceID = '" . $deviceid . "'"; $result = $sccm_db->exec_query($query); @@ -395,33 +337,23 @@ public function getStorages($deviceid, $limit = 99999999) $i++; } - - $sccm_db->disconnect(); - return $data; } public function getMedias($deviceid, $limit = 99999999) { - - $sccm_db = new PluginSccmSccmdb(); - $res = $sccm_db->connect(); - if (!$res) { - throw new BadRequestHttpException( - __s('Cannot connect to SCCM database', 'sccm'), - ); - } + $sccm_db = $this->sccmdb; $query = " - SELECT distinct - Description0 as \"Med-Description\", - Manufacturer0 as \"Med-Manufacturer\", - Caption0 as \"Med-Model\", - Name0 as \"Med-Name\", - SCSITargetID0 as \"Med-SCSITargetId\", - MediaType0 as \"Med-Type\" - FROM v_GS_CDROM - WHERE ResourceID = '" . $deviceid . "'"; + SELECT distinct + Description0 as \"Med-Description\", + Manufacturer0 as \"Med-Manufacturer\", + Caption0 as \"Med-Model\", + Name0 as \"Med-Name\", + SCSITargetID0 as \"Med-SCSITargetId\", + MediaType0 as \"Med-Type\" + FROM v_GS_CDROM + WHERE ResourceID = '" . $deviceid . "'"; $result = $sccm_db->exec_query($query); @@ -441,8 +373,6 @@ public function getMedias($deviceid, $limit = 99999999) $i++; } - $sccm_db->disconnect(); - return $data; } @@ -476,6 +406,67 @@ public static function install() ); } + public static function getcomputerQuery($collection_name) { + + $result = "SELECT csd.Description00 as \"CSD-Description\", + csd.Domain00 as \"CSD-Domain\", + csd.Manufacturer00 as \"CSD-Manufacturer\", + csd.Model00 as \"CSD-Model\", + csd.Roles00 as \"CSD-Roles\", + csd.SystemType00 as \"CSD-SystemType\", + csd.UserName00 as \"CSD-UserName\", + csd.MachineID as \"CSD-MachineID\", + csd.TimeKey as \"CSD-TimeKey\", + md.SystemName00 as \"MD-SystemName\", + osd.BuildNumber00 as \"OSD-BuildNumber\", + osd.Caption00 as \"OSD-Caption\", + osd.CSDVersion00 as \"OSD-CSDVersion\", + osd.BootDevice00 as \"OSD-BootDevice\", + osd.InstallDate00 as \"OSD-InstallDate\", + osd.LastBootUpTime00 as \"OSD-LastBootUpTime\", + osd.Manufacturer00 as \"OSD-Manufacturer\", + osd.Name00 as \"OSD-Name\", + osd.Organization00 as \"OSD-Organization\", + osd.RegisteredUser00 as \"OSD-RegisteredUser\", + osd.TotalVirtualMemorySize00 as \"OSD-TotalVirtualMemory\", + osd.TotalVisibleMemorySize00 as \"OSD-TotalVisibleMemory\", + osd.Version00 as \"OSD-Version\", + pbd.SerialNumber00 as \"PBD-SerialNumber\", + pbd.ReleaseDate00 as \"PBD-ReleaseDate\", + pbd.Name00 as \"PBD-Name\", + pbd.SMBIOSBIOSVersion00 as \"PBD-BiosVersion\", + pbd.Version00 as \"PBD-Version\", + pbd.Manufacturer00 as \"PBD-Manufacturer\", + sdi.User_Name0 as \"SDI-UserName\", + sd.SMSID0 as \"SD-UUID\", + sd.SystemRole0 as \"SD-SystemRole\", + VrS.User_Name0 as \"VrS-UserName\", + vWD.LastHWScan as \"vWD-LastScan\" + FROM Computer_System_DATA csd + LEFT JOIN Motherboard_DATA md ON csd.MachineID = md.MachineID + LEFT JOIN Operating_System_DATA osd ON csd.MachineID = osd.MachineID + LEFT JOIN v_GS_WORKSTATION_STATUS vWD ON csd.MachineID = vWD.ResourceID + LEFT JOIN PC_BIOS_DATA pbd ON csd.MachineID = pbd.MachineID + LEFT JOIN System_DISC sdi ON csd.MachineID = sdi.ItemKey + LEFT JOIN System_DATA sd ON csd.MachineID = sd.MachineID + INNER JOIN v_R_System VrS ON csd.MachineID = VrS.ResourceID + WHERE csd.MachineID is not null and csd.MachineID != '' + "; + + if (!empty($collection_name)) + { + $result .= " AND md.SystemName00 in ( + SELECT FCM.Name + FROM v_FullCollectionMembership FCM INNER JOIN v_Collection COL + ON FCM.CollectionID = COL.CollectionID + WHERE col.name='" . $collection_name . "' + ) + "; + } + + return $result; + } + public static function uninstall() { CronTask::unregister(self::class); @@ -500,9 +491,7 @@ public static function cronInfo($name) if ($name == "SCCMPush") { return ['description' => __s("Interface - SCCMPush", "sccm")]; } - return null; - } public static function executeCollect($task) @@ -513,125 +502,116 @@ public static function executeCollect($task) $REP_XML = GLPI_PLUGIN_DOC_DIR . '/sccm/xml/'; $PluginSccmConfig = new PluginSccmConfig(); - $PluginSccmConfig->getFromDB(1); + $configurations = $PluginSccmConfig->getAllConfigurations(); + + if (empty($configurations)) + { + echo __("No SCCM configurations found.", "sccm"); + return $retcode; + } + + foreach ($configurations as $config) { - $PluginSccmSccm = new PluginSccmSccm(); + $configId = $config['id']; + Toolbox::logInFile('sccm', "Init Collect on ". $config['sccm_config_name'] ." \n", true); - if ($PluginSccmConfig->getField('active_sync') == 1) { + $PluginSccmConfig->getFromDB($configId); - $PluginSccmSccm->getDevices(); - Toolbox::logInFile('sccm', "getDevices OK \n", true); + $REP_XML = GLPI_PLUGIN_DOC_DIR.'/sccm/xml/'. $PluginSccmConfig->getField('id'); - Toolbox::logInFile('sccm', "Generate XML start : " - . count($PluginSccmSccm->devices) . " files\n", true); + if (!is_dir($REP_XML)) { + mkdir($REP_XML); + } - foreach ($PluginSccmSccm->devices as $device_values) { + if ($PluginSccmConfig->getField('active_sync') == 1) { + $PluginSccmSccmdb = new PluginSccmSccmdb(); + if (!$PluginSccmSccmdb->connect($config['id'])) { + Toolbox::logInFile('sccm', "Error connecting to database on config ". $config['sccm_config_name'] ." \n", true); + continue; + } + $PluginSccmSccm = new PluginSccmSccm($PluginSccmSccmdb); - $PluginSccmSccmxml = new PluginSccmSccmxml($device_values); + Toolbox::logInFile('sccm', "Getting devices ... \n", true); + $PluginSccmSccm->getDevices($PluginSccmConfig->getField('sccm_collection_name')); + Toolbox::logInFile('sccm', "getDevices OK \n", true); - $PluginSccmSccmxml->setAccessLog(); - $PluginSccmSccmxml->setAccountInfos(); - $PluginSccmSccmxml->setHardware(); - $PluginSccmSccmxml->setOS(); - $PluginSccmSccmxml->setBios(); - $PluginSccmSccmxml->setProcessors(); - $PluginSccmSccmxml->setSoftwares(); - $PluginSccmSccmxml->setMemories(); - $PluginSccmSccmxml->setVideos(); - $PluginSccmSccmxml->setSounds(); - $PluginSccmSccmxml->setUsers(); - $PluginSccmSccmxml->setNetworks(); - $PluginSccmSccmxml->setStorages(); + if ($PluginSccmSccm->devices == null){ + Toolbox::logInFile('sccm', "Collect completed, no devices found.\n", true); + continue; + } - $SXML = $PluginSccmSccmxml->sxml; + Toolbox::logInFile('sccm', "Generate XML start : " + . count($PluginSccmSccm->devices) . " files\n", true); - $SXML->asXML($REP_XML . $PluginSccmSccmxml->device_id . ".ocs"); + foreach ($PluginSccmSccm->devices as $device_values) { - Toolbox::logInFile('sccm', "Collect OK for device - " . $PluginSccmSccmxml->device_id . " \n", true); - $task->addVolume(1); - } + $PluginSccmSccmxml = new PluginSccmSccmxml($PluginSccmSccm, $device_values); - $retcode = 1; - Toolbox::logInFile('sccm', "Collect completed \n", true); + $PluginSccmSccmxml->setAccessLog(); + $PluginSccmSccmxml->setAccountInfos(); + $PluginSccmSccmxml->setHardware(); + $PluginSccmSccmxml->setOS(); + $PluginSccmSccmxml->setBios(); + $PluginSccmSccmxml->setProcessors(); + $PluginSccmSccmxml->setSoftwares(); + $PluginSccmSccmxml->setMemories(); + $PluginSccmSccmxml->setVideos(); + $PluginSccmSccmxml->setSounds(); + $PluginSccmSccmxml->setUsers(); + $PluginSccmSccmxml->setNetworks(); + $PluginSccmSccmxml->setStorages(); - } else { - echo __s("Collect is disabled by configuration.", "sccm"); - } + $SXML = $PluginSccmSccmxml->sxml; - return $retcode; - } + $SXML->asXML($REP_XML."/".$PluginSccmSccmxml->device_id.".ocs"); - public static function getcomputerQuery() - { - return "SELECT csd.Description00 as \"CSD-Description\", - csd.Domain00 as \"CSD-Domain\", - csd.Manufacturer00 as \"CSD-Manufacturer\", - csd.Model00 as \"CSD-Model\", - csd.Roles00 as \"CSD-Roles\", - csd.SystemType00 as \"CSD-SystemType\", - csd.UserName00 as \"CSD-UserName\", - csd.MachineID as \"CSD-MachineID\", - csd.TimeKey as \"CSD-TimeKey\", - md.SystemName00 as \"MD-SystemName\", - osd.BuildNumber00 as \"OSD-BuildNumber\", - osd.Caption00 as \"OSD-Caption\", - osd.CSDVersion00 as \"OSD-CSDVersion\", - osd.BootDevice00 as \"OSD-BootDevice\", - osd.InstallDate00 as \"OSD-InstallDate\", - osd.LastBootUpTime00 as \"OSD-LastBootUpTime\", - osd.Manufacturer00 as \"OSD-Manufacturer\", - osd.Name00 as \"OSD-Name\", - osd.Organization00 as \"OSD-Organization\", - osd.RegisteredUser00 as \"OSD-RegisteredUser\", - osd.TotalVirtualMemorySize00 as \"OSD-TotalVirtualMemory\", - osd.TotalVisibleMemorySize00 as \"OSD-TotalVisibleMemory\", - osd.Version00 as \"OSD-Version\", - pbd.SerialNumber00 as \"PBD-SerialNumber\", - pbd.ReleaseDate00 as \"PBD-ReleaseDate\", - pbd.Name00 as \"PBD-Name\", - pbd.SMBIOSBIOSVersion00 as \"PBD-BiosVersion\", - pbd.Version00 as \"PBD-Version\", - pbd.Manufacturer00 as \"PBD-Manufacturer\", - sdi.User_Name0 as \"SDI-UserName\", - sd.SMSID0 as \"SD-UUID\", - sd.SystemRole0 as \"SD-SystemRole\", - VrS.User_Name0 as \"VrS-UserName\", - vWD.LastHWScan as \"vWD-LastScan\" - FROM Computer_System_DATA csd - LEFT JOIN Motherboard_DATA md ON csd.MachineID = md.MachineID - LEFT JOIN Operating_System_DATA osd ON csd.MachineID = osd.MachineID - LEFT JOIN v_GS_WORKSTATION_STATUS vWD ON csd.MachineID = vWD.ResourceID - LEFT JOIN PC_BIOS_DATA pbd ON csd.MachineID = pbd.MachineID - LEFT JOIN System_DISC sdi ON csd.MachineID = sdi.ItemKey - LEFT JOIN System_DATA sd ON csd.MachineID = sd.MachineID - INNER JOIN v_R_System VrS ON csd.MachineID = VrS.ResourceID - WHERE csd.MachineID is not null and csd.MachineID != ''"; - } + Toolbox::logInFile('sccm', "Collect OK for device - ".$PluginSccmSccmxml->device_id." \n", true); + $task->addVolume(1); + } + $retcode = 1; + Toolbox::logInFile('sccm', "Collect completed on ". $config['sccm_config_name'] .", " . count($PluginSccmSccm->devices) . " devices found \n", true); + $PluginSccmSccmdb->disconnect(); + } else { + Toolbox::logInFile('sccm', "Collect is disabled by configuration on ". $config['sccm_config_name']." \n", true); + echo __("Collect is disabled by configuration on ". $config['sccm_config_name'] .".", "sccm"); + } + } + return $retcode; + } - public static function executePush($task) + public static function executePush($task) { - /** @var array $CFG_GLPI */ global $CFG_GLPI; + $retcode = -1; - $PluginSccmSccmdb = new PluginSccmSccmdb(); - $res = $PluginSccmSccmdb->connect(); $PluginSccmConfig = new PluginSccmConfig(); - $PluginSccmConfig->getFromDB(1); + $configurations = $PluginSccmConfig->getAllConfigurations(); - $retcode = -1; + if (empty($configurations)) + { + echo __("No SCCM configurations found.", "sccm"); + return $retcode; + } - if ($PluginSccmConfig->getField('active_sync') == 1) { - if ($res) { + foreach ($configurations as $config) { - $query = self::getcomputerQuery(); - $result = $PluginSccmSccmdb->exec_query($query); + Toolbox::logInFile('sccm', "Init Push on ". $config['sccm_config_name'] ." \n", true); + $PluginSccmConfig->getFromDB($config['id']); + + if ($PluginSccmConfig->getField('active_sync') == 1) { + $PluginSccmSccmdb = new PluginSccmSccmdb(); + if (!$PluginSccmSccmdb->connect($config['id'])) { + Toolbox::logInFile('sccm', "Error connecting to database on config ". $config['sccm_config_name'] ." \n", true); + continue; + } + $query = self::getcomputerQuery($PluginSccmConfig->getField('sccm_collection_name')); + $result = $PluginSccmSccmdb->exec_query($query); $tab = []; while ($tab = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { - - $REP_XML = realpath(GLPI_PLUGIN_DOC_DIR . '/sccm/xml/' . $tab['CSD-MachineID'] . '.ocs'); + $REP_XML = realpath(GLPI_PLUGIN_DOC_DIR.'/sccm/xml/'. $PluginSccmConfig->getField('id')."/".$tab['CSD-MachineID'].'.ocs'); if ($REP_XML === false) { Toolbox::logInFile('sccm', "There is a problem with the path, realpath function return false.\nPath : " . $REP_XML . "\n", true); @@ -670,10 +650,10 @@ public static function executePush($task) curl_setopt($ch, CURLOPT_REFERER, $CFG_GLPI['url_base']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $ch_result = curl_exec($ch); + if ($ch_result === false) { Toolbox::logInFile('sccm', curl_error($ch) . "\n", true); } else { - $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpcode != 200) { $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); @@ -696,31 +676,25 @@ public static function executePush($task) } } } - Toolbox::logInFile('sccm', "Push OK - " . $tab['CSD-MachineID'] . " \n", true); } - } - curl_close($ch); } else { $errors = ""; foreach (libxml_get_errors() as $error) { $errors = $errors . $error->message . "\n"; } - Toolbox::logInFile('sccm', "Can't load the file with the path : " . $REP_XML . "\n\n" . $errors . "\n", true); } } - - Toolbox::logInFile('sccm', "Push completed \n", true); + Toolbox::logInFile('sccm', "Push completed on ".$config['sccm_config_name']."\n", true); $PluginSccmSccmdb->disconnect(); $retcode = 1; + } else { + echo __("Push is disabled by configuration on ".$config['sccm_config_name'].".", "sccm"); } - } else { - echo __s("Push is disabled by configuration.", "sccm"); } - return $retcode; } diff --git a/inc/sccmdb.class.php b/inc/sccmdb.class.php index 1648faa..90ee74c 100644 --- a/inc/sccmdb.class.php +++ b/inc/sccmdb.class.php @@ -64,10 +64,19 @@ class PluginSccmSccmdb { public $dbconn; - public function connect() + function testConfiguration($id) { + if ($this->connect($id)) { + Session::addMessageAfterRedirect(__("Connection successfull!", 'sccm'), false, INFO, false); + $this->disconnect(); + } else { + Session::addMessageAfterRedirect(__("Connection failed!", 'sccm'), false, ERROR, false); + } + } + + public function connect($id) { $config = new PluginSccmConfig(); - $config->getFromDB(1); + $config->getFromDB($id); $host = $config->getField('sccmdb_host'); $dbname = $config->getField('sccmdb_dbname'); diff --git a/inc/sccmxml.class.php b/inc/sccmxml.class.php index 2b9510e..f5dc176 100644 --- a/inc/sccmxml.class.php +++ b/inc/sccmxml.class.php @@ -33,15 +33,15 @@ class PluginSccmSccmxml { public $device_id; - public $sxml; - public $agentbuildnumber; - public $username; - public function __construct(public $data) + public PluginSccmSccm $sccm; + + public function __construct(PluginSccmSccm $sccm, public $data) { + $this->sccm = $sccm; $plug = new Plugin(); $plug->getFromDBbyDir("sccm"); @@ -172,13 +172,10 @@ public function setBios() public function setProcessors() { - $sccm = new PluginSccmSccm(); - $cpukeys = []; - $CONTENT = $this->sxml->CONTENT[0]; $i = 0; - foreach ($sccm->getDatas('processors', $this->device_id) as $value) { + foreach ($this->sccm->getDatas('processors', $this->device_id) as $value) { if (!in_array($value['CPUKey00'], $cpukeys)) { $CONTENT->addChild('CPUS'); $CPUS = $this->sxml->CONTENT[0]->CPUS[$i]; @@ -199,13 +196,11 @@ public function setProcessors() public function setSoftwares() { - $sccm = new PluginSccmSccm(); - $antivirus = []; $inject_antivirus = false; $CONTENT = $this->sxml->CONTENT[0]; $i = 0; - foreach ($sccm->getSoftware($this->device_id) as $value) { + foreach ($this->sccm->getSoftware($this->device_id) as $value) { $CONTENT->addChild('SOFTWARES'); $SOFTWARES = $this->sxml->CONTENT[0]->SOFTWARES[$i]; @@ -250,11 +245,9 @@ public function setSoftwares() public function setMemories() { - $sccm = new PluginSccmSccm(); - $CONTENT = $this->sxml->CONTENT[0]; $i = 0; - foreach ($sccm->getMemories($this->device_id) as $value) { + foreach ($this->sccm->getMemories($this->device_id) as $value) { $CONTENT->addChild('MEMORIES'); $MEMORIES = $this->sxml->CONTENT[0]->MEMORIES[$i]; @@ -277,11 +270,9 @@ public function setMemories() public function setVideos() { - $sccm = new PluginSccmSccm(); - $CONTENT = $this->sxml->CONTENT[0]; $i = 0; - foreach ($sccm->getVideos($this->device_id) as $value) { + foreach ($this->sccm->getVideos($this->device_id) as $value) { $CONTENT->addChild('VIDEOS'); $VIDEOS = $this->sxml->CONTENT[0]->VIDEOS[$i]; @@ -298,11 +289,9 @@ public function setVideos() public function setSounds() { - $sccm = new PluginSccmSccm(); - $CONTENT = $this->sxml->CONTENT[0]; $i = 0; - foreach ($sccm->getSounds($this->device_id) as $value) { + foreach ($this->sccm->getSounds($this->device_id) as $value) { $CONTENT->addChild('SOUNDS'); $SOUNDS = $this->sxml->CONTENT[0]->SOUNDS[$i]; @@ -362,11 +351,9 @@ public function determineNetworkType($network_description) public function setNetworks() { - $sccm = new PluginSccmSccm(); - $CONTENT = $this->sxml->CONTENT[0]; - $networks = $sccm->getNetwork($this->device_id); + $networks = $this->sccm->getNetwork($this->device_id); if (count($networks) > 0) { @@ -400,11 +387,10 @@ public function setNetworks() } public function setStorages() - { - $sccm = new PluginSccmSccm(); + { $CONTENT = $this->sxml->CONTENT[0]; $i = 0; - foreach ($sccm->getStorages($this->device_id) as $value) { + foreach ($this->sccm->getStorages($this->device_id) as $value) { $value['gld-TotalSize'] = intval($value['gld-TotalSize']) * 1024; $value['gld-FreeSpace'] = intval($value['gld-FreeSpace']) * 1024; $CONTENT->addChild('DRIVES'); @@ -420,7 +406,7 @@ public function setStorages() } $i = 0; - foreach ($sccm->getMedias($this->device_id) as $value) { + foreach ($this->sccm->getMedias($this->device_id) as $value) { $CONTENT->addChild('STORAGES'); $STORAGES = $this->sxml->CONTENT[0]->STORAGES[$i]; $STORAGES->addChild('DESCRIPTION', $value['Med-Description']); diff --git a/templates/config.html.twig b/templates/config.html.twig index 4920e95..63e4433 100644 --- a/templates/config.html.twig +++ b/templates/config.html.twig @@ -32,9 +32,11 @@ {% block more_fields %} -
- - + {{ fields.textField( + 'sccm_config_name', + item.fields['sccm_config_name'], + __('SCCM configuration name', 'sccm') + ) }} {{ fields.checkboxField( 'active_sync', @@ -67,6 +69,12 @@ {'autocomplete': 'off'} ) }} + {{ fields.textField( + 'sccm_collection_name', + item.fields['sccm_collection_name'], + __('SCCM collection name', 'sccm') + ) }} + {% set alert %} {{ url }} {% endset %}