Skip to content

Commit e36ff94

Browse files
committed
Merge remote-tracking branch 'origin/support/2.13.0' into support/2.14.0
2 parents d363127 + 61722da commit e36ff94

10 files changed

Lines changed: 458 additions & 17 deletions

inc/field/filefield.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function moveUploads() {
133133
foreach ($this->uploads["_$key"] as $index => $document) {
134134
$document = Toolbox::stripslashes_deep($document);
135135
if (is_file(GLPI_TMP_DIR . '/' . $document)) {
136-
$prefix = $this->uploads['_prefix_formcreator_field_' . $this->question->getID()][$index];
136+
$prefix = $this->uploads['_prefix_' . $key][$index];
137137
$answer_value[] = $this->saveDocument($document, $prefix);
138138
}
139139
$index++;
@@ -189,7 +189,7 @@ public function saveUploads($input) {
189189
foreach ($input["_$key"] as $document) {
190190
$document = Toolbox::stripslashes_deep($document);
191191
if (is_file(GLPI_TMP_DIR . '/' . $document)) {
192-
$prefix = $input['_prefix_formcreator_field_' . $this->question->getID()][$index];
192+
$prefix = $input['_prefix_' . $key][$index];
193193
$answer_value[] = $this->saveDocument($document, $prefix);
194194
}
195195
$index++;

inc/formanswer.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ public function parseTags(string $content, PluginFormcreatorTargetInterface $tar
13941394
$name = '';
13951395
$value = '';
13961396
if (PluginFormcreatorFields::isVisible($question, $this->questionFields)) {
1397-
$name = $question->fields['name'];
1397+
$name = __($question->fields['name'], $domain);
13981398
$value = $this->questionFields[$questionId]->getValueForTargetText($domain, $richText);
13991399
}
14001400

inc/targetchange.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use GlpiPlugin\Formcreator\Exception\ImportFailureException;
3333
use GlpiPlugin\Formcreator\Exception\ExportFailureException;
3434
use Glpi\Application\View\TemplateRenderer;
35+
use Glpi\Toolbox\Sanitizer;
3536

3637
if (!defined('GLPI_ROOT')) {
3738
die("Sorry. You can't access this file directly");
@@ -666,7 +667,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
666667
];
667668
foreach ($changeFields as $changeField) {
668669
$data[$changeField] = $this->prepareTemplate(
669-
$this->fields[$changeField] ?? '',
670+
Sanitizer::unsanitize(__($this->fields[$changeField], $domain)) ?? '',
670671
$formanswer,
671672
$changeField == 'content' // only content supports rich text
672673
);

inc/targetproblem.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use GlpiPlugin\Formcreator\Exception\ImportFailureException;
3333
use GlpiPlugin\Formcreator\Exception\ExportFailureException;
3434
use Glpi\Application\View\TemplateRenderer;
35+
use Glpi\Toolbox\Sanitizer;
3536

3637
if (!defined('GLPI_ROOT')) {
3738
die("Sorry. You can't access this file directly");
@@ -185,7 +186,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
185186
];
186187
foreach ($problemFields as $problemFields) {
187188
$data[$problemFields] = $this->prepareTemplate(
188-
$this->fields[$problemFields] ?? '',
189+
Sanitizer::unsanitize(__($this->fields[$problemFields], $domain)) ?? '',
189190
$formanswer,
190191
$problemFields == 'content' // only content supports rich text
191192
);

inc/targetticket.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use GlpiPlugin\Formcreator\Exception\ImportFailureException;
3333
use GlpiPlugin\Formcreator\Exception\ExportFailureException;
3434
use Glpi\Application\View\TemplateRenderer;
35+
use Glpi\Toolbox\Sanitizer;
3536

3637
if (!defined('GLPI_ROOT')) {
3738
die("Sorry. You can't access this file directly");
@@ -844,7 +845,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
844845
$data['date'] = $_SESSION['glpi_currenttime'];
845846

846847
$data['content'] = $this->prepareTemplate(
847-
$this->fields['content'] ?? '',
848+
Sanitizer::unsanitize(__($this->fields['content'], $domain)) ?? '',
848849
$formanswer,
849850
$richText
850851
);

install/install.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class PluginFormcreatorInstall {
8181
'2.13.1' => '2.13.3',
8282
'2.13.3' => '2.13.4',
8383
'2.13.4' => '2.13.5',
84-
'2.13.5' => '2.14',
84+
'2.13.5' => '2.13.6',
85+
'2.13.6' => '2.14',
8586
];
8687

8788
protected bool $resyncIssues = false;

install/mysql/plugin_formcreator_2.13.6_empty.sql

Lines changed: 352 additions & 0 deletions
Large diffs are not rendered by default.

install/upgrade_to_2.13.6.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* ---------------------------------------------------------------------
4+
* Formcreator is a plugin which allows creation of custom forms of
5+
* easy access.
6+
* ---------------------------------------------------------------------
7+
* LICENSE
8+
*
9+
* This file is part of Formcreator.
10+
*
11+
* Formcreator is free software; you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation; either version 2 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* Formcreator is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
23+
* ---------------------------------------------------------------------
24+
* @copyright Copyright © 2011 - 2021 Teclib'
25+
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
26+
* @link https://github.com/pluginsGLPI/formcreator/
27+
* @link https://pluginsglpi.github.io/formcreator/
28+
* @link http://plugins.glpi-project.org/#/plugin/formcreator
29+
* ---------------------------------------------------------------------
30+
*/
31+
32+
use Glpi\RichText\RichText;
33+
use Glpi\Toolbox\Sanitizer;
34+
35+
class PluginFormcreatorUpgradeTo2_13_6 {
36+
/** @var Migration */
37+
protected $migration;
38+
39+
public function isResyncIssuesRequired() {
40+
return false;
41+
}
42+
43+
/**
44+
* @param Migration $migration
45+
*/
46+
public function upgrade(Migration $migration) {
47+
$this->migration = $migration;
48+
$this->migrateToRichText();
49+
}
50+
51+
public function migrateToRichText() {
52+
global $DB;
53+
54+
$tables = [
55+
'glpi_plugin_formcreator_targetchanges' => [
56+
'content',
57+
'impactcontent',
58+
'controlistcontent',
59+
'rolloutplancontent',
60+
'backoutplancontent',
61+
'checklistcontent',
62+
],
63+
'glpi_plugin_formcreator_targetproblems' => [
64+
'content',
65+
'impactcontent',
66+
'causecontent',
67+
'symptomcontent',
68+
],
69+
];
70+
71+
foreach ($tables as $table => $fields) {
72+
$request = [
73+
'SELECT' => ['id'] + $fields,
74+
'FROM' => $table
75+
];
76+
foreach ($DB->request($request) as $row) {
77+
foreach ($fields as $field) {
78+
$row[$field] = RichText::getSafeHtml($row[$field]);
79+
$row[$field] = Sanitizer::dbEscape($row[$field]);
80+
}
81+
$DB->update($table, $row, ['id' => $row['id']]);
82+
}
83+
}
84+
}
85+
}

templates/pages/targetchange.html.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
{ required: true, full_width: true }
5050
) }}
5151

52-
{{ fields.textareaField('content', item.fields['content'], __('Description', 'formcreator'), { full_width: true }) }}
52+
{{ fields.textareaField('content', item.fields['content'], __('Description', 'formcreator'), { enable_richtext: true, full_width: true }) }}
5353

54-
{{ fields.textareaField('impactcontent', item.fields['impactcontent'], __('Impacts'), { full_width: true }) }}
54+
{{ fields.textareaField('impactcontent', item.fields['impactcontent'], __('Impacts'), { enable_richtext: true, full_width: true }) }}
5555

56-
{{ fields.textareaField('controlistcontent', item.fields['controlistcontent'], __('Control list'), { full_width: true }) }}
56+
{{ fields.textareaField('controlistcontent', item.fields['controlistcontent'], __('Control list'), { enable_richtext: true, full_width: true }) }}
5757

58-
{{ fields.textareaField('rolloutplancontent', item.fields['rolloutplancontent'], __('Deployment plan'), { full_width: true }) }}
58+
{{ fields.textareaField('rolloutplancontent', item.fields['rolloutplancontent'], __('Deployment plan'), { enable_richtext: true, full_width: true }) }}
5959

60-
{{ fields.textareaField('backoutplancontent', item.fields['backoutplancontent'], __('Backup plan'), { full_width: true }) }}
60+
{{ fields.textareaField('backoutplancontent', item.fields['backoutplancontent'], __('Backup plan'), { enable_richtext: true, full_width: true }) }}
6161

62-
{{ fields.textareaField('checklistcontent', item.fields['checklistcontent'], __('Checklist'), { full_width: true }) }}
62+
{{ fields.textareaField('checklistcontent', item.fields['checklistcontent'], __('Checklist'), { enable_richtext: true, full_width: true }) }}
6363
{% endblock %}

templates/pages/targetproblem.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
{ required: true, full_width: true }
5050
) }}
5151

52-
{{ fields.textareaField('content', item.fields['content'], __('Description', 'formcreator'), { full_width: true }) }}
52+
{{ fields.textareaField('content', item.fields['content'], __('Description', 'formcreator'), { enable_richtext: true, full_width: true }) }}
5353

54-
{{ fields.textareaField('impactcontent', item.fields['impactcontent'], __('Impacts'), { full_width: true }) }}
54+
{{ fields.textareaField('impactcontent', item.fields['impactcontent'], __('Impacts'), { enable_richtext: true, full_width: true }) }}
5555

56-
{{ fields.textareaField('causecontent', item.fields['causecontent'], __('Cause'), { full_width: true }) }}
56+
{{ fields.textareaField('causecontent', item.fields['causecontent'], __('Cause'), { enable_richtext: true, full_width: true }) }}
5757

58-
{{ fields.textareaField('symptomcontent', item.fields['symptomcontent'], __('Symptom'), { full_width: true }) }}
58+
{{ fields.textareaField('symptomcontent', item.fields['symptomcontent'], __('Symptom'), { enable_richtext: true, full_width: true }) }}
5959
{% endblock %}

0 commit comments

Comments
 (0)