3535 ----------------------------------------------------------------------
3636 */
3737
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 " );
3944
4045if (!defined ("GENERICOBJECT_DIR " )) {
4146 define ("GENERICOBJECT_DIR " , GLPI_ROOT . "/plugins/genericobject " );
8994}
9095
9196// Autoload class generated in files/_plugins/genericobject/inc/
92- include_once ( GENERICOBJECT_DIR . "/vendor/autoload.php " );
9397include_once ( GENERICOBJECT_DIR . "/inc/autoload.php " );
9498include_once ( GENERICOBJECT_DIR . "/inc/functions.php " );
9599if (file_exists (GENERICOBJECT_DIR . "/log_filter.settings.php " )) {
@@ -185,18 +189,20 @@ function plugin_post_init_genericobject() {
185189 * @return array
186190 */
187191function plugin_version_genericobject () {
188- return array ('name ' => __ ("Objects management " , "genericobject " ),
189- 'version ' => PLUGIN_GENERICOBJECT_VERSION ,
190- 'author ' => "<a href= \"mailto:contact@teclib.com \">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: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+ ];
200206}
201207
202208/**
@@ -206,11 +212,25 @@ function plugin_version_genericobject() {
206212 * @return boolean
207213 */
208214function 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+ }
213232 }
233+
214234 return true ;
215235}
216236
0 commit comments