This repository has been archived by the owner on May 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.php
144 lines (122 loc) · 4.99 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* LICENSE
*
* This file is part of Flyve MDM Demo Plugin for GLPI,
* a subproject of Flyve MDM.
*
* Flyve MDM Demo Plugin for GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Flyve MDM Demo Plugin for GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* ------------------------------------------------------------------------------
* @author Thierry Bugier - <tbugier@teclib.com>
* @copyright Copyright © 2017 - 2018 Teclib
* @license AGPLv3 https://www.gnu.org/licenses/agpl-3.0.html
* @link https://github.com/flyve-mdm/demo-mode
* @link https://flyve-mdm.com/
* ------------------------------------------------------------------------------
*/
define('PLUGIN_FLYVEMDMDEMO_VERSION', '1.0.0-dev');
// is or is not an official release of the plugin
define('PLUGIN_FLYVEMDMDEMO_IS_OFFICIAL_RELEASE', false);
// Minimal GLPI version, inclusive
define('PLUGIN_FLYVEMDMDEMO_GLPI_MIN_VERSION', '9.2');
// Maximum GLPI version, exclusive
define('PLUGIN_FLYVEMDMDEMO_GLPI_MAX_VERSION', '9.3');
// Minimum PHP version inclusive
define('PLUGIN_FLYVEMDMDEMO_PHP_MIN_VERSION', '5.5');
// Init the hooks of the plugins -Needed
function plugin_init_flyvemdmdemo() {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['csrf_compliant']['flyvemdmdemo'] = true;
$plugin = new Plugin();
if (!$plugin->isActivated('flyvemdm')) {
return;
}
if ($plugin->isActivated('flyvemdmdemo')) {
include_once __DIR__ . '/vendor/autoload.php';
plugin_flyvemdmdemo_registerClasses();
plugin_flyvemdmdemo_addHooks();
}
}
function plugin_flyvemdmdemo_registerClasses() {
Plugin::registerClass(
PluginFlyvemdmdemoAccountvalidation::class, [
'notificationtemplates_types' => true, // 'document_types' => true
]
);
Plugin::registerClass(PluginFlyvemdmdemoProfile::class,
['addtabon' => Profile::class]);
}
function plugin_flyvemdmdemo_addHooks() {
global $PLUGIN_HOOKS;
$PLUGIN_HOOKS['post_init']['flyvemdmdemo'] = 'plugin_flyvemdmdemo_postinit';
// Notifications
$PLUGIN_HOOKS['item_get_events']['flyvemdmdemo'] =
[PluginFlyvemdmdemoNotificationTargetAccountvalidation::class =>
[PluginFlyvemdmdemoNotificationTargetAccountvalidation::class, 'addEvents']];
$PLUGIN_HOOKS['item_get_datas']['flyvemdmdemo'] =
[PluginFlyvemdmdemoNotificationTargetAccountvalidation::class =>
[PluginFlyvemdmdemoNotificationTargetAccountvalidation::class, 'getAdditionalDatasForTemplate']];
if (Session::haveRight(PluginFlyvemdmProfile::$rightname, PluginFlyvemdmProfile::RIGHT_FLYVEMDM_USE)) {
$PLUGIN_HOOKS['config_page']['flyvemdmdemo'] = 'front/config.form.php';
}
// Hooks for the plugin : objects inherited from GLPI
$PLUGIN_HOOKS['pre_item_add']['flyvemdmdemo'] = [
User::class => 'plugin_flyvemdmdemo_hook_pre_entity_add',
];
$PLUGIN_HOOKS['pre_item_purge']['flyvemdmdemo'] = [
PluginFlyvemdmFleet::class => 'plugin_flyvemdmdemo_pre_fleet_purge',
];
$PLUGIN_HOOKS['item_purge']['flyvemdm'] = [
User::class => [PluginFlyvemdmDemoUser::class, 'hook_pre_user_purge'],
];
}
// Get the name and the version of the plugin - Needed
function plugin_version_flyvemdmdemo() {
$author = "<a href='http://www.teclib.com'>Teclib</a>";
if (defined('GLPI_PREVER') && PLUGIN_FLYVEMDMDEMO_IS_OFFICIAL_RELEASE == false) {
$glpiVersion = version_compare(GLPI_PREVER, PLUGIN_FLYVEMDMDEMO_GLPI_MIN_VERSION, 'lt');
} else {
$glpiVersion = PLUGIN_FLYVEMDMDEMO_GLPI_MIN_VERSION;
}
return [
'name' => __s('Flyve MDM Demo', 'flyvemdmdemo'),
'version' => PLUGIN_FLYVEMDMDEMO_VERSION,
'author' => $author,
'license' => 'AGPLv3+',
'homepage' => '',
'minGlpiVersion' => $glpiVersion,
'requirements' => [
'glpi' => [
'min' => $glpiVersion,
'max' => '9.3',
'dev' => PLUGIN_FLYVEMDMDEMO_IS_OFFICIAL_RELEASE == false,
'plugins' => [
'flyvemdm',
],
],
'php' => [
'min' => PLUGIN_FLYVEMDMDEMO_PHP_MIN_VERSION,
]
]
];
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_flyvemdmdemo_check_prerequisites() {
$prerequisitesSuccess = true;
if (!is_readable(__DIR__ . '/vendor/autoload.php') || !is_file(__DIR__ . '/vendor/autoload.php')) {
echo "Run composer install --no-dev in the plugin directory<br>";
$prerequisitesSuccess = false;
}
return $prerequisitesSuccess;
}
function plugin_flyvemdmdemo_check_config() {
return true;
}