Skip to content
Merged
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
53 changes: 53 additions & 0 deletions front/computermodel.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* -------------------------------------------------------------------------
* Carbon plugin for GLPI
*
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
* @link https://github.com/pluginsGLPI/carbon
*
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Carbon plugin for GLPI.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\NotFoundHttpException;
use GlpiPlugin\Carbon\ComputerModel;

include(__DIR__ . '/../../../inc/includes.php');

if (!Plugin::isPluginActive('carbon')) {
throw new NotFoundHttpException();
}

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

$item = new ComputerModel();

if (isset($_POST['update'])) {
// Add a new Form
Session::checkRight('entity', UPDATE);
$item->update($_POST);
Html::back();
}

Html::back();
2 changes: 0 additions & 2 deletions front/embodiedimpact.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@

use Glpi\Event;
use Glpi\Exception\Http\NotFoundHttpException;
use GlpiPlugin\Carbon\Config;
use GlpiPlugin\Carbon\EmbodiedImpact;
use GlpiPlugin\Carbon\Impact\Embodied\AbstractEmbodiedImpact;
use GlpiPlugin\Carbon\Impact\Embodied\Engine;

include(__DIR__ . '/../../../inc/includes.php');
Expand Down
54 changes: 54 additions & 0 deletions front/monitormodel.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* -------------------------------------------------------------------------
* Carbon plugin for GLPI
*
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
* @link https://github.com/pluginsGLPI/carbon
*
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Carbon plugin for GLPI.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\NotFoundHttpException;
use GlpiPlugin\Carbon\MonitorModel;

include(__DIR__ . '/../../../inc/includes.php');

if (!Plugin::isPluginActive('carbon')) {
throw new NotFoundHttpException();
}


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

$item = new MonitorModel();

if (isset($_POST['update'])) {
// Add a new Form
Session::checkRight('entity', UPDATE);
$item->update($_POST);
Html::back();
}

Html::back();
54 changes: 54 additions & 0 deletions front/networkequipmentmodel.form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* -------------------------------------------------------------------------
* Carbon plugin for GLPI
*
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
* @link https://github.com/pluginsGLPI/carbon
*
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Carbon plugin for GLPI.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/

use Glpi\Exception\Http\NotFoundHttpException;
use GlpiPlugin\Carbon\NetworkEquipmentModel;

include(__DIR__ . '/../../../inc/includes.php');

if (!Plugin::isPluginActive('carbon')) {
throw new NotFoundHttpException();
}


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

$item = new NetworkEquipmentModel();

if (isset($_POST['update'])) {
// Add a new Form
Session::checkRight('entity', UPDATE);
$item->update($_POST);
Html::back();
}

Html::back();
48 changes: 48 additions & 0 deletions install/mysql/plugin_carbon_empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_sources_zones` (
UNIQUE KEY `unicity` (`plugin_carbon_sources_id`, `plugin_carbon_zones_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_computermodels` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`computermodels_id` int unsigned NOT NULL DEFAULT '0',
`gwp` int DEFAULT '0' COMMENT '(unit gCO2eq) Global warming potential',
`gwp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`gwp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
`adp` int DEFAULT '0' COMMENT '(unit gSbEq) Abiotic depletion potential',
`adp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`adp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
`pe` int DEFAULT '0' COMMENT '(unit J) Primary energy',
`pe_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`pe_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`computermodels_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_computertypes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`computertypes_id` int unsigned NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -139,6 +155,22 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_environmentalimpacts` (
UNIQUE KEY `unicity` (`computers_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_monitormodels` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`monitormodels_id` int unsigned NOT NULL DEFAULT '0',
`gwp` int DEFAULT '0' COMMENT '(unit gCO2eq) Global warming potential',
`gwp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`gwp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
`adp` int DEFAULT '0' COMMENT '(unit gSbEq) Abiotic depletion potential',
`adp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`adp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
`pe` int DEFAULT '0' COMMENT '(unit J) Primary energy',
`pe_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`pe_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`monitormodels_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_monitortypes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`monitortypes_id` int unsigned NOT NULL DEFAULT '0',
Expand All @@ -148,6 +180,22 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_monitortypes` (
UNIQUE KEY `unicity` (`monitortypes_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_networkequipmentmodels` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`networkequipmentmodels_id` int unsigned NOT NULL DEFAULT '0',
`gwp` int DEFAULT '0' COMMENT '(unit gCO2eq) Global warming potential',
`gwp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`gwp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
`adp` int DEFAULT '0' COMMENT '(unit gSbEq) Abiotic depletion potential',
`adp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`adp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
`pe` int DEFAULT '0' COMMENT '(unit J) Primary energy',
`pe_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
`pe_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`networkequipmentmodels_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_networkequipmenttypes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`networkequipmenttypes_id` int unsigned NOT NULL DEFAULT '0',
Expand Down
9 changes: 7 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
use GlpiPlugin\Carbon\Location;

define('PLUGIN_CARBON_VERSION', '1.2.0-dev');
define('PLUGIN_CARBON_SCHEMA_VERSION', '1.1.0');
define('PLUGIN_CARBON_SCHEMA_VERSION', '1.2.0');

// Minimal GLPI version, inclusive
define("PLUGIN_CARBON_MIN_GLPI_VERSION", "11.0.0-beta");
Expand Down Expand Up @@ -143,10 +143,15 @@ function plugin_carbon_registerClasses()
Plugin::registerClass(Location::class, ['addtabon' => GlpiLocation::class]);

foreach (PLUGIN_CARBON_TYPES as $itemtype) {
$item_type_class = 'GlpiPlugin\\Carbon\\' . $itemtype . 'Type';
$core_type_class = $itemtype . 'Type';
$item_type_class = 'GlpiPlugin\\Carbon\\' . $core_type_class;
Plugin::registerClass($item_type_class, ['addtabon' => $core_type_class]);

Plugin::registerClass(UsageInfo::class, ['addtabon' => $itemtype]);

$core_model_class = $itemtype . 'Model';
$item_model_class = 'GlpiPlugin\\Carbon\\' . $core_model_class;
Plugin::registerClass($item_model_class, ['addtabon' => $core_model_class]);
}
}

Expand Down
Loading