mirror of
https://github.com/tips-of-mine/GLPI-Plugin-SOC-Case-Management.git
synced 2025-06-28 05:38:42 +02:00
Merge pull request #1 from tips-of-mine/fix/plugin-registration
Fix: Implement missing GLPI plugin registration functions
This commit is contained in:
114
setup.php
114
setup.php
@ -1,4 +1,118 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Get plugin version information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function plugin_version() {
|
||||
$xml = simplexml_load_file(__DIR__ . '/plugin.xml');
|
||||
|
||||
if ($xml === false) {
|
||||
// Handle error: plugin.xml not found or unreadable
|
||||
return []; // Or throw an exception
|
||||
}
|
||||
|
||||
$authors = [];
|
||||
if (isset($xml->authors) && isset($xml->authors->author)) {
|
||||
foreach ($xml->authors->author as $author) {
|
||||
$authors[] = (string)$author->name . (isset($author->email) ? ' <' . (string)$author->email . '>' : '');
|
||||
}
|
||||
}
|
||||
|
||||
$versions = [];
|
||||
if (isset($xml->versions) && isset($xml->versions->version)) {
|
||||
foreach ($xml->versions->version as $version) {
|
||||
$versions[] = [
|
||||
'num' => (string)$version->num,
|
||||
'minGlpiVersion' => (string)$version->compatibility, // GLPI expects minGlpiVersion
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$langs = [];
|
||||
if (isset($xml->langs) && isset($xml->langs->lang)) {
|
||||
foreach ($xml->langs->lang as $lang) {
|
||||
$langs[] = (string)$lang;
|
||||
}
|
||||
}
|
||||
|
||||
$tags = [];
|
||||
if (isset($xml->tags)) {
|
||||
foreach ($xml->tags->children() as $lang_code => $tag_list) {
|
||||
$current_tags = [];
|
||||
foreach ($tag_list->tag as $tag) {
|
||||
$current_tags[] = (string)$tag;
|
||||
}
|
||||
$tags[$lang_code] = $current_tags;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'name' => (string)$xml->name,
|
||||
'key' => (string)$xml->key,
|
||||
'state' => (string)$xml->state,
|
||||
'logo' => (string)$xml->logo,
|
||||
'shortdesc' => (string)$xml->description_short, // GLPI expects shortdesc
|
||||
'longdesc' => (string)$xml->description_long, // GLPI expects longdesc
|
||||
'homepage' => (string)$xml->homepage,
|
||||
'download' => (string)$xml->download,
|
||||
'issues_tracker' => (string)$xml->issues, // GLPI expects issues_tracker
|
||||
'readme' => (string)$xml->readme,
|
||||
'authors' => $authors,
|
||||
'versions' => $versions,
|
||||
'langs' => $langs,
|
||||
'license' => (string)$xml->license,
|
||||
'tags' => $tags,
|
||||
'minGlpiVersion' => !empty($versions) ? $versions[count($versions)-1]['minGlpiVersion'] : '' // Default to last version's compatibility
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize plugin options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function plugin_init_options() {
|
||||
return [
|
||||
'name' => __('SOC Case Management', 'soc'),
|
||||
'key' => 'soc',
|
||||
'tooltip' => __('SOC Case Management integration plugin for security teams.', 'soc'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check plugin prerequisites.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function plugin_check_prerequisites() {
|
||||
// For now, always return true
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check plugin configuration.
|
||||
*
|
||||
* @param boolean $verbose Enable verbose mode (default false)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function plugin_check_config($verbose = false) {
|
||||
// For now, always return true
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display plugin configuration page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function plugin_display_config() {
|
||||
// Currently does nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the hooks of the plugin
|
||||
*
|
||||
|
Reference in New Issue
Block a user