35
35
----------------------------------------------------------------------
36
36
*/
37
37
38
- define ('PLUGIN_GENERICOBJECT_VERSION ' , '2.5.1 ' );
38
+ define ('PLUGIN_GENERICOBJECT_VERSION ' , '2.5.2 ' );
39
+
40
+ // Minimal GLPI version, inclusive
41
+ define ("PLUGIN_GENERICOBJECT_MIN_GLPI " , "9.2 " );
42
+ // Maximum GLPI version, exclusive
43
+ define ("PLUGIN_GENERICOBJECT_MAX_GLPI " , "9.3 " );
39
44
40
45
if (!defined ("GENERICOBJECT_DIR " )) {
41
46
define ("GENERICOBJECT_DIR " , GLPI_ROOT . "/plugins/genericobject " );
89
94
}
90
95
91
96
// Autoload class generated in files/_plugins/genericobject/inc/
92
- include_once ( GENERICOBJECT_DIR . "/vendor/autoload.php " );
93
97
include_once ( GENERICOBJECT_DIR . "/inc/autoload.php " );
94
98
include_once ( GENERICOBJECT_DIR . "/inc/functions.php " );
95
99
if (file_exists (GENERICOBJECT_DIR . "/log_filter.settings.php " )) {
@@ -185,18 +189,20 @@ function plugin_post_init_genericobject() {
185
189
* @return array
186
190
*/
187
191
function plugin_version_genericobject () {
188
- return array ('name ' => __ ("Objects management " , "genericobject " ),
189
- 'version ' => PLUGIN_GENERICOBJECT_VERSION ,
190
- 'author ' =>
"<a href= \"mailto:[email protected] \">Teclib'</a> & siprossii " ,
191
- 'homepage ' => 'https://github.com/pluginsGLPI/genericobject ' ,
192
- 'license ' => 'GPLv2+ ' ,
193
- 'requirements ' => [
194
- 'glpi ' => [
195
- 'min ' => '9.2 ' ,
196
- 'dev ' => true
197
- ]
198
- ]
199
- );
192
+ return [
193
+ 'name ' => __ ("Objects management " , "genericobject " ),
194
+ 'version ' => PLUGIN_GENERICOBJECT_VERSION ,
195
+ 'author ' =>
"<a href= \"mailto:[email protected] \">Teclib'</a> & siprossii " ,
196
+ 'homepage ' => 'https://github.com/pluginsGLPI/genericobject ' ,
197
+ 'license ' => 'GPLv2+ ' ,
198
+ 'requirements ' => [
199
+ 'glpi ' => [
200
+ 'min ' => PLUGIN_GENERICOBJECT_MIN_GLPI ,
201
+ 'max ' => PLUGIN_GENERICOBJECT_MAX_GLPI ,
202
+ 'dev ' => true , //Required to allow 9.2-dev
203
+ ]
204
+ ]
205
+ ];
200
206
}
201
207
202
208
/**
@@ -206,11 +212,25 @@ function plugin_version_genericobject() {
206
212
* @return boolean
207
213
*/
208
214
function plugin_genericobject_check_prerequisites () {
209
- $ version = rtrim (GLPI_VERSION , '-dev ' );
210
- if (version_compare ($ version , '9.2 ' , 'lt ' )) {
211
- echo "This plugin requires GLPI 9.2 or higher " ;
212
- return false ;
215
+
216
+ //Version check is not done by core in GLPI < 9.2 but has to be delegated to core in GLPI >= 9.2.
217
+ if (!method_exists ('Plugin ' , 'checkGlpiVersion ' )) {
218
+ $ version = preg_replace ('/^((\d+\.?)+).*$/ ' , '$1 ' , GLPI_VERSION );
219
+ $ matchMinGlpiReq = version_compare ($ version , PLUGIN_GENERICOBJECT_MIN_GLPI , '>= ' );
220
+ $ matchMaxGlpiReq = version_compare ($ version , PLUGIN_GENERICOBJECT_MAX_GLPI , '< ' );
221
+
222
+ if (!$ matchMinGlpiReq || !$ matchMaxGlpiReq ) {
223
+ echo vsprintf (
224
+ 'This plugin requires GLPI >= %1$s and < %2$s. ' ,
225
+ [
226
+ PLUGIN_GENERICOBJECT_MIN_GLPI ,
227
+ PLUGIN_GENERICOBJECT_MAX_GLPI ,
228
+ ]
229
+ );
230
+ return false ;
231
+ }
213
232
}
233
+
214
234
return true ;
215
235
}
216
236
0 commit comments