Skip to content

Commit dc3dcf4

Browse files
committed
fix(form_validator): manage deletion of all items for a level
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 41320ba commit dc3dcf4

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

inc/form_validator.class.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function post_deleteItem() {
273273
}
274274
}
275275

276-
if ($currentLevelCount < 1) {
276+
if ($currentLevelCount < 1) {
277277
// No more items for this level. Moving decreasing level of above levels
278278
foreach ($rows as $row) {
279279
if ($row['level'] < $this->fields['level']) {
@@ -569,8 +569,7 @@ public function getAvailableValidatorGroups() {
569569
"$profileRightTable.name" => "ticketvalidation",
570570
[
571571
'OR' => [
572-
"$profileRightTable.rights" => ['&', TicketValidation::VALIDATEREQUEST],
573-
"$profileRightTable.rights" => ['&', TicketValidation::VALIDATEINCIDENT],
572+
"$profileRightTable.rights" => ['&', TicketValidation::VALIDATEINCIDENT | TicketValidation::VALIDATEREQUEST],
574573
],
575574
],
576575
"$userTable.is_active" => '1',

inc/formanswer.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public function canValidate(): bool {
434434
$rows = $formAnswerValidation->find(
435435
[
436436
self::getForeignKeyField() => $this->getID(),
437-
'level' => ['>=', PluginFormcreatorFormAnswerValidation::getCurrentValidationLevel($this)],
437+
'level' => ['<>', PluginFormcreatorFormAnswerValidation::getCurrentValidationLevel($this)],
438438
],
439439
['itemtype ASC']
440440
);
@@ -514,7 +514,7 @@ public function showForm($ID, $options = []) {
514514
$canEdit = $this->fields['status'] == self::STATUS_REFUSED
515515
&& Session::getLoginUserID() == $this->fields['requester_id']
516516
|| $this->fields['status'] == self::STATUS_WAITING
517-
&& $this->canValidate() && $editMode;
517+
&& $this->canValidate();
518518

519519
// form title
520520
echo "<h1 class='form-title'>";
@@ -597,7 +597,7 @@ public function showForm($ID, $options = []) {
597597
}
598598
}
599599
}
600-
echo $question->getRenderedHtml($domain, $canEdit, $answers, $visibility[$question->getType()][$question->getID()]);
600+
echo $question->getRenderedHtml($domain, $editMode, $answers, $visibility[$question->getType()][$question->getID()]);
601601
$lastQuestion = $question;
602602
}
603603
echo '</div>';

inc/formanswervalidation.class.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function computeValidationStatus(PluginFormcreatorFormAnswer $form
8181
$result = $DB->request([
8282
'FROM' => self::getTable(),
8383
'WHERE' => [
84-
$formAnswerFk => $formAnswer->fields['id'],
84+
$formAnswerFk => $formAnswer->getID(),
8585
],
8686
'GROUPBY' => ['level'],
8787
]);
@@ -104,10 +104,7 @@ public static function computeValidationStatus(PluginFormcreatorFormAnswer $form
104104
'SELECT' => ['MAX' => 'level as level'],
105105
'FROM' => self::getTable(),
106106
'WHERE' => [
107-
$formAnswerFk => $formAnswer->fields['id'],
108-
['NOT' => [
109-
'status' => PluginFormcreatorForm_Validator::VALIDATION_STATUS_WAITING,
110-
]],
107+
$formAnswerFk => $formAnswer->getID(),
111108
],
112109
];
113110
$max = $DB->request($request)->next();

0 commit comments

Comments
 (0)