Skip to content

Commit fa1cdab

Browse files
committed
feat(ComputerModel,MonitorModel,NetworkEquipmentModel): user input for enbodied impacts
1 parent 40cb8e7 commit fa1cdab

34 files changed

+1407
-57
lines changed

front/computermodel.form.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/**
4+
* -------------------------------------------------------------------------
5+
* Carbon plugin for GLPI
6+
*
7+
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
8+
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
9+
* @link https://github.com/pluginsGLPI/carbon
10+
*
11+
* -------------------------------------------------------------------------
12+
*
13+
* LICENSE
14+
*
15+
* This file is part of Carbon plugin for GLPI.
16+
*
17+
* This program is free software: you can redistribute it and/or modify
18+
* it under the terms of the GNU General Public License as published by
19+
* the Free Software Foundation, either version 3 of the License, or
20+
* (at your option) any later version.
21+
*
22+
* This program is distributed in the hope that it will be useful,
23+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
* GNU General Public License for more details.
26+
*
27+
* You should have received a copy of the GNU General Public License
28+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
*
30+
* -------------------------------------------------------------------------
31+
*/
32+
33+
use Glpi\Exception\Http\NotFoundHttpException;
34+
use GlpiPlugin\Carbon\ComputerModel;
35+
36+
include(__DIR__ . '/../../../inc/includes.php');
37+
38+
if (!Plugin::isPluginActive('carbon')) {
39+
throw new NotFoundHttpException();
40+
}
41+
42+
Session::checkRight('config', UPDATE);
43+
44+
$item = new ComputerModel();
45+
46+
if (isset($_POST['update'])) {
47+
// Add a new Form
48+
Session::checkRight('entity', UPDATE);
49+
$item->update($_POST);
50+
Html::back();
51+
}
52+
53+
Html::back();

front/embodiedimpact.form.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232

3333
use Glpi\Event;
3434
use Glpi\Exception\Http\NotFoundHttpException;
35-
use GlpiPlugin\Carbon\Config;
3635
use GlpiPlugin\Carbon\EmbodiedImpact;
37-
use GlpiPlugin\Carbon\Impact\Embodied\AbstractEmbodiedImpact;
3836
use GlpiPlugin\Carbon\Impact\Embodied\Engine;
3937

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

front/monitormodel.form.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* -------------------------------------------------------------------------
5+
* Carbon plugin for GLPI
6+
*
7+
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
8+
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
9+
* @link https://github.com/pluginsGLPI/carbon
10+
*
11+
* -------------------------------------------------------------------------
12+
*
13+
* LICENSE
14+
*
15+
* This file is part of Carbon plugin for GLPI.
16+
*
17+
* This program is free software: you can redistribute it and/or modify
18+
* it under the terms of the GNU General Public License as published by
19+
* the Free Software Foundation, either version 3 of the License, or
20+
* (at your option) any later version.
21+
*
22+
* This program is distributed in the hope that it will be useful,
23+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
* GNU General Public License for more details.
26+
*
27+
* You should have received a copy of the GNU General Public License
28+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
*
30+
* -------------------------------------------------------------------------
31+
*/
32+
33+
use Glpi\Exception\Http\NotFoundHttpException;
34+
use GlpiPlugin\Carbon\MonitorModel;
35+
36+
include(__DIR__ . '/../../../inc/includes.php');
37+
38+
if (!Plugin::isPluginActive('carbon')) {
39+
throw new NotFoundHttpException();
40+
}
41+
42+
43+
Session::checkRight('config', UPDATE);
44+
45+
$item = new MonitorModel();
46+
47+
if (isset($_POST['update'])) {
48+
// Add a new Form
49+
Session::checkRight('entity', UPDATE);
50+
$item->update($_POST);
51+
Html::back();
52+
}
53+
54+
Html::back();
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* -------------------------------------------------------------------------
5+
* Carbon plugin for GLPI
6+
*
7+
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
8+
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
9+
* @link https://github.com/pluginsGLPI/carbon
10+
*
11+
* -------------------------------------------------------------------------
12+
*
13+
* LICENSE
14+
*
15+
* This file is part of Carbon plugin for GLPI.
16+
*
17+
* This program is free software: you can redistribute it and/or modify
18+
* it under the terms of the GNU General Public License as published by
19+
* the Free Software Foundation, either version 3 of the License, or
20+
* (at your option) any later version.
21+
*
22+
* This program is distributed in the hope that it will be useful,
23+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
* GNU General Public License for more details.
26+
*
27+
* You should have received a copy of the GNU General Public License
28+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
*
30+
* -------------------------------------------------------------------------
31+
*/
32+
33+
use Glpi\Exception\Http\NotFoundHttpException;
34+
use GlpiPlugin\Carbon\NetworkEquipmentModel;
35+
36+
include(__DIR__ . '/../../../inc/includes.php');
37+
38+
if (!Plugin::isPluginActive('carbon')) {
39+
throw new NotFoundHttpException();
40+
}
41+
42+
43+
Session::checkRight('config', UPDATE);
44+
45+
$item = new NetworkEquipmentModel();
46+
47+
if (isset($_POST['update'])) {
48+
// Add a new Form
49+
Session::checkRight('entity', UPDATE);
50+
$item->update($_POST);
51+
Html::back();
52+
}
53+
54+
Html::back();

install/mysql/plugin_carbon_empty.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_sources_zones` (
9191
UNIQUE KEY `unicity` (`plugin_carbon_sources_id`, `plugin_carbon_zones_id`)
9292
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
9393

94+
CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_computermodels` (
95+
`id` int unsigned NOT NULL AUTO_INCREMENT,
96+
`computermodels_id` int unsigned NOT NULL DEFAULT '0',
97+
`gwp` int DEFAULT '0' COMMENT '(unit gCO2eq) Global warming potential',
98+
`gwp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
99+
`gwp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
100+
`adp` int DEFAULT '0' COMMENT '(unit gSbEq) Abiotic depletion potential',
101+
`adp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
102+
`adp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
103+
`pe` int DEFAULT '0' COMMENT '(unit J) Primary energy',
104+
`pe_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
105+
`pe_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
106+
PRIMARY KEY (`id`),
107+
UNIQUE KEY `unicity` (`computermodels_id`)
108+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
109+
94110
CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_computertypes` (
95111
`id` int unsigned NOT NULL AUTO_INCREMENT,
96112
`computertypes_id` int unsigned NOT NULL DEFAULT '0',
@@ -140,6 +156,22 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_environmentalimpacts` (
140156
UNIQUE KEY `unicity` (`computers_id`)
141157
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
142158

159+
CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_monitormodels` (
160+
`id` int unsigned NOT NULL AUTO_INCREMENT,
161+
`monitormodels_id` int unsigned NOT NULL DEFAULT '0',
162+
`gwp` int DEFAULT '0' COMMENT '(unit gCO2eq) Global warming potential',
163+
`gwp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
164+
`gwp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
165+
`adp` int DEFAULT '0' COMMENT '(unit gSbEq) Abiotic depletion potential',
166+
`adp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
167+
`adp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
168+
`pe` int DEFAULT '0' COMMENT '(unit J) Primary energy',
169+
`pe_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
170+
`pe_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
171+
PRIMARY KEY (`id`),
172+
UNIQUE KEY `unicity` (`monitormodels_id`)
173+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
174+
143175
CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_monitortypes` (
144176
`id` int unsigned NOT NULL AUTO_INCREMENT,
145177
`monitortypes_id` int unsigned NOT NULL DEFAULT '0',
@@ -148,6 +180,22 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_monitortypes` (
148180
UNIQUE KEY `unicity` (`monitortypes_id`)
149181
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
150182

183+
CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_networkequipmentmodels` (
184+
`id` int unsigned NOT NULL AUTO_INCREMENT,
185+
`networkequipmentmodels_id` int unsigned NOT NULL DEFAULT '0',
186+
`gwp` int DEFAULT '0' COMMENT '(unit gCO2eq) Global warming potential',
187+
`gwp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
188+
`gwp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
189+
`adp` int DEFAULT '0' COMMENT '(unit gSbEq) Abiotic depletion potential',
190+
`adp_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
191+
`adp_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
192+
`pe` int DEFAULT '0' COMMENT '(unit J) Primary energy',
193+
`pe_source` mediumtext DEFAULT NULL COMMENT 'any information to describe the source, URL preferred',
194+
`pe_quality` int DEFAULT '0' COMMENT 'DataTtacking\\AbstractTracked::DATA_QUALITY_* constants',
195+
PRIMARY KEY (`id`),
196+
UNIQUE KEY `unicity` (`networkequipmentmodels_id`)
197+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
198+
151199
CREATE TABLE IF NOT EXISTS `glpi_plugin_carbon_networkequipmenttypes` (
152200
`id` int unsigned NOT NULL AUTO_INCREMENT,
153201
`networkequipmenttypes_id` int unsigned NOT NULL DEFAULT '0',

setup.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
use GlpiPlugin\Carbon\Location;
4444

4545
define('PLUGIN_CARBON_VERSION', '1.2.0-dev');
46-
define('PLUGIN_CARBON_SCHEMA_VERSION', '1.1.0');
46+
define('PLUGIN_CARBON_SCHEMA_VERSION', '1.2.0');
4747

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

145145
foreach (PLUGIN_CARBON_TYPES as $itemtype) {
146-
$item_type_class = 'GlpiPlugin\\Carbon\\' . $itemtype . 'Type';
147146
$core_type_class = $itemtype . 'Type';
147+
$item_type_class = 'GlpiPlugin\\Carbon\\' . $core_type_class;
148148
Plugin::registerClass($item_type_class, ['addtabon' => $core_type_class]);
149+
149150
Plugin::registerClass(UsageInfo::class, ['addtabon' => $itemtype]);
151+
152+
$core_model_class = $itemtype . 'Model';
153+
$item_model_class = 'GlpiPlugin\\Carbon\\' . $core_model_class;
154+
Plugin::registerClass($item_model_class, ['addtabon' => $core_model_class]);
150155
}
151156
}
152157

0 commit comments

Comments
 (0)