Skip to content

Commit

Permalink
Merge branch 'release/2.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jun 21, 2018
2 parents 02d848c + 9253f01 commit 5d4d0f2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 78 deletions.
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
"prefer-stable": true,
"require-dev": {
"glpi-project/tools": "^0.1.2"
},
"require": {
"zendframework/zend-loader": "^2.5"
}
}
64 changes: 11 additions & 53 deletions composer.lock

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

4 changes: 4 additions & 0 deletions genericobject.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<author>Walid Nouh</author>
</authors>
<versions>
<version>
<num>2.5.2</num>
<compatibility>9.2</compatibility>
</version>
<version>
<num>2.5.1</num>
<compatibility>9.2</compatibility>
Expand Down
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 PluginGenericobjectAutoloader implements SplAutoloader
class PluginGenericobjectAutoloader
{
protected $paths = [];

Expand Down
2 changes: 1 addition & 1 deletion objects/objectinjection.class.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class %%INJECTIONCLASS%% extends %%CLASSNAME%%
$this->table = getTableForItemType(get_parent_class($this));
}

static function getTable() {
static function getTable($classname = null) {
$parenttype = get_parent_class();
return $parenttype::getTable();
Expand Down
56 changes: 38 additions & 18 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
----------------------------------------------------------------------
*/

define ('PLUGIN_GENERICOBJECT_VERSION', '2.5.1');
define ('PLUGIN_GENERICOBJECT_VERSION', '2.5.2');

// Minimal GLPI version, inclusive
define("PLUGIN_GENERICOBJECT_MIN_GLPI", "9.2");
// Maximum GLPI version, exclusive
define("PLUGIN_GENERICOBJECT_MAX_GLPI", "9.3");

if (!defined("GENERICOBJECT_DIR")) {
define("GENERICOBJECT_DIR", GLPI_ROOT . "/plugins/genericobject");
Expand Down Expand Up @@ -89,7 +94,6 @@
}

// Autoload class generated in files/_plugins/genericobject/inc/
include_once( GENERICOBJECT_DIR . "/vendor/autoload.php");
include_once( GENERICOBJECT_DIR . "/inc/autoload.php");
include_once( GENERICOBJECT_DIR . "/inc/functions.php");
if (file_exists(GENERICOBJECT_DIR . "/log_filter.settings.php")) {
Expand Down Expand Up @@ -185,18 +189,20 @@ function plugin_post_init_genericobject() {
* @return array
*/
function plugin_version_genericobject() {
return array ('name' => __("Objects management", "genericobject"),
'version' => PLUGIN_GENERICOBJECT_VERSION,
'author' => "<a href=\"mailto:contact@teclib.com\">Teclib'</a> & siprossii",
'homepage' => 'https://github.com/pluginsGLPI/genericobject',
'license' => 'GPLv2+',
'requirements' => [
'glpi' => [
'min' => '9.2',
'dev' => true
]
]
);
return [
'name' => __("Objects management", "genericobject"),
'version' => PLUGIN_GENERICOBJECT_VERSION,
'author' => "<a href=\"mailto:contact@teclib.com\">Teclib'</a> & siprossii",
'homepage' => 'https://github.com/pluginsGLPI/genericobject',
'license' => 'GPLv2+',
'requirements' => [
'glpi' => [
'min' => PLUGIN_GENERICOBJECT_MIN_GLPI,
'max' => PLUGIN_GENERICOBJECT_MAX_GLPI,
'dev' => true, //Required to allow 9.2-dev
]
]
];
}

/**
Expand All @@ -206,11 +212,25 @@ function plugin_version_genericobject() {
* @return boolean
*/
function plugin_genericobject_check_prerequisites() {
$version = rtrim(GLPI_VERSION, '-dev');
if (version_compare($version, '9.2', 'lt')) {
echo "This plugin requires GLPI 9.2 or higher";
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_GENERICOBJECT_MIN_GLPI, '>=');
$matchMaxGlpiReq = version_compare($version, PLUGIN_GENERICOBJECT_MAX_GLPI, '<');

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

return true;
}

Expand Down

0 comments on commit 5d4d0f2

Please sign in to comment.