Skip to content

Commit

Permalink
Merge branch 'release/2.6.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Nov 6, 2018
2 parents 949b40b + dfc4a5a commit 2ba9620
Show file tree
Hide file tree
Showing 23 changed files with 629 additions and 475 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ php:
- 7.2
- nightly

allow_failures:
- php: nightly
- env: GLPI_BRANCH=master
matrix:
allow_failures:
- php: nightly
- env: GLPI_BRANCH=master

before_script:
- mysql -u root -e 'create database glpitest;'
Expand Down
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
<a name="2.6.5"></a>
## [2.6.5](https://github.com-btry/pluginsglpi/formcreator/compare/2.6.3...2.6.5) (2018-11-06)


### Bug Fixes

* **actorfield:** compatibility with GLPI 9.3 ([#1034](https://github.com-btry/pluginsglpi/formcreator/issues/1034)) ([3b2051f](https://github.com-btry/pluginsglpi/formcreator/commit/3b2051f))
* **actors:** fix broken select tag ([82509e8](https://github.com-btry/pluginsglpi/formcreator/commit/82509e8))
* **actors:** fix edit of an existing question of type actors ([f1606af](https://github.com-btry/pluginsglpi/formcreator/commit/f1606af))
* **actors:** use first / last name in generataed tickets ([1455708](https://github.com-btry/pluginsglpi/formcreator/commit/1455708)), closes [#1016](https://github.com-btry/pluginsglpi/formcreator/issues/1016)
* **build:** check consistency of manifest XML file ([fb06543](https://github.com-btry/pluginsglpi/formcreator/commit/fb06543))
* **checkboxedfield:** single quote rendering ([888b13f](https://github.com-btry/pluginsglpi/formcreator/commit/888b13f))
* **date:** format dates for target generation ([10c70fc](https://github.com-btry/pluginsglpi/formcreator/commit/10c70fc)), closes [#1050](https://github.com-btry/pluginsglpi/formcreator/issues/1050)
* **description:** cannot apply hide/show condition on descriptions ([8693a6a](https://github.com-btry/pluginsglpi/formcreator/commit/8693a6a))
* **filefield:** SQL single quote escaping ([e0b9bd6](https://github.com-btry/pluginsglpi/formcreator/commit/e0b9bd6))
* **form:** access to form not properly checked ([#1047](https://github.com-btry/pluginsglpi/formcreator/issues/1047)) ([1a40790](https://github.com-btry/pluginsglpi/formcreator/commit/1a40790))
* **form:** check access to form only by entity ([c0973cb](https://github.com-btry/pluginsglpi/formcreator/commit/c0973cb))
* **form:** duplicate may fail ([a29f806](https://github.com-btry/pluginsglpi/formcreator/commit/a29f806))
* **form:** duplicate may fail ([b9b2547](https://github.com-btry/pluginsglpi/formcreator/commit/b9b2547))
* **form:** duplicate with quote ([ec6460f](https://github.com-btry/pluginsglpi/formcreator/commit/ec6460f))
* **form:** forbid purge of a form when there are answers ([f84b353](https://github.com-btry/pluginsglpi/formcreator/commit/f84b353))
* **form:** import restrictions by profile was broken ([34ae3bf](https://github.com-btry/pluginsglpi/formcreator/commit/34ae3bf)), closes [#722](https://github.com-btry/pluginsglpi/formcreator/issues/722)
* **form_answer:** allow view of form if the user has update entity right ([7dad4cb](https://github.com-btry/pluginsglpi/formcreator/commit/7dad4cb))
* **form_answer:** fix compatibility with GLPI 9.4 ([001a82f](https://github.com-btry/pluginsglpi/formcreator/commit/001a82f))
* **form_answer:** fix fatal error ([c292981](https://github.com-btry/pluginsglpi/formcreator/commit/c292981))
* **form_profile:** UUID was not generated ([44f231b](https://github.com-btry/pluginsglpi/formcreator/commit/44f231b))
* **glpiselect:** compatibility with GLPI 9.3 ([a9aea5a](https://github.com-btry/pluginsglpi/formcreator/commit/a9aea5a))
* **install:** bad logic for upgrade steps ([c324e1c](https://github.com-btry/pluginsglpi/formcreator/commit/c324e1c))
* **issue:** avoid truncate of comment ([8a98b0d](https://github.com-btry/pluginsglpi/formcreator/commit/8a98b0d))
* **issue:** more consistent status display for status of issues ([2802a78](https://github.com-btry/pluginsglpi/formcreator/commit/2802a78))
* **issue:** php warnings in service catalog ([0754b5f](https://github.com-btry/pluginsglpi/formcreator/commit/0754b5f))
* **plugin:** update compatibility ([57c607f](https://github.com-btry/pluginsglpi/formcreator/commit/57c607f))
* **question:** description displayed in italic ([e572b43](https://github.com-btry/pluginsglpi/formcreator/commit/e572b43))
* **question:** fix loss of description ([4b39371](https://github.com-btry/pluginsglpi/formcreator/commit/4b39371))
* **question_condition:** fix creation of conditions ([135d6c8](https://github.com-btry/pluginsglpi/formcreator/commit/135d6c8))
* **target:** actors not inserted on tarrgets ([18b5662](https://github.com-btry/pluginsglpi/formcreator/commit/18b5662))
* **target:** continue keyword in switch ([576c891](https://github.com-btry/pluginsglpi/formcreator/commit/576c891))
* **target:** loading of instance from DB ([1d314de](https://github.com-btry/pluginsglpi/formcreator/commit/1d314de))
* **target:** unescaped quote ([6afa05b](https://github.com-btry/pluginsglpi/formcreator/commit/6afa05b))
* **targetbase:** fix double quote renderiing in targets ([40811d8](https://github.com-btry/pluginsglpi/formcreator/commit/40811d8))
* **targetchange:** apply fix [#267](https://github.com-btry/pluginsglpi/formcreator/issues/267) to target changes ([3eafa29](https://github.com-btry/pluginsglpi/formcreator/commit/3eafa29))
* **targetchange:** changes does not supports rich text ([8d7bad0](https://github.com-btry/pluginsglpi/formcreator/commit/8d7bad0)), closes [#1139](https://github.com-btry/pluginsglpi/formcreator/issues/1139)
* **targetchange:** duplication leaves default actors ([854191d](https://github.com-btry/pluginsglpi/formcreator/commit/854191d))
* **targetchange:** entity from a question ([40cc7eb](https://github.com-btry/pluginsglpi/formcreator/commit/40cc7eb))
* **targetchange:** fix creation if relation between change and form answer ([8259899](https://github.com-btry/pluginsglpi/formcreator/commit/8259899))
* compatibility with GLPI 9.4 ([6dfaae9](https://github.com-btry/pluginsglpi/formcreator/commit/6dfaae9)), closes [#1022](https://github.com-btry/pluginsglpi/formcreator/issues/1022)
* **targetchange:** rendering with rich text ([e842b0f](https://github.com-btry/pluginsglpi/formcreator/commit/e842b0f))
* **targetchange:** rich text does not exists for changes ([e39028b](https://github.com-btry/pluginsglpi/formcreator/commit/e39028b))
* **targetchange:** time to resolve not populated when required ([b1240d6](https://github.com-btry/pluginsglpi/formcreator/commit/b1240d6))
* fix plugin manifest xml file ([7608920](https://github.com-btry/pluginsglpi/formcreator/commit/7608920))
* **targetchange:** title edition fails ([32eb4db](https://github.com-btry/pluginsglpi/formcreator/commit/32eb4db))
* **targetticket:** fix HTML ([00f81fc](https://github.com-btry/pluginsglpi/formcreator/commit/00f81fc))
* **textarea:** rendering without rich text mode ([b41a9b2](https://github.com-btry/pluginsglpi/formcreator/commit/b41a9b2))
* **textareafield:** rendering for rich text ([8735189](https://github.com-btry/pluginsglpi/formcreator/commit/8735189))
* **wizard:** warnings ([6a355f9](https://github.com-btry/pluginsglpi/formcreator/commit/6a355f9)), closes [#1076](https://github.com-btry/pluginsglpi/formcreator/issues/1076)


### Features

* **core:** add search option to get assign group / tech to ticket ([5f1eb35](https://github.com-btry/pluginsglpi/formcreator/commit/5f1eb35))



<a name="2.6.4"></a>
## [2.6.4](https://github.com-btry/pluginsGLPI/formcreator/compare/2.6.3...2.6.4) (2018-08-13)

Expand Down
18 changes: 18 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ function plugin_formcreator_addLeftJoin($itemtype, $ref_table, $new_table, $link
}
$join = " LEFT JOIN `$new_table` AS `$AS` ON (`$ref_table`.`tickets_id` = `$AS`.`tickets_id`) ";
}

if ($new_table == 'glpi_groups') {
foreach ($already_link_tables as $table) {
if (strpos($table, $new_table) === 0) {
$AS = $table;
}
}
$join = " LEFT JOIN `$new_table` AS `$AS` ON (`glpi_groups_tickets_original_id`.`groups_id` = `$AS`.`id`) ";
}

if ($new_table == 'glpi_users' && $linkfield == 'users_id') {
foreach ($already_link_tables as $table) {
if (strpos($table, $new_table) === 0) {
$AS = $table;
}
}
$join = " LEFT JOIN `$new_table` AS `$AS` ON (`glpi_tickets_users_original_id`.`users_id` = `$AS`.`id`) ";
}
break;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/fields/actorfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function displayField($canEdit = true) {
echo '<select multiple
name="formcreator_field_' . $this->fields['id'] . '[]"
id="formcreator_field_' . $this->fields['id']. '"
value="" />';
value=""></select>';
echo Html::scriptBlock('$(function() {
$("#formcreator_field_' . $this->fields['id']. '").select2({
tokenSeparators: [",", ";"],
Expand Down
4 changes: 2 additions & 2 deletions inc/fields/checkboxesfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public function displayField($canEdit = true) {
$current_value = null;
$current_value = $this->getValue();
echo "<div class='checkbox'>";
echo Html::getCheckbox(['title' => $value,
echo Html::getCheckbox(['title' => htmlentities($value, ENT_QUOTES),
'id' => 'formcreator_field_'.$this->fields['id'].'_'.$i,
'name' => 'formcreator_field_'.$this->fields['id'] . '[]',
'value' => $value,
'value' => htmlentities($value, ENT_QUOTES),
'zero_on_empty' => false,
'checked' => (!empty($current_value) && in_array($value, $current_value))]);
echo '<label for="formcreator_field_'.$this->fields['id'].'_'.$i.'">';
Expand Down
4 changes: 4 additions & 0 deletions inc/fields/datefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function getValue() {
return (strtotime($date) != '') ? $date : null;
}

public function prepareQuestionInputForTarget($input) {
return Toolbox::addslashes_deep(Html::convDate($input));
}

public function getAnswer() {
return Html::convDate($this->getValue());
}
Expand Down
4 changes: 4 additions & 0 deletions inc/fields/datetimefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function getAnswer() {
return Html::convDateTime($this->getValue());
}

public function prepareQuestionInputForTarget($input) {
return Toolbox::addslashes_deep(Html::convDateTime($input));
}

public function isValid($value) {
// If the field is required it can't be empty
if ($this->isRequired() && (strtotime($value) == '')) {
Expand Down
4 changes: 4 additions & 0 deletions inc/fields/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public function displayField($canEdit = true) {
jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").on("select2-selecting", function(e) {
formcreatorChangeValueOf (' . $this->fields['id']. ', e.val);
});
var field = $("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '");
field.on("change", function(e) {
formcreatorChangeValueOf (' . $this->fields['id']. ', e.target.value);
});
});
</script>';
} else {
Expand Down
16 changes: 13 additions & 3 deletions inc/fields/textareafield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ public function displayField($canEdit = true) {

if ($canEdit) {
$required = $this->fields['required'] ? ' required' : '';

if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$value = '<p>' . str_replace("\r\n", '</p><p>', $this->getValue()) . '</p>';
} else {
$value = str_replace('\r\n', PHP_EOL, $this->getValue());
}
echo '<textarea class="form-control"
rows="5"
name="formcreator_field_'.$this->fields['id'].'"
id="formcreator_field_'.$this->fields['id'].'"
onchange="formcreatorChangeValueOf('.$this->fields['id'].', this.value);">'
.str_replace('\r\n', PHP_EOL, $this->getValue()).'</textarea>';
.$value.'</textarea>';
if ($CFG_GLPI["use_rich_text"]) {
Html::initEditorSystem('formcreator_field_'.$this->fields['id']);
}
Expand All @@ -62,7 +66,13 @@ public static function getName() {
}

public function prepareQuestionInputForTarget($input) {
$input = str_replace("\r\n", '\r\n', addslashes($input));
global $CFG_GLPI;

if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
$input = str_replace("</p><p>", "\r\n", addslashes($input));
$input = str_replace("</p>", '', addslashes($input));
$input = str_replace("<p>", '', addslashes($input));
}
return $input;
}

Expand Down
10 changes: 7 additions & 3 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1293,8 +1293,9 @@ public function duplicate() {

unset($form_datas['id'], $form_datas['uuid']);

$old_form_id = $this->getID();
$new_form_id = $this->add($form_datas);
$old_form_id = $this->getID();
$form_datas = Toolbox::addslashes_deep($form_datas);
$new_form_id = $this->add($form_datas);
if ($new_form_id === false) {
return false;
}
Expand Down Expand Up @@ -1327,6 +1328,7 @@ public function duplicate() {
unset($sectionRow['id'],
$sectionRow['uuid']);
$sectionRow['plugin_formcreator_forms_id'] = $new_form_id;
$sectionRow = Toolbox::addslashes_deep($sectionRow);
if (!$new_sections_id = $form_section->add($sectionRow)) {
return false;
}
Expand All @@ -1337,6 +1339,7 @@ public function duplicate() {
unset($questionRow['id'],
$questionRow['uuid']);
$questionRow['plugin_formcreator_sections_id'] = $new_sections_id;
$questionRow = Toolbox::addslashes_deep($questionRow);
if (!$new_questions_id = $section_question->add($questionRow)) {
return false;
}
Expand All @@ -1354,6 +1357,7 @@ public function duplicate() {
$row['uuid']);
$row['show_field'] = $tab_questions[$row['show_field']];
$row['plugin_formcreator_questions_id'] = $tab_questions[$row['plugin_formcreator_questions_id']];
$row['show_value'] = Toolbox::addslashes_deep($row['show_value']);
if (!$question_condition->add($row)) {
return false;
}
Expand Down Expand Up @@ -1510,7 +1514,7 @@ public function duplicate() {

case PluginFormcreatorTargetChange::class:
// Drop default actors
$target_ticket_actor->deleteByCriteria([
$target_change_actor->deleteByCriteria([
'plugin_formcreator_targetchanges_id' => $new_target_item_id
]);

Expand Down
18 changes: 13 additions & 5 deletions inc/form_answer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ public function saveAnswers($data) {
if (!$this->generateTarget()) {
Session::addMessageAfterRedirect(__('Cannot generate targets!', 'formcreator'), true, ERROR);

// TODO: find a way to validate the answers
// It the form is not being validated, nothing gives the power to anyone to validate the answers
$this->update([
'id' => $this->getID(),
'status' => 'waiting',
Expand Down Expand Up @@ -1078,14 +1080,16 @@ public function getForm() {
*
* @return String Full form questions and answers to be print
*/
public function getFullForm() {
public function getFullForm($disableRichText = false) {
global $CFG_GLPI, $DB;

$question_no = 0;
$output = '';
$eol = '\r\n';
$eol = "\r\n";

if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
if ($disableRichText === false
&& (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']))
{
$output .= '<h1>' . __('Form data', 'formcreator') . '</h1>';
} else {
$output .= __('Form data', 'formcreator') . $eol;
Expand Down Expand Up @@ -1114,7 +1118,9 @@ public function getFullForm() {

// Get and display current section if needed
if ($last_section != $question_line['section_name']) {
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
if ($disableRichText === false
&& (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']))
{
$output .= '<h2>' . Toolbox::addslashes_deep($question_line['section_name']) . '</h2>';
} else {
$output .= $eol . Toolbox::addslashes_deep($question_line['section_name']) . $eol;
Expand All @@ -1135,7 +1141,9 @@ public function getFullForm() {

if ($question_line['fieldtype'] != 'description') {
$question_no++;
if (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']) {
if ($disableRichText === false
&& (version_compare(PluginFormcreatorCommon::getGlpiVersion(), 9.4) >= 0 || $CFG_GLPI['use_rich_text']))
{
$output .= '<div>';
$output .= '<b>' . $question_no . ') ##question_' . $question_line['id'] . '## : </b>';
$output .= '##answer_' . $question_line['id'] . '##';
Expand Down
42 changes: 41 additions & 1 deletion inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public function rawSearchOptions() {
'table' => $this::getTable(),
'field' => 'comment',
'name' => __('Comment'),
'datatype' => 'string',
'datatype' => 'text',
'massiveaction' => false
];

Expand Down Expand Up @@ -428,6 +428,46 @@ public function rawSearchOptions() {
]
];

$tab[] = [
'id' => '14',
'table' => User::getTable(),
'field' => 'name',
'linkfield' => 'users_id',
'name' => __('Technician'),
'datatype' => 'dropdown',
'forcegroupby' => false,
'massiveaction' => false,
'joinparams' => [
'beforejoin' => [
'table' => Ticket_User::getTable(),
'linkfield' => 'original_id',
'joinparams' => [
'jointype' => 'empty',
]
]
]
];

$tab[] = [
'id' => '15',
'table' => Group::getTable(),
'field' => 'name',
'linkfield' => 'groups_id',
'name' => __('Technician group'),
'datatype' => 'dropdown',
'forcegroupby' => false,
'massiveaction' => false,
'joinparams' => [
'beforejoin' => [
'table' => Group_Ticket::getTable(),
'linkfield' => 'original_id',
'joinparams' => [
'jointype' => 'empty',
]
]
]
];

return $tab;
}

Expand Down
Loading

0 comments on commit 2ba9620

Please sign in to comment.