-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.php
85 lines (66 loc) · 2.74 KB
/
setup.php
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
<?php
define('PLUGIN_TRADEMARK_VERSION', '1.4.1');
// Minimal GLPI version, inclusive
define("PLUGIN_TRADEMARK_MIN_GLPI_VERSION", "10.0.0");
// Maximum GLPI version, exclusive
define("PLUGIN_TRADEMARK_MAX_GLPI_VERSION", "10.1.0");
$folder = basename(dirname(__FILE__));
if ($folder !== "trademark") {
$msg = sprintf("Please, rename the plugin folder \"%s\" to \"trademark\"", $folder);
Session::addMessageAfterRedirect($msg, true, ERROR);
}
// Init the hooks of the plugins -Needed
function plugin_init_trademark() {
global $PLUGIN_HOOKS, $CFG_GLPI;
$PLUGIN_HOOKS['csrf_compliant']['trademark'] = true;
Plugin::registerClass('PluginTrademarkConfig', ['addtabon' => 'Config']);
$PLUGIN_HOOKS['config_page']['trademark'] = 'front/config.form.php';
$plugin = new Plugin();
if ($plugin->isInstalled('trademark') && $plugin->isActivated('trademark')) {
$autoload = __DIR__ . '/vendor/autoload.php';
if (file_exists($autoload)) {
include_once $autoload;
};
Plugin::registerClass('PluginTrademarkConfig', [
'addtabon' => ['Config']
]);
$PLUGIN_HOOKS['display_login']['trademark'] = "plugin_trademark_display_login";
// Tip Trick to add version in css output
$PLUGIN_HOOKS["add_css"]['trademark'] = new PluginTrademarkFileVersion('front/internal.css.php');
$PLUGIN_HOOKS["add_javascript"]['trademark'] = new PluginTrademarkFileVersion('front/internal.js.php');
$CFG_GLPI['javascript']['config']['config'][] = 'codemirror';
$CFG_GLPI['javascript']['config']['config'][] = 'tinymce';
}
}
// Get the name and the version of the plugin - Needed
function plugin_version_trademark() {
return [
'name' => t_trademark('Trademark'),
'version' => PLUGIN_TRADEMARK_VERSION,
'author' => '<a href="https://librecode.coop/">LibreCode</a>, <a href="https://github.com/edgardmessias">Edgard</a>',
'homepage' => 'https://github.com/librecodecoop/trademark',
'license' => 'GPL v2+',
'minGlpiVersion' => PLUGIN_TRADEMARK_MIN_GLPI_VERSION,
'requirements' => [
'glpi' => [
'min' => PLUGIN_TRADEMARK_MIN_GLPI_VERSION,
'max' => PLUGIN_TRADEMARK_MAX_GLPI_VERSION,
]
]
];
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_trademark_check_prerequisites() {
if (version_compare(GLPI_VERSION, PLUGIN_TRADEMARK_MIN_GLPI_VERSION, 'lt')) {
echo "This plugin requires GLPI >= " . PLUGIN_TRADEMARK_MIN_GLPI_VERSION;
return false;
} else {
return true;
}
}
function plugin_trademark_check_config() {
return true;
}
function t_trademark($str) {
return __($str, 'trademark');
}