Skip to content

Commit

Permalink
Merge branch 'release/1.7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jun 21, 2018
2 parents d07b2b6 + fceb759 commit d0e03ac
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 64 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ env:
matrix:
#- GLPIVER=9.1.2 ==> not released yet!
- GLPIVER=9.2/bugfixes
- GLPIVER=master

before_script:
- composer self-update
- git clone --depth=1 https://github.com/glpi-project/glpi -b $GLPIVER ../glpi && cd ../glpi
- composer install --no-dev
- mysql -u root -e 'create database glpitest;'
- php tools/cliinstall.php --db=glpitest --user=root --tests
- php scripts/cliinstall.php --db=glpitest --user=root --tests
- mv ../fields plugins/fields
- cd plugins/fields
- composer install -o
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"atoum/atoum": "^3.1"
},
"require": {
"php": ">=5.6.0",
"zendframework/zend-loader": "^2.5"
"php": ">=5.6.0"
},
"config": {
"optimize-autoloader": true,
Expand Down
51 changes: 3 additions & 48 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions inc/autoload.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use Zend\Loader\SplAutoloader;

class PluginFieldsAutoloader implements SplAutoloader
class PluginFieldsAutoloader
{
protected $paths = [];

Expand Down
4 changes: 4 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Il existe un [script de migration](https://github.com/pluginsGLPI/customfields/b
<author>Johan Cwiklinski</author>
</authors>
<versions>
<version>
<num>1.7.3</num>
<compatibility>9.2</compatibility>
</version>
<version>
<num>1.7.2</num>
<compatibility>9.2</compatibility>
Expand Down
35 changes: 26 additions & 9 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
--------------------------------------------------------------------------
*/

define ('PLUGIN_FIELDS_VERSION', '1.7.2');
define ('PLUGIN_FIELDS_VERSION', '1.7.3');

// Minimal GLPI version, inclusive
define("PLUGIN_FIELDS_MIN_GLPI", "9.2");
// Maximum GLPI version, exclusive
define("PLUGIN_FIELDS_MAX_GLPI", "9.3");

if (!defined("PLUGINFIELDS_DIR")) {
define("PLUGINFIELDS_DIR", GLPI_ROOT . "/plugins/fields");
Expand Down Expand Up @@ -65,7 +70,6 @@ function plugin_init_fields() {
$PLUGIN_HOOKS['csrf_compliant']['fields'] = true;

// manage autoload of plugin custom classes
include_once(PLUGINFIELDS_DIR . "/vendor/autoload.php");
include_once(PLUGINFIELDS_DIR . "/inc/autoload.php");
$pluginfields_autoloader = new PluginFieldsAutoloader([PLUGINFIELDS_CLASS_PATH]);
$pluginfields_autoloader->register();
Expand Down Expand Up @@ -174,9 +178,9 @@ function plugin_version_fields() {
'license' => 'GPLv2+',
'requirements' => [
'glpi' => [
'min' => '9.2',
'max' => '9.3',
'dev' => true
'min' => PLUGIN_FIELDS_MIN_GLPI,
'max' => PLUGIN_FIELDS_MAX_GLPI,
'dev' => true, //Required to allow 9.2-dev
]
]
];
Expand All @@ -189,10 +193,23 @@ function plugin_version_fields() {
* @return boolean
*/
function plugin_fields_check_prerequisites() {
$version = rtrim(GLPI_VERSION, '-dev');
if (version_compare($version, '9.2', 'lt')) {
echo "This plugin requires GLPI 9.2";
return false;

//Version check is not done by core in GLPI < 9.2 but has to be delegated to core in GLPI >= 9.2.
if (!method_exists('Plugin', 'checkGlpiVersion')) {
$version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION);
$matchMinGlpiReq = version_compare($version, PLUGIN_FIELDS_MIN_GLPI, '>=');
$matchMaxGlpiReq = version_compare($version, PLUGIN_FIELDS_MAX_GLPI, '<');

if (!$matchMinGlpiReq || !$matchMaxGlpiReq) {
echo vsprintf(
'This plugin requires GLPI >= %1$s and < %2$s.',
[
PLUGIN_FIELDS_MIN_GLPI,
PLUGIN_FIELDS_MAX_GLPI,
]
);
return false;
}
}

return true;
Expand Down

0 comments on commit d0e03ac

Please sign in to comment.