Ajouter le fichier hook.php et corriger l'installation

This commit is contained in:
tips-of-mine
2025-05-31 11:05:58 +02:00
committed by GitHub
parent c428a4271b
commit 2f73a61861
3 changed files with 154 additions and 3 deletions

View File

@ -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:

74
hook.php Normal file
View File

@ -0,0 +1,74 @@
<?php
/**
* Hook functions for the SOC plugin
*/
/**
* Hook called after a new item has been added
*
* @param CommonDBTM $item
* @return void
*/
function plugin_soc_item_add(CommonDBTM $item) {
// Add actions when a new item is created
}
/**
* Hook called after an item has been updated
*
* @param CommonDBTM $item
* @return void
*/
function plugin_soc_item_update(CommonDBTM $item) {
// Add actions when an item is updated
}
/**
* Hook called after an item has been deleted
*
* @param CommonDBTM $item
* @return void
*/
function plugin_soc_item_delete(CommonDBTM $item) {
// Add actions when an item is deleted
}
/**
* Hook called after an item has been purged
*
* @param CommonDBTM $item
* @return void
*/
function plugin_soc_item_purge(CommonDBTM $item) {
// Add actions when an item is purged
}
/**
* Hook called when displaying the tabs for an item
*
* @param array $params
* @return array
*/
function plugin_soc_getAddSearchOptions($itemtype) {
$options = [];
// Add search options for supported item types
if ($itemtype == 'Ticket' || $itemtype == 'Change') {
$options[9000] = [
'table' => '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;
}

View File

@ -98,3 +98,71 @@ function plugin_soc_uninstall() {
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;
}