Skip to content

Commit

Permalink
Restore compatibility with PHP 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Jun 19, 2017
1 parent 045ef22 commit 1506e95
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
GLPI Formcreator ChangeLog
===============================

Version 2.5.1
-------------

## Bugfixes:
* restore compatibility with PHP 5.4


Version 2.5.0
-------------

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">= 5.4.0",
"ext-xml": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0",
"glpi-project/tools": "^0.1.0"
Expand Down
13 changes: 8 additions & 5 deletions inc/form_answer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,15 @@ static function showForForm(PluginFormcreatorForm $form, $params = []) {
$_SESSION['formcreator']['form_search_answers'] = $form->getID();

// prepare params for search
$item = new Self;
$filter = function ($key) {
return (is_numeric($key));
};
$item = new PluginFormcreatorForm_Answer();
$soptions = $item->getSearchOptions();
$soptions = array_filter($soptions, $filter, ARRAY_FILTER_USE_KEY);
$filteredOptions = [];
foreach ($options as $key => $value) {
if (is_numeric($key)) {
$filteredOptions[$key] = $value;
}
}
$soptions = $filteredOptions;
$sopt_keys = array_keys($soptions);

$forcedisplay = array_combine($sopt_keys, $sopt_keys);
Expand Down
6 changes: 3 additions & 3 deletions inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function getItem_Item() {
}

protected function getTargetItemtypeName() {
return Change::class;
return 'Change';
}

public function getItem_Actor() {
Expand Down Expand Up @@ -1160,7 +1160,7 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
$tagObj->add(array(
'plugin_tag_tags_id' => $tag,
'items_id' => $changeID,
'itemtype' => Change::class,
'itemtype' => 'Change',
));
}
}
Expand Down Expand Up @@ -1244,7 +1244,7 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
}
}

$this->attachDocument($formanswer->getID(), Change::class, $changeID);
$this->attachDocument($formanswer->getID(), 'Change', $changeID);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function getItem_Item() {
}

protected function getTargetItemtypeName() {
return Ticket::class;
return 'Ticket';
}

public function getItem_Actor() {
Expand Down Expand Up @@ -1104,7 +1104,7 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
$tagObj->add(array(
'plugin_tag_tags_id' => $tag,
'items_id' => $ticketID,
'itemtype' => Ticket::class,
'itemtype' => 'Ticket',
));
}
}
Expand All @@ -1117,7 +1117,7 @@ public function save(PluginFormcreatorForm_Answer $formanswer) {
'tickets_id' => $ticketID,
));

$this->attachDocument($formanswer->getID(), Ticket::class, $ticketID);
$this->attachDocument($formanswer->getID(), 'Ticket', $ticketID);

// Attach validation message as first ticket followup if validation is required and
// if is set in ticket target configuration
Expand Down
4 changes: 4 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ Features
<num>2.5.0</num>
<compatibility>9.1.2</compatibility>
</version>
<version>
<num>2.5.1</num>
<compatibility>9.1.2</compatibility>
</version>
</versions>
<langs>
<lang>ca_ES</lang>
Expand Down
23 changes: 17 additions & 6 deletions setup.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php
global $CFG_GLPI;
// Version of the plugin
define('PLUGIN_FORMCREATOR_VERSION', '2.5.0');
define('PLUGIN_FORMCREATOR_VERSION', '2.5.1');
// Schema version of this version
define('PLUGIN_FORMCREATOR_SCHEMA_VERSION', '2.5');

// Minimal GLPI version, inclusive
define ("PLUGIN_FORMCREATOR_GLPI_MIN_VERSION", '9.1.2');
define ('PLUGIN_FORMCREATOR_GLPI_MIN_VERSION', '9.1.2');
// Maximum GLPI version, exclusive
define ("PLUGIN_FORMCREATOR_GLPI_MAX_VERSION", '9.2');
define ('PLUGIN_FORMCREATOR_GLPI_MAX_VERSION', '9.2');
// Minimum version of PHP
define('PLUGIN_FORMCREATOR_PHP_MIN_VERSION', '5.4.0');

define('FORMCREATOR_ROOTDOC', $CFG_GLPI['root_doc']."/plugins/formcreator");
define('FORMCREATOR_ROOTDOC', $CFG_GLPI['root_doc'] . '/plugins/formcreator');

/**
* Define the plugin's version and informations
Expand Down Expand Up @@ -39,11 +41,20 @@ function plugin_formcreator_check_prerequisites () {
echo 'This plugin requires GLPI >= ' . PLUGIN_FORMCREATOR_GLPI_MIN_VERSION . '<br>';
$success = false;
}
if (! function_exists("utf8_decode")) {
echo "This plugin requires php-xml<br>";
if (! function_exists('utf8_decode')) {
echo 'This plugin requires php-xml<br>';
$success = false;
}

if (version_compare(PHP_VERSION, PLUGIN_FORMCREATOR_PHP_MIN_VERSION, 'lt')) {
if (method_exists('Plugin', 'messageIncompatible')) {
echo Plugin::messageIncompatible('core', PLUGIN_FORMCREATOR_GLPI_MIN_VERSION) . '<br/>';
} else {
echo 'This plugin requires PHP >=' . PLUGIN_FORMCREATOR_GLPI_MIN_VERSION . '<br>';
}
$success= false;
}

return $success;
}

Expand Down

0 comments on commit 1506e95

Please sign in to comment.