Skip to content

Commit d363127

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

13 files changed

Lines changed: 168 additions & 28 deletions

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
<a name="2.13.5"></a>
2+
## [2.13.5](https://github.com/pluginsGLPI/formcreator/compare/2.13.4..2.13.5) (2023-03-24)
3+
4+
5+
### Bug Fixes
6+
7+
* add missing domain for public forms translation (#3162) ([970f183c6](https://github.com/pluginsGLPI/formcreator/commit/970f183c6))
8+
* duplicate key when updating a profile ([1bd6a2ab6](https://github.com/pluginsGLPI/formcreator/commit/1bd6a2ab6))
9+
* remote glpi prefix for commands ([651444a27](https://github.com/pluginsGLPI/formcreator/commit/651444a27))
10+
* **abstractitiltarget:** set priority from urgency and impact (#3178) ([1269edd51](https://github.com/pluginsGLPI/formcreator/commit/1269edd51))
11+
* **checkboxes:** better display ([f8fe93a63](https://github.com/pluginsGLPI/formcreator/commit/f8fe93a63))
12+
* **checkboxes:** padding between items ([a62f879ce](https://github.com/pluginsGLPI/formcreator/commit/a62f879ce))
13+
* **condition:** infinite loop detection ([172d5e8eb](https://github.com/pluginsGLPI/formcreator/commit/172d5e8eb))
14+
* **dropdownfield:** prevent ambiguous column name ([b54523219](https://github.com/pluginsGLPI/formcreator/commit/b54523219))
15+
* **form:** remove obsolete translations on update ([3cc58ac7d](https://github.com/pluginsGLPI/formcreator/commit/3cc58ac7d))
16+
* **form:** rename form answer properties tab ([a3395179d](https://github.com/pluginsGLPI/formcreator/commit/a3395179d))
17+
* **form_language:** avoid persistent rich editor toolbar when closing modal ([11a8808b5](https://github.com/pluginsGLPI/formcreator/commit/11a8808b5))
18+
* **form_language:** display problems when translating ([93073e656](https://github.com/pluginsGLPI/formcreator/commit/93073e656))
19+
* **form_language:** filter out obsolete translations ([b38555c5e](https://github.com/pluginsGLPI/formcreator/commit/b38555c5e))
20+
* **formanswer:** access restriction ([a9451d982](https://github.com/pluginsGLPI/formcreator/commit/a9451d982))
21+
* **install:** distinguish error messages for sanity check ([b798bf264](https://github.com/pluginsGLPI/formcreator/commit/b798bf264))
22+
* **notifications:** missing lang tags ([3cad18562](https://github.com/pluginsGLPI/formcreator/commit/3cad18562))
23+
* **question:** missing conditions count after update ([ea185beb8](https://github.com/pluginsGLPI/formcreator/commit/ea185beb8))
24+
* **question:** updating a question returns sanitized label ([936ccd475](https://github.com/pluginsGLPI/formcreator/commit/936ccd475))
25+
* **radios:** update escaping of valies ([c940e1764](https://github.com/pluginsGLPI/formcreator/commit/c940e1764))
26+
* **radiosfield:** better display ([fe6c2e8d0](https://github.com/pluginsGLPI/formcreator/commit/fe6c2e8d0))
27+
* **restrictedformcriteria:** bad key when generating error message ([6cabca1fe](https://github.com/pluginsGLPI/formcreator/commit/6cabca1fe))
28+
* **targetchange,targetproblem:** harmonize implemetnation with targetticket ([1ba402de0](https://github.com/pluginsGLPI/formcreator/commit/1ba402de0))
29+
* **targetchange,targetproblem:** missed code refactor ([e24d2fc13](https://github.com/pluginsGLPI/formcreator/commit/e24d2fc13))
30+
* **targetticket:** wrong property label ([fd3d30973](https://github.com/pluginsGLPI/formcreator/commit/fd3d30973))
31+
* **textareafield:** target ticket shows HTML when image uploaded ([56fc8d54d](https://github.com/pluginsGLPI/formcreator/commit/56fc8d54d))
32+
* **translation:** avoid rn when using formatted rich (html) text ([24113a353](https://github.com/pluginsGLPI/formcreator/commit/24113a353))
33+
34+
35+
### Features
36+
37+
* Link documents to form ([690f58d13](https://github.com/pluginsGLPI/formcreator/commit/690f58d13))
38+
* **form_language:** add items count in tab ([90a579680](https://github.com/pluginsGLPI/formcreator/commit/90a579680))
39+
* **issue:** more anonymising options (#3160) ([075896bb6](https://github.com/pluginsGLPI/formcreator/commit/075896bb6))
40+
41+
142
<a name="2.13.4"></a>
243
## [2.13.4](https://github.com/pluginsGLPI/formcreator/compare/2.13.3..2.13.4) (2023-01-24)
344

front/formanswer.form.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@
4545
$formanswer->update($_POST);
4646
Html::back();
4747

48-
} else if (isset($_POST['refuse_formanswer'])) {
49-
$formanswer->update($_POST);
50-
$formanswer->redirectToList();
51-
52-
} else if (isset($_POST['accept_formanswer'])) {
53-
$formanswer->update($_POST);
54-
$formanswer->redirectToList();
55-
48+
} else if (isset($_POST['refuse_formanswer']) || isset($_POST['accept_formanswer'])) {
49+
if ($formanswer->update($_POST)) {
50+
$formanswer->redirectToList();
51+
} else {
52+
//redirect to formanswer if update failed (ex : missing mandatory field)
53+
Html::back();
54+
}
5655
} else if (isset($_POST['save_formanswer'])) {
5756
if (!$formanswer->update($_POST)) {
5857
Html::back();

inc/field/dropdownfield.class.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use Toolbox;
4141
use Session;
4242
use DBUtils;
43+
use Document;
4344
use Dropdown;
4445
use CommonGLPI;
4546
use CommonITILActor;
@@ -67,11 +68,12 @@
6768

6869
class DropdownField extends PluginFormcreatorAbstractField
6970
{
70-
7171
const ENTITY_RESTRICT_USER = 1;
7272
const ENTITY_RESTRICT_FORM = 2;
7373
const ENTITY_RESTRICT_BOTH = 3;
7474

75+
protected static $noEntityRrestrict = [Entity::class, Document::class];
76+
7577
public function getEnumEntityRestriction() {
7678
return [
7779
self::ENTITY_RESTRICT_USER => User::getTypeName(1),
@@ -133,10 +135,14 @@ public function showForm(array $options): void {
133135
$this->question->fields['_entity_restrict'] = $decodedValues['entity_restrict'] ?? self::ENTITY_RESTRICT_FORM;
134136
$this->question->fields['_is_tree'] = '0';
135137
$this->question->fields['_is_entity_restrict'] = '0';
138+
if (isset($this->question->fields['itemtype']) && is_subclass_of($this->question->fields['itemtype'], CommonDBTM::class)) {
139+
if (!in_array($this->question->fields['itemtype'], self::$noEntityRrestrict)) {
140+
$item = new $this->question->fields['itemtype'];
141+
$this->question->fields['_is_entity_restrict'] = $item->isEntityAssign() ? '1' : '0';
142+
}
143+
}
136144
if (isset($this->question->fields['itemtype']) && is_subclass_of($this->question->fields['itemtype'], CommonTreeDropdown::class)) {
137145
$this->question->fields['_is_tree'] = '1';
138-
$item = new $this->question->fields['itemtype'];
139-
$this->question->fields['_is_entity_restrict'] = $item->isEntityAssign() ? '1' : '0';
140146
}
141147
$this->question->fields['default_values'] = Html::entities_deep($this->question->fields['default_values']);
142148
$this->deserializeValue($this->question->fields['default_values']);
@@ -176,6 +182,10 @@ public function buildParams($rand = null) {
176182
JSON_OBJECT_AS_ARRAY
177183
);
178184

185+
if (in_array($itemtype, self::$noEntityRrestrict)) {
186+
unset($dparams['entity']);
187+
}
188+
179189
switch ($itemtype) {
180190
case SLA::class:
181191
case OLA::class:
@@ -185,11 +195,6 @@ public function buildParams($rand = null) {
185195
}
186196
break;
187197

188-
case Entity::class:
189-
case Document::class:
190-
unset($dparams['entity']);
191-
break;
192-
193198
case User::class:
194199
$dparams['right'] = 'all';
195200
$currentEntity = Session::getActiveEntity();
@@ -1019,7 +1024,7 @@ protected function getEntityRestriction() {
10191024
switch ($restrictionPolicy) {
10201025
case self::ENTITY_RESTRICT_FORM:
10211026
$form = PluginFormcreatorForm::getByItem($this->getQuestion());
1022-
$formEntities = [$form->fields['entities_id']];
1027+
$formEntities = [$form->fields['entities_id'] => $form->fields['entities_id']];
10231028
if ($form->fields['is_recursive']) {
10241029
$formEntities = $formEntities + (new DBUtils())->getSonsof(Entity::getTable(), $form->fields['entities_id']);
10251030
}
@@ -1028,7 +1033,7 @@ protected function getEntityRestriction() {
10281033

10291034
case self::ENTITY_RESTRICT_BOTH:
10301035
$form = PluginFormcreatorForm::getByItem($this->getQuestion());
1031-
$formEntities = [$form->fields['entities_id']];
1036+
$formEntities = [$form->fields['entities_id'] => $form->fields['entities_id']];
10321037
if ($form->fields['is_recursive']) {
10331038
$formEntities = $formEntities + (new DBUtils())->getSonsof(Entity::getTable(), $form->fields['entities_id']);
10341039
}

inc/field/filefield.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function regex($value): bool {
286286
}
287287

288288
public function isPublicFormCompatible(): bool {
289-
return true;
289+
return false;
290290
}
291291

292292
public function getHtmlIcon() {

inc/field/glpiselectfield.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public function showForm(array $options): void {
6060
$this->question->fields['_is_tree'] = '0';
6161
$this->question->fields['_is_entity_restrict'] = '0';
6262
if (isset($this->question->fields['itemtype']) && is_subclass_of($this->question->fields['itemtype'], CommonDBTM::class)) {
63-
$item = new $this->question->fields['itemtype'];
64-
$this->question->fields['_is_entity_restrict'] = $item->isEntityAssign() ? '1' : '0';
63+
if (!in_array($this->question->fields['itemtype'], self::$noEntityRrestrict)) {
64+
$item = new $this->question->fields['itemtype'];
65+
$this->question->fields['_is_entity_restrict'] = $item->isEntityAssign() ? '1' : '0';
66+
}
6567
}
6668
if (isset($this->question->fields['itemtype']) && $this->question->fields['itemtype'] == User::class) {
6769
$this->question->fields['_is_entity_restrict'] = '1';

inc/field/textareafield.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function getRenderedHtml($domain, $canEdit = true): string {
153153
$fieldName = 'formcreator_field_' . $id;
154154
$value = $this->value;
155155
$html = '';
156+
$form = PluginFormcreatorForm::getByItem($this->getQuestion());
156157
$html .= Html::textarea([
157158
'name' => $fieldName,
158159
'editor_id' => "$fieldName$rand",
@@ -161,6 +162,7 @@ public function getRenderedHtml($domain, $canEdit = true): string {
161162
'rows' => 5,
162163
'display' => false,
163164
'enable_richtext' => true,
165+
'enable_images' => !$form->isPublicAccess(),
164166
'enable_fileupload' => false,
165167
'uploads' => $this->uploads,
166168
]);

inc/item_targetticket.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ protected function convertIds(&$parameter) {
180180
$targetTicket->getFromDB($parameter['items_id']);
181181
$parameter['items_id'] = $targetTicket->fields['uuid'];
182182
}
183+
if ($parameter['itemtype'] == PluginFormcreatorQuestion::getType()) {
184+
$question = new PluginFormcreatorQuestion();
185+
$question->getFromDB($parameter['items_id']);
186+
$parameter['items_id'] = $question->fields['uuid'];
187+
}
183188
}
184189

185190
protected function convertUuids(&$parameter) {

inc/targetchange.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
680680
$this->prepareActors($form, $formanswer);
681681

682682
if (count($this->requesters['_users_id_requester']) == 0) {
683-
$this->addActor('requester', $formanswer->fields['requester_id'], true);
683+
$this->addActor(PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER, $formanswer->fields['requester_id'], true);
684684
$requesters_id = $formanswer->fields['requester_id'];
685685
} else {
686686
$requesterAccounts = array_filter($this->requesters['_users_id_requester'], function($v) {

inc/targetproblem.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
199199
$this->prepareActors($form, $formanswer);
200200

201201
if (count($this->requesters['_users_id_requester']) == 0) {
202-
$this->addActor('requester', $formanswer->fields['requester_id'], true);
202+
$this->addActor(PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER, $formanswer->fields['requester_id'], true);
203203
$requesters_id = $formanswer->fields['requester_id'];
204204
} else {
205205
$requesterAccounts = array_filter($this->requesters['_users_id_requester'], function($v) {

inc/targetticket.class.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,11 +1129,8 @@ protected function setTargetContract($data, $formanswer) {
11291129
}
11301130

11311131
protected function setTargetSource(array $data, PluginFormcreatorFormAnswer $formanswer): array {
1132+
// do nothing with self::REQUESTSOURCE_NONE
11321133
switch ($this->fields['source_rule']) {
1133-
case self::REQUESTSOURCE_NONE:
1134-
$data['requesttypes_id'] = PluginFormcreatorCommon::getFormcreatorRequestTypeId();
1135-
break;
1136-
11371134
case self::REQUESTSOURCE_FORMCREATOR:
11381135
$data['requesttypes_id'] = $this->fields['source_question'];
11391136
break;

0 commit comments

Comments
 (0)