-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
103 lines (86 loc) · 2.82 KB
/
Copy pathsetup.php
File metadata and controls
103 lines (86 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Cloud Storage for GLPI
*
* Store GLPI documents in cloud storage (Azure Blob Storage, AWS S3).
* This plugin does NOT modify any GLPI core files.
*
* @license GPL-3.0-or-later
*/
use Glpi\Plugin\Hooks;
use GlpiPlugin\Cloudstorage\DocumentHook;
define('PLUGIN_CLOUDSTORAGE_VERSION', '2.0.0');
define('PLUGIN_CLOUDSTORAGE_MIN_GLPI_VERSION', '11.0.0');
define('PLUGIN_CLOUDSTORAGE_MAX_GLPI_VERSION', '11.0.99');
function plugin_version_cloudstorage(): array
{
return [
'name' => 'Cloud Storage',
'version' => PLUGIN_CLOUDSTORAGE_VERSION,
'author' => 'Rafael Farias',
'license' => 'GPLv3',
'homepage' => 'https://github.com/rafaelfariasbsb/glpi-cloud-storage',
'requirements' => [
'glpi' => [
'min' => PLUGIN_CLOUDSTORAGE_MIN_GLPI_VERSION,
'max' => PLUGIN_CLOUDSTORAGE_MAX_GLPI_VERSION,
],
'php' => [
'min' => '8.2',
],
],
];
}
function plugin_cloudstorage_check_prerequisites(): bool
{
$autoload = __DIR__ . '/vendor/autoload.php';
if (!file_exists($autoload)) {
Session::addMessageAfterRedirect(
__('Cloud Storage plugin requires composer dependencies. Run "composer install" in the plugin directory.'),
false,
ERROR
);
return false;
}
return true;
}
function plugin_cloudstorage_check_config($verbose = false): bool
{
return true;
}
function plugin_init_cloudstorage(): void
{
global $PLUGIN_HOOKS;
// CSRF compliance declaration (mandatory for GLPI marketplace)
$PLUGIN_HOOKS[Hooks::CSRF_COMPLIANT]['cloudstorage'] = true;
$plugin = new Plugin();
if (!$plugin->isActivated('cloudstorage')) {
return;
}
// Load composer autoload for Flysystem/Cloud SDKs
$autoload = __DIR__ . '/vendor/autoload.php';
if (file_exists($autoload)) {
require_once $autoload;
}
// Config page
$PLUGIN_HOOKS[Hooks::CONFIG_PAGE]['cloudstorage'] = 'front/config.php';
// Encrypt sensitive config values
$PLUGIN_HOOKS[Hooks::SECURED_CONFIGS]['cloudstorage'] = [
'azure_connection_string',
'azure_account_key',
's3_access_key_id',
's3_secret_access_key',
];
// Document lifecycle hooks
$PLUGIN_HOOKS[Hooks::ITEM_ADD]['cloudstorage'] = [
'Document' => [DocumentHook::class, 'onItemAdd'],
];
$PLUGIN_HOOKS[Hooks::ITEM_UPDATE]['cloudstorage'] = [
'Document' => [DocumentHook::class, 'onItemUpdate'],
];
$PLUGIN_HOOKS[Hooks::PRE_ITEM_PURGE]['cloudstorage'] = [
'Document' => [DocumentHook::class, 'onPreItemPurge'],
];
// JavaScript for URL rewriting.
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['cloudstorage'] = ['js/url-rewriter.js'];
}