config.form.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /*
  3. * @version $Id: config.form.php 234 2019-12-12 14:34:31Z yllen $
  4. -------------------------------------------------------------------------
  5. LICENSE
  6. This file is part of Archires plugin for GLPI.
  7. Archires is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU Affero General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11. Archires is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with Archires. If not, see <http://www.gnu.org/licenses/>.
  17. @package archires
  18. @author Nelly Mahu-Lasson, Xavier Caillaud
  19. @copyright Copyright (c) 2016-2021 Archires plugin team
  20. @license AGPL License 3.0 or (at your option) any later version
  21. http://www.gnu.org/licenses/agpl-3.0-standalone.html
  22. @link https://forge.glpi-project.org/projects/archires
  23. @since version 2.2
  24. --------------------------------------------------------------------------
  25. */
  26. if (!defined('GLPI_ROOT')) {
  27. include ("../../../inc/includes.php");
  28. }
  29. $plugin = new Plugin();
  30. if ($plugin->isActivated("archires")) {
  31. Session::checkRight("config", UPDATE);
  32. $PluginArchiresImageItem = new PluginArchiresImageItem();
  33. $PluginArchiresNetworkInterfaceColor = new PluginArchiresNetworkInterfaceColor();
  34. $PluginArchiresVlanColor = new PluginArchiresVlanColor();
  35. $PluginArchiresStateColor = new PluginArchiresStateColor();
  36. if (isset($_POST["add"]) && isset($_POST['_itemtype'])) {
  37. if ($PluginArchiresImageItem->canCreate()) {
  38. $PluginArchiresImageItem->addItemImage($_POST['type'], $_POST['_itemtype'],
  39. $_POST['img']);
  40. }
  41. Html::back();
  42. } else if (isset($_POST["delete"])) {
  43. Session::checkRight("config", UPDATE);
  44. $PluginArchiresImageItem->getFromDB($_POST["id"],-1);
  45. foreach ($_POST["item"] as $key => $val) {
  46. if ($val == 1) {
  47. $PluginArchiresImageItem->delete(['id' => $key]);
  48. }
  49. }
  50. Html::back();
  51. } else if (isset($_POST["add_color_networkinterface"])
  52. && isset($_POST['networkinterfaces_id'])) {
  53. if ($PluginArchiresNetworkInterfaceColor->canCreate()) {
  54. $PluginArchiresNetworkInterfaceColor->addNetworkInterfaceColor($_POST['networkinterfaces_id'],
  55. $_POST['color']);
  56. }
  57. Html::back();
  58. } else if (isset($_POST["delete_color_networkinterface"])) {
  59. Session::checkRight("config", UPDATE);
  60. $PluginArchiresNetworkInterfaceColor->getFromDB($_POST["id"],-1);
  61. foreach ($_POST["item_color"] as $key => $val) {
  62. if ($val == 1) {
  63. $PluginArchiresNetworkInterfaceColor->delete(['id' => $key]);
  64. }
  65. }
  66. Html::back();
  67. } else if (isset($_POST["add_color_state"]) && isset($_POST['states_id'])) {
  68. if ($PluginArchiresStateColor->canCreate()) {
  69. $PluginArchiresStateColor->addStateColor($_POST['states_id'],$_POST['color']);
  70. }
  71. Html::back();
  72. } else if (isset($_POST["delete_color_state"])) {
  73. Session::checkRight("config", UPDATE);
  74. $PluginArchiresStateColor->getFromDB($_POST["id"],-1);
  75. foreach ($_POST["item_color"] as $key => $val) {
  76. if ($val == 1) {
  77. $PluginArchiresStateColor->delete(['id' => $key]);
  78. }
  79. }
  80. Html::back();
  81. } else if (isset($_POST["add_color_vlan"]) && isset($_POST['vlans_id'])) {
  82. if ($PluginArchiresVlanColor->canCreate()) {
  83. $PluginArchiresVlanColor->addVlanColor($_POST['vlans_id'],$_POST['color']);
  84. }
  85. Html::back();
  86. } else if (isset($_POST["delete_color_vlan"])) {
  87. Session::checkRight("config", UPDATE);
  88. $PluginArchiresVlanColor->getFromDB($_POST["id"],-1);
  89. foreach ($_POST["item_color"] as $key => $val) {
  90. if ($val == 1) {
  91. $PluginArchiresVlanColor->delete(['id' => $key]);
  92. }
  93. }
  94. Html::back();
  95. } else {
  96. Html::header(PluginArchiresArchires::getTypeName(), '', "tools", "pluginarchiresmenu");
  97. $PluginArchiresImageItem->showConfigForm();
  98. $PluginArchiresNetworkInterfaceColor->showConfigForm(true);
  99. $PluginArchiresVlanColor->showConfigForm(true);
  100. $PluginArchiresStateColor->showConfigForm(true);
  101. Html::footer();
  102. }
  103. } else {
  104. Html::header(__('Setup'), '', "config", "plugins");
  105. echo "<div class='center'><br><br>".
  106. "<img src=\"".$CFG_GLPI["root_doc"]."/pics/warning.png\" alt='warning'><br><br>";
  107. echo "<b>".__('Please activate the plugin','addressing')."</b></div>";
  108. Html::footer();
  109. }