From 99d308a3719882c0563b2197d90b719e2c7ea118 Mon Sep 17 00:00:00 2001 From: tips-of-mine <54597409+tips-of-mine@users.noreply.github.com> Date: Sat, 31 May 2025 11:31:43 +0200 Subject: [PATCH] Fix plugin structure for proper GLPI detection --- front/rule.form.php | 88 +++++++++++++++++++++++++++++++++++++++++++++ front/rule.php | 20 +++++++++++ plugin.xml | 4 +-- 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 front/rule.form.php create mode 100644 front/rule.php diff --git a/front/rule.form.php b/front/rule.form.php new file mode 100644 index 0000000..57df067 --- /dev/null +++ b/front/rule.form.php @@ -0,0 +1,88 @@ +check(-1, CREATE, $_POST); + if ($rule->add($_POST)) { + Event::log( + $rule->fields['id'], + "plugin_cve_rule", + 4, + "inventory", + sprintf(__('%1$s adds the rule %2$s'), $_SESSION["glpiname"], $_POST["name"]) + ); + } + Html::back(); +} else if (isset($_POST["delete"])) { + $rule->check($_POST["id"], DELETE); + if ($rule->delete($_POST)) { + Event::log( + $_POST["id"], + "plugin_cve_rule", + 4, + "inventory", + sprintf(__('%1$s deletes the rule %2$s'), $_SESSION["glpiname"], $_POST["id"]) + ); + } + $rule->redirectToList(); +} else if (isset($_POST["restore"])) { + $rule->check($_POST["id"], DELETE); + if ($rule->restore($_POST)) { + Event::log( + $_POST["id"], + "plugin_cve_rule", + 4, + "inventory", + sprintf(__('%1$s restores the rule %2$s'), $_SESSION["glpiname"], $_POST["id"]) + ); + } + $rule->redirectToList(); +} else if (isset($_POST["purge"])) { + $rule->check($_POST["id"], PURGE); + if ($rule->delete($_POST, 1)) { + Event::log( + $_POST["id"], + "plugin_cve_rule", + 4, + "inventory", + sprintf(__('%1$s purges the rule %2$s'), $_SESSION["glpiname"], $_POST["id"]) + ); + } + $rule->redirectToList(); +} else if (isset($_POST["update"])) { + $rule->check($_POST["id"], UPDATE); + if ($rule->update($_POST)) { + Event::log( + $_POST["id"], + "plugin_cve_rule", + 4, + "inventory", + sprintf(__('%1$s updates the rule %2$s'), $_SESSION["glpiname"], $_POST["id"]) + ); + } + Html::back(); +} else { + Html::header( + PluginCveCveRule::getTypeName(Session::getPluralNumber()), + $_SERVER['PHP_SELF'], + "tools", + "PluginCveCveMenu", + "cverule" + ); + + $id = 0; + if (isset($_GET["id"])) { + $id = $_GET["id"]; + } + + $rule->display(['id' => $id]); + Html::footer(); +} \ No newline at end of file diff --git a/front/rule.php b/front/rule.php new file mode 100644 index 0000000..71cbbb9 --- /dev/null +++ b/front/rule.php @@ -0,0 +1,20 @@ + 0.0.1 - ~10.0.18 - https://github.com/tips-of-mine/GLPI-Plugin-CVE-Prototype/releases/download/0.0.1/cve-0.0.1.tar.gz + ~10.0 + https://github.com/tips-of-mine/GLPI-Plugin-CVE-Prototype/releases/download/0.0.1/cve-prototype-0.0.1.tar.gz