Skip to content

Commit

Permalink
Merge branch 'release/2.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Mar 11, 2019
2 parents 34651c0 + 3bc6b11 commit 24b6591
Show file tree
Hide file tree
Showing 47 changed files with 2,959 additions and 469 deletions.
17 changes: 2 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ env:
global:
- GLPI_SOURCE="https://github.com/glpi-project/glpi"
- CS=7.2
- DBUSER=root
- DBNAME=glpitest
- OLDDBNAME=glpiupgradetest
- AFTER_SUCCESS_BRANCH=9.4/bugfixes
Expand All @@ -30,21 +31,7 @@ before_script:
- "./tests/before_script.sh"

script:
- COVERAGE="-ncc"
- if [ "${TRAVIS_PHP_VERSION:0:3}" = "$CS" ] && [ "$GLPI_BRANCH" = "$AFTER_SUCCESS_BRANCH" ]; then COVERAGE="--nccfc CommonTreeDropdown CommonDropdown CommonDBTM CommonGLPI CommonDBChild CommonDBConnexity CommonDBRelation"; fi
- if [ -e ../../scripts/cliinstall.php ] ; then php ../../scripts/cliinstall.php --db=$OLDDBNAME --user=root --tests ; fi
- if [ -e ../../bin/console ] ; then php ../../bin/console glpi:database:install --db-name=$OLDDBNAME --db-user=root --config-dir=../../tests --no-interaction --force; fi
- mysql -u root $OLDDBNAME < tests/plugin_formcreator_empty_2.5.0.sql
- mysql -u root $OLDDBNAME < tests/plugin_formcreator_config_2.5.0.sql
- php scripts/cliinstall.php --tests
- rm ../../tests/config_db.php
- if [ -e ../../scripts/cliinstall.php ] ; then php ../../scripts/cliinstall.php --db=$DBNAME --user=root --tests ; fi
- if [ -e ../../bin/console ] ; then php ../../bin/console glpi:database:install --db-name=$DBNAME --db-user=root --config-dir=../../tests --no-interaction --force; fi
- vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-install -ncc
- vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-integration $COVERAGE
- vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-unit $COVERAGE
- vendor/bin/atoum -ft -bf tests/bootstrap.php -d tests/suite-uninstall -ncc
- if [ ${TRAVIS_PHP_VERSION:0:3} == "$CS" ] && [ "$GLPI_BRANCH" = "$AFTER_SUCCESS_BRANCH" ]; then vendor/bin/robo --no-interaction code:cs; fi
- "./tests/script.sh"

after_success:
# let's update the documentation and locales
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
<a name="2.8.0"></a>
# [2.8.0](https://github.com/pluginsglpi/formcreator/compare/v2.7.0...v2.8.0) (2019-03-06)


### Bug Fixes

* **checkboxesfield:** handle case when one option is selcted ([5cee1a5](https://github.com/pluginsglpi/formcreator/commit/5cee1a5))
* **dropdownfield:** bad entity restriction ([e9c27dd](https://github.com/pluginsglpi/formcreator/commit/e9c27dd))
* **dropdownfield:** bad subtree handling for ITIL category ([a62e764](https://github.com/pluginsglpi/formcreator/commit/a62e764))
* **form:** fix anonymous file upload ([a13ec8b](https://github.com/pluginsglpi/formcreator/commit/a13ec8b))
* **form:** import of entity and category ([2e3beea](https://github.com/pluginsglpi/formcreator/commit/2e3beea))
* **formanswer:** use of non-eistent field for count ([fb30d55](https://github.com/pluginsglpi/formcreator/commit/fb30d55))
* **glpiobject,dropdown:** formanswer must display name, not the ID ([db24ae9](https://github.com/pluginsglpi/formcreator/commit/db24ae9))
* **install:** remvoe rename of the plugin from upgtrade to 2.7 ([6e03e21](https://github.com/pluginsglpi/formcreator/commit/6e03e21))
* **install:** rename of the plugin in 2.8, not 2.7 ([e176d3c](https://github.com/pluginsglpi/formcreator/commit/e176d3c))
* **issue:** rebuild of issues table ([eec8012](https://github.com/pluginsglpi/formcreator/commit/eec8012))
* **question,section:** escaping bug on duplication ([971339f](https://github.com/pluginsglpi/formcreator/commit/971339f))
* **questionrange,questionregex:** bad var names ([978a116](https://github.com/pluginsglpi/formcreator/commit/978a116))
* **section:** escape questions to duplciate ([9786afa](https://github.com/pluginsglpi/formcreator/commit/9786afa))
* **targetchange:** add users from question of type actors ([fcb357b](https://github.com/pluginsglpi/formcreator/commit/fcb357b))
* **targetchange:** category not assigned ([7f840df](https://github.com/pluginsglpi/formcreator/commit/7f840df))
* **wizard:** compatibility accross versions od font awesome ([2462ca4](https://github.com/pluginsglpi/formcreator/commit/2462ca4))
* rename the plugin ([2f5c27f](https://github.com/pluginsglpi/formcreator/commit/2f5c27f)), closes [#1264](https://github.com/pluginsglpi/formcreator/issues/1264)


### Features

* **glpiselect:** add Project in the supported list ([eae0a3b](https://github.com/pluginsglpi/formcreator/commit/eae0a3b))
* **issue:** add qtip for ticket types ([4edcd06](https://github.com/pluginsglpi/formcreator/commit/4edcd06))



<a name="2.7.0"></a>
# [2.7.0](https://github.com/pluginsglpi/formcreator/compare/v2.7.0-beta.2...v2.7.0) (2019-02-12)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Formcreator",
"name": "glpi-plugin/formcreator",
"description": "Formcreator is a plugin that allow creation of custom, easy to access forms for users when they want to create one or more GLPI tickets.",
"license": "GPL-2.0-or-later",
"minimum-stability": "dev",
Expand Down
1 change: 1 addition & 0 deletions front/formdisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@

// If user was not authenticated, remove temporary user
if ($_SESSION['glpiname'] == 'formcreator_temp_user') {
session_write_close();
unset($_SESSION['glpiname']);
}

Expand Down
2 changes: 1 addition & 1 deletion inc/fields/checkboxesfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function parseAnswerValues($input) {
$input[$key] = [];
} else {
if (!is_array($input[$key])) {
return false;
$input[$key] = [$input[$key]];
}
}

Expand Down
35 changes: 25 additions & 10 deletions inc/fields/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function displayField($canEdit = true) {
$dparams = ['name' => $fieldName,
'value' => $this->value,
'comments' => false,
'entity' => $_SESSION['glpiactive_entity'],
'entity' => $_SESSION['glpiactiveentities'],
'rand' => $rand];

$dparams_cond_crit = [];
Expand Down Expand Up @@ -116,9 +116,9 @@ public function displayField($canEdit = true) {
ItilCategory::getTable(),
$decodedValues['show_ticket_categories_root']
);
$sons = "'" . implode("', '", $sons) . "'";
$dparams['condition'] .= " AND `id` IN ('" . $decodedValues['show_ticket_categories_root'] . "')";
$dparams_cond_crit['id'] = $decodedValues['show_ticket_categories_root'];
//$sons = "'" . implode("', '", $sons) . "'";
$dparams['condition'] .= " AND `id` IN ('" . implode("', '", $sons) . "')";
$dparams_cond_crit['id'] = $sons;
}
break;

Expand Down Expand Up @@ -165,7 +165,19 @@ public function displayField($canEdit = true) {
pluginFormcreatorInitializeDropdown('$fieldName', '$rand');
});");
} else {
echo $this->value;
$decodedValues = json_decode($this->fields['values'], JSON_OBJECT_AS_ARRAY);
if ($decodedValues === null) {
$itemtype = $this->fields['values'];
} else {
$itemtype = $decodedValues['itemtype'];
}
$item = new $itemtype();
$value = '';
if ($item->getFromDB($this->value)) {
$value = $item->getField('name');
}

echo $value;
}
}

Expand Down Expand Up @@ -372,12 +384,15 @@ public function lessThan($value) {

public function parseAnswerValues($input) {
$key = 'formcreator_field_' . $this->fields['id'];
if (!is_string($input[$key])) {
return false;
if (!isset($input[$key])) {
$input[$key] = '0';
} else {
if (!is_string($input[$key])) {
return false;
}
}

$this->value = $input[$key];
return true;
$this->value = $input[$key];
return true;
}

public function isAnonymousFormCompatible() {
Expand Down
4 changes: 0 additions & 4 deletions inc/fields/filefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ public function displayField($canEdit = true) {
if ($canEdit) {
$required = $this->isRequired() ? ' required' : '';

echo '<input type="hidden" class="form-control"
name="formcreator_field_' . $this->fields['id'] . '" value="" />' . PHP_EOL;

echo Html::file([
'name' => 'formcreator_field_' . $this->fields['id'],
'display' => false,
'multiple' => 'multiple',
]);

} else {
$doc = new Document();
$answer = $this->value;
Expand Down
12 changes: 8 additions & 4 deletions inc/fields/urgencyfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ public function prepareQuestionInputForSave($input) {

public function parseAnswerValues($input) {
$key = 'formcreator_field_' . $this->fields['id'];
if (!is_string($input[$key])) {
return false;
if (!isset($input[$key])) {
$input[$key] = '3';
} else {
if (!is_string($input[$key])) {
return false;
}
}

$this->value = $input[$key];
return true;
$this->value = $input[$key];
return true;
}

public static function getPrefs() {
Expand Down
61 changes: 42 additions & 19 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1734,12 +1734,12 @@ function export($remove_uuid = false) {
// replace dropdown ids
if ($form['plugin_formcreator_categories_id'] > 0) {
$form['_plugin_formcreator_category']
= Dropdown::getDropdownName('glpi_plugin_formcreator_categories',
= Dropdown::getDropdownName(PluginFormcreatorCategory::getTable(),
$form['plugin_formcreator_categories_id']);
}
if ($form['entities_id'] > 0) {
$form['_entity']
= Dropdown::getDropdownName('glpi_entities',
= Dropdown::getDropdownName(Entity::getTable(),
$form['entities_id']);
}

Expand Down Expand Up @@ -2028,34 +2028,57 @@ public static function import(PluginFormcreatorImportLinker $importLinker, $form
set_time_limit(30);

$form_obj = new self;
$entity = new Entity;
$form_cat = new PluginFormcreatorCategory;

$forms_id = plugin_formcreator_getFromDBByField(
$form_obj,
'uuid',
$form['uuid']
);

// retrieve foreign keys
if (!isset($form['_entity'])
|| !$form['entities_id']
= plugin_formcreator_getFromDBByField($entity,
'completename',
$form['_entity'])) {
$form['entities_id'] = $_SESSION['glpiactive_entity'];
$entity = new Entity();
$entityFk = Entity::getForeignKeyField();
$entityId = $_SESSION['glpiactive_entity'];
if (isset($form['_entity'])) {
plugin_formcreator_getFromDBByField(
$entity,
'completename',
$form['_entity']
);
// Check rights on the destination entity of the form
if (!$entity->isNewItem() && $entity->canUpdateItem()) {
$entityId = $entity->getID();
} else {
if ($forms_id !== false) {
// The form is in an entity where we don't have UPDATE right
Session::addMessageAfterRedirect(
sprintf(__('The form %1$s already exists and is in an unmodifiable entity.', 'formcreator'), $form['name']),
false,
WARNING
);
return false;
}
}
}
if (!isset($form['_plugin_formcreator_categories_id'])
|| !$form['_plugin_formcreator_categories_id']
= plugin_formcreator_getFromDBByField($form_cat,
'completename',
$form['_plugin_formcreator_category'])) {
$form['plugin_formcreator_categories_id'] = 0;
$form[$entityFk] = $entityId;

$formCategory = new PluginFormcreatorCategory();
$formCategoryFk = PluginFormcreatorCategory::getForeignKeyField();
$formCategoryId = 0;
if (isset($form['_plugin_formcreator_category'])) {
$formCategoryId = $formCategory->import([
'completename' => $form['_plugin_formcreator_category'],
]);
}
$form[$formCategoryFk] = $formCategoryId;

// escape text fields
foreach (['name', 'description', 'content'] as $key) {
$form[$key] = $DB->escape($form[$key]);
}

// retrieve form by its uuid
if ($forms_id = plugin_formcreator_getFromDBByField($form_obj,
'uuid',
$form['uuid'])) {
if (!$form_obj->isNewItem()) {
// add id key
$form['id'] = $forms_id;

Expand Down
9 changes: 3 additions & 6 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
static::getTable(),
[
$formFk => $item->getID(),
'is_deleted' => 0,
]
);
return self::createTabEntry(self::getTypeName($number), $number);
Expand Down Expand Up @@ -965,8 +964,8 @@ public function saveAnswers(PluginFormcreatorForm $form, $data, $fields) {
/**
* Update the answers
*
* @param [type] $input
* @return void
* @param array $input
* @return boolean
*/
public function updateAnswers($input) {
$form = new PluginFormcreatorForm();
Expand All @@ -985,7 +984,7 @@ public function updateAnswers($input) {
);
$fields[$id]->parseAnswerValues($input);
}
$this->saveAnswers($form, $input, $fields);
return $this->saveAnswers($form, $input, $fields);
}

/**
Expand Down Expand Up @@ -1018,7 +1017,6 @@ public function refuseAnswers($input) {
);
$fields[$id]->parseAnswerValues($input);
}

return $this->saveAnswers($form, $input, $fields);
}

Expand Down Expand Up @@ -1052,7 +1050,6 @@ public function acceptAnswers($input) {
);
$fields[$id]->parseAnswerValues($input);
}

return $this->saveAnswers($form, $input, $fields);
}

Expand Down
Loading

0 comments on commit 24b6591

Please sign in to comment.