From 2f73a61861e2d9d1a8f804480d952320710ad362 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:05:58 +0200 Subject: [PATCH] Ajouter le fichier hook.php et corriger l'installation --- README.md | 15 ++++++++--- hook.php | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 hook.php diff --git a/README.md b/README.md index 2a9ff07..3da8325 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,18 @@ This plugin provides a specialized case management system for Security Operation ## Installation 1. Download the ZIP file 2. Extract it in your GLPI plugins directory (`glpi/plugins/`) -3. Rename the directory to "soc" if needed -4. Navigate to Setup > Plugins in your GLPI web interface -5. Install and activate the plugin +3. Rename the directory to "soc" (this is important - the folder must be named "soc") +4. Make sure all files have correct permissions (www-data or apache user should be able to read them) +5. Navigate to Setup > Plugins in your GLPI web interface +6. Install and activate the plugin + +## Troubleshooting Installation +If the plugin doesn't appear in the plugins list: +- Verify the plugin folder is named exactly "soc" (not "SOC" or "soc-plugin") +- Check file permissions (files should be readable by the web server) +- Check that all required files are present: setup.php, hook.php, plugin.php +- Clear GLPI cache by removing files in `/glpi/files/_cache` +- Restart your web server ## Configuration After activation, you can configure the plugin by: diff --git a/hook.php b/hook.php new file mode 100644 index 0000000..a1b1f4d --- /dev/null +++ b/hook.php @@ -0,0 +1,74 @@ + 'glpi_plugin_soc_cases', + 'field' => 'name', + 'name' => __('SOC Case', 'soc'), + 'joinparams' => [ + 'beforejoin' => [ + 'table' => $itemtype == 'Ticket' ? 'glpi_plugin_soc_case_tickets' : 'glpi_plugin_soc_case_changes', + 'joinparams' => [ + 'jointype' => 'itemtype_item', + 'specific_itemtype' => $itemtype + ] + ] + ] + ]; + } + + return $options; +} \ No newline at end of file diff --git a/setup.php b/setup.php index 033e7c0..c3c6e29 100644 --- a/setup.php +++ b/setup.php @@ -97,4 +97,72 @@ function plugin_soc_uninstall() { $DB->query($query) or die("Error deleting plugin_soc display preferences"); return true; +} + +/** + * Define hooks + */ +function plugin_init_soc() { + global $PLUGIN_HOOKS; + + // Add plugin hooks here +} + +/** + * Define database relations + */ +function plugin_soc_getDatabaseRelations() { + return [ + 'glpi_entities' => [ + 'glpi_plugin_soc_cases' => 'entities_id' + ], + 'glpi_users' => [ + 'glpi_plugin_soc_cases' => 'users_id_tech' + ], + 'glpi_groups' => [ + 'glpi_plugin_soc_cases' => 'groups_id_tech' + ], + 'glpi_tickets' => [ + 'glpi_plugin_soc_case_tickets' => 'tickets_id' + ], + 'glpi_changes' => [ + 'glpi_plugin_soc_case_changes' => 'changes_id' + ], + 'glpi_plugin_soc_cases' => [ + 'glpi_plugin_soc_case_tickets' => 'plugin_soc_cases_id', + 'glpi_plugin_soc_case_changes' => 'plugin_soc_cases_id' + ] + ]; +} + +/** + * Define display preferences + */ +function plugin_soc_getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { + $tabs = []; + + if ($item->getType() == 'Ticket' && Session::haveRight("plugin_soc_case", READ)) { + $tabs[1] = __('SOC Cases', 'soc'); + } + + if ($item->getType() == 'Change' && Session::haveRight("plugin_soc_case", READ)) { + $tabs[1] = __('SOC Cases', 'soc'); + } + + return $tabs; +} + +/** + * Define right names + */ +function plugin_soc_getRights($itemtype = '') { + $rights = [ + [ + 'itemtype' => 'PluginSocCase', + 'label' => __('SOC Case', 'soc'), + 'field' => 'plugin_soc_case' + ] + ]; + + return $rights; } \ No newline at end of file