37
37
38
38
define ('PLUGIN_GENERICOBJECT_VERSION ' , '2.5.1 ' );
39
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 " );
44
+
40
45
if (!defined ("GENERICOBJECT_DIR " )) {
41
46
define ("GENERICOBJECT_DIR " , GLPI_ROOT . "/plugins/genericobject " );
42
47
}
@@ -184,18 +189,20 @@ function plugin_post_init_genericobject() {
184
189
* @return array
185
190
*/
186
191
function plugin_version_genericobject () {
187
- return array ('name ' => __ ("Objects management " , "genericobject " ),
188
- 'version ' => PLUGIN_GENERICOBJECT_VERSION ,
189
- 'author ' => "<a href= \"mailto:contact@teclib.com \">Teclib'</a> & siprossii " ,
190
- 'homepage ' => 'https://github.com/pluginsGLPI/genericobject ' ,
191
- 'license ' => 'GPLv2+ ' ,
192
- 'requirements ' => [
193
- 'glpi ' => [
194
- 'min ' => '9.2 ' ,
195
- 'dev ' => true
196
- ]
197
- ]
198
- );
192
+ return [
193
+ 'name ' => __ ("Objects management " , "genericobject " ),
194
+ 'version ' => PLUGIN_GENERICOBJECT_VERSION ,
195
+ 'author ' => "<a href= \"mailto:contact@teclib.com \">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
+ ];
199
206
}
200
207
201
208
/**
@@ -205,11 +212,25 @@ function plugin_version_genericobject() {
205
212
* @return boolean
206
213
*/
207
214
function plugin_genericobject_check_prerequisites () {
208
- $ version = rtrim (GLPI_VERSION , '-dev ' );
209
- if (version_compare ($ version , '9.2 ' , 'lt ' )) {
210
- echo "This plugin requires GLPI 9.2 or higher " ;
211
- 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
+ }
212
232
}
233
+
213
234
return true ;
214
235
}
215
236
0 commit comments