Add GenericObject plugin files and assets

- Introduced default icon images in PNG and SVG formats.
- Added example icons for car and cube in SVG format.
- Created setup file for the GenericObject plugin with versioning and directory definitions.
- Included a header file with licensing information for the plugin.
- Added a remove.txt file with instructions for safe deletion.
This commit is contained in:
2025-11-11 13:52:20 +01:00
parent 5c733eac6b
commit f33121a308
125 changed files with 13188 additions and 32 deletions

View File

@ -0,0 +1,44 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (isset($_REQUEST['itemtype'])) {
$itemtype = $_REQUEST['itemtype'];
if (class_exists($itemtype)) {
$dropdown = new $itemtype();
include (GLPI_ROOT . "/front/dropdown.common.form.php");
} else {
Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
}
} else {
Html::displayErrorAndDie(__('Not Found!'));
}

View File

@ -0,0 +1,46 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (isset($_REQUEST['itemtype'])) {
$itemtype = $_REQUEST['itemtype'];
if (class_exists($itemtype)) {
$dropdown = new $itemtype();
include (GLPI_ROOT . "/front/dropdown.common.php");
} else {
Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
}
} else {
Html::displayErrorAndDie(__('Not Found!'));
}

View File

@ -0,0 +1,44 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (isset($_REQUEST['itemtype'])) {
$itemtype = $_REQUEST['itemtype'];
if (class_exists($itemtype)) {
$dropdown = new $itemtype();
include (GLPI_ROOT . "/front/dropdown.common.form.php");
} else {
Html::displayErrorAndDie(__('The requested dropdown does not exists', 'genericobject'));
}
} else {
Html::displayErrorAndDie(__('Not Found!'));
}

View File

@ -0,0 +1,32 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
include ("./commondropdown.php");

View File

@ -0,0 +1,60 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ('../../../inc/includes.php');
$family = new PluginGenericobjectTypeFamily();
if (!isset($_GET['id']) || !$family->getFromDB($_GET['id'])) {
Html::header(__("Objects management", "genericobject"), $_SERVER['PHP_SELF'], "assets",
"genericobject");
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th>".__("Empty family", "genericobject")."</th></tr>";
echo "</table>";
} else {
$family->getFromDB($_GET['id']);
Html::header(__("Objects management", "genericobject"), $_SERVER['PHP_SELF'], "assets",
$family->getName());
echo "<table class='tab_cadre_fixe'>";
$types = PluginGenericobjectTypeFamily::getItemtypesByFamily($_GET['id']);
echo "<tr class='tab_bg_2'><th>".Dropdown::getDropdownName("glpi_plugin_genericobject_typefamilies", $_GET['id'])."</th></tr>";
foreach ($types as $type) {
$itemtype = $type['itemtype'];
echo "<tr class='tab_bg_1'><td align='center'>";
echo "<a href='".$itemtype::getSearchURL()."'>";
echo $itemtype::getTypeName();
echo "</a></td></tr>";
}
echo "</table>";
}
Html::footer();

View File

@ -0,0 +1,62 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (isset ($_POST["delete"])) {
if (isset($_POST["fields"]) && count($_POST["fields"] > 0 )) {
$type = new PluginGenericobjectType();
$type->getFromDB($_POST["id"]);
$itemtype = $type->fields['itemtype'];
PluginGenericobjectType::registerOneType($itemtype);
foreach ($_POST["fields"] as $field => $value) {
if ($type->can($_POST["id"], PURGE)
&& $value == 1
&& PluginGenericobjectField::checkNecessaryFieldsDelete($itemtype, $field)) {
PluginGenericobjectField::deleteField(getTableForItemType($itemtype), $field);
Session::addMessageAfterRedirect(__("Field(s) deleted successfully", "genericobject"), true, INFO);
}
}
}
} else if (isset ($_POST["add_field"])) {
$type = new PluginGenericobjectType();
if ($_POST["new_field"] && $type->can($_POST["id"], UPDATE)) {
$itemtype = $type->fields['itemtype'];
PluginGenericobjectType::registerOneType($itemtype);
PluginGenericobjectField::addNewField(getTableForItemType($itemtype), $_POST["new_field"]);
Session::addMessageAfterRedirect(__("Field added successfully", "genericobject"));
}
} else if (isset($_POST['action'])) {
//Move field
PluginGenericobjectField::changeFieldOrder($_POST);
}
Html::back();

View File

@ -0,0 +1,112 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
$itemtype = null;
if (isset($_REQUEST['itemtype'])) {
$types = array_keys(PluginGenericobjectType::getTypes());
$requested_type = $_REQUEST['itemtype'];
$error = [];
if (!in_array($requested_type, $types)) {
$error[] = __('The requested type has not been defined yet!');
if (!PluginGenericobjectType::canCreate()) {
$error[] = __('Please ask your administrator to create this type of object');
};
} else if (!class_exists($requested_type)) {
$error[]= __('The generated files for the requested type of object are missing!');
$error[]= __('You might need to regenerate the files under '.GENERICOBJECT_DOC_DIR.'.');
}
if (count($error) > 0) {
Html::header(__('Type not found!'));
Html::displayErrorAndDie(implode('<br/>', $error));
} else {
$itemtype = $requested_type;
}
}
if (!is_null($itemtype)) {
if (!isset($_REQUEST['id'])) {
$id = -1;
} else {
$id = $_REQUEST['id'];
}
if (!isset($_GET["withtemplate"])) {
$_GET["withtemplate"] = "";
}
$item = new $itemtype();
if (isset ($_POST["add"])) {
$item->check($id, CREATE);
$newID = $item->add($_POST);
if ($_SESSION['glpibackcreated']) {
Html::redirect($itemtype::getFormURL()."&id=".$newID);
} else {
Html::back();
}
} else if (isset ($_POST["update"])) {
$item->check($id, UPDATE);
$item->update($_POST);
Html::back();
} else if (isset ($_POST["restore"])) {
$item->check($id, DELETE);
$item->restore($_POST);
Html::back();
} else if (isset($_POST["purge"])) {
$item->check($id, PURGE);
$item->delete($_POST, 1);
$item->redirectToList();
} else if (isset($_POST["delete"])) {
$item->check($id, DELETE);
$item->delete($_POST);
$item->redirectToList();
}
$menu = PluginGenericobjectType::getFamilyNameByItemtype($_GET['itemtype']);
Html::header($itemtype::getTypeName(), $_SERVER['PHP_SELF'],
"assets", ($menu!==false?$menu:$itemtype), strtolower($itemtype));
$item->display($_GET, ['withtemplate' => $_GET["withtemplate"]]);
Html::footer();
} else {
Html::header(__('Access Denied!'));
Html::DisplayErrorAndDie(__("You can't access to this page directly!"));
}

View File

@ -0,0 +1,42 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (isset($_GET['itemtype'])) {
Session::checkRight(PluginGenericobjectProfile::getProfileNameForItemtype($_GET['itemtype']), READ);
$menu = PluginGenericobjectType::getFamilyNameByItemtype($_GET['itemtype']);
Html::header(__("Type of objects", "genericobject"),
$_SERVER['PHP_SELF'], "assets", ($menu!==false?$menu:strtolower($_GET['itemtype'])), strtolower($_GET['itemtype']));
Search::Show($_GET['itemtype']);
}
Html::footer();

View File

@ -0,0 +1,54 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
Session::checkRight("profile", UPDATE);
_log($_POST);
$prof = new Profile();
/* save profile */
if (isset($_POST['update_all_rights']) && isset($_POST['itemtype'])) {
$profiles = [];
foreach ($_POST as $key => $val) {
if (preg_match("/^profile_/", $key)) {
$id = preg_replace("/^profile_/", "", $key);
$profiles[$id] = [
"id" => $id,
"_".PluginGenericobjectProfile::getProfileNameForItemtype($_POST['itemtype']) => $val
];
}
}
_log($profiles);
foreach ($profiles as $profile_id => $input) {
$prof->update($input);
}
}
Html::redirect($_SERVER['HTTP_REFERER']);

View File

@ -0,0 +1,80 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (!isset ($_GET["id"])) {
$_GET["id"] = '';
}
$type = new PluginGenericobjectType();
$extraparams = [];
if (isset ($_POST["select"]) && $_POST["select"] == "all") {
$extraparams["selected"] = "checked";
}
//Change fields order
if (isset ($_GET["action"])) {
$type->getFromDB($_REQUEST["id"]);
PluginGenericobjectType::registerOneType($type);
PluginGenericobjectObject::changeFieldOrder($_GET["field"], $type->fields["itemtype"],
$_GET["action"]);
Html::back();
} else if (isset ($_POST["add"])) {
//Add a new itemtype
$new_id = $type->add($_POST);
Html::redirect(Toolbox::getItemTypeFormURL('PluginGenericobjectType')."?id=$new_id");
} else if (isset ($_POST["update"])) {
//Update an existing itemtype
if (isset($_POST['itemtypes']) && is_array($_POST['itemtypes'])) {
$_POST['linked_itemtypes'] = json_encode($_POST['itemtypes']);
}
$type->update($_POST);
Html::back();
} else if (isset ($_POST["purge"])) {
//Delete an itemtype
$type->delete($_POST);
$type->redirectToList();
} else if (isset($_POST['regenerate'])) {
//Regenerate files for an itemtype
$type->getFromDB($_POST["id"]);
PluginGenericobjectType::checkClassAndFilesForOneItemType($type->fields['itemtype'],
$type->fields['name'], true);
Html::back();
}
Html::header(__("Objects management", "genericobject"), $_SERVER['PHP_SELF'], "config",
"PluginGenericobjectType");
$type->display($_GET);
Html::footer();

View File

@ -0,0 +1,48 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
if (isset($_GET['itemtype'])
&& !isset($_GET['search'])
&& !isset($_GET['sort'])) {
$type = new PluginGenericobjectType();
$type->getFromDBByType($_GET['itemtype']);
Html::redirect(Toolbox::getItemTypeFormURL('PluginGenericobjectType').'?id='.$type->getID());
} else if (Session::haveRightsOr('plugin_genericobject_types', [READ, CREATE, UPDATE, PURGE])) {
Html::header(__("Type of objects", "genericobject"), $_SERVER['PHP_SELF'], "config",
"PluginGenericobjectType");
Search::Show('PluginGenericobjectType');
Html::footer();
} else {
Html::redirect($CFG_GLPI['root_doc']."/front/central.php");
}

View File

@ -0,0 +1,35 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
$dropdown = new PluginGenericobjectTypeFamily();
include (GLPI_ROOT . "/front/dropdown.common.form.php");

View File

@ -0,0 +1,35 @@
<?php
/**
* -------------------------------------------------------------------------
* GenericObject plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GenericObject.
*
* GenericObject 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.
*
* GenericObject 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 GenericObject. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2009-2022 by GenericObject plugin team.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/pluginsGLPI/genericobject
* -------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
$dropdown = new PluginGenericobjectTypeFamily();
include (GLPI_ROOT . "/front/dropdown.common.php");