Skip to content

Commit

Permalink
fix(form_validator): manage deletion of all items for a level
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Apr 1, 2021
1 parent 41320ba commit dc3dcf4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions inc/form_validator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function post_deleteItem() {
}
}

if ($currentLevelCount < 1) {
if ($currentLevelCount < 1) {
// No more items for this level. Moving decreasing level of above levels
foreach ($rows as $row) {
if ($row['level'] < $this->fields['level']) {
Expand Down Expand Up @@ -569,8 +569,7 @@ public function getAvailableValidatorGroups() {
"$profileRightTable.name" => "ticketvalidation",
[
'OR' => [
"$profileRightTable.rights" => ['&', TicketValidation::VALIDATEREQUEST],
"$profileRightTable.rights" => ['&', TicketValidation::VALIDATEINCIDENT],
"$profileRightTable.rights" => ['&', TicketValidation::VALIDATEINCIDENT | TicketValidation::VALIDATEREQUEST],
],
],
"$userTable.is_active" => '1',
Expand Down
6 changes: 3 additions & 3 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public function canValidate(): bool {
$rows = $formAnswerValidation->find(
[
self::getForeignKeyField() => $this->getID(),
'level' => ['>=', PluginFormcreatorFormAnswerValidation::getCurrentValidationLevel($this)],
'level' => ['<>', PluginFormcreatorFormAnswerValidation::getCurrentValidationLevel($this)],
],
['itemtype ASC']
);
Expand Down Expand Up @@ -514,7 +514,7 @@ public function showForm($ID, $options = []) {
$canEdit = $this->fields['status'] == self::STATUS_REFUSED
&& Session::getLoginUserID() == $this->fields['requester_id']
|| $this->fields['status'] == self::STATUS_WAITING
&& $this->canValidate() && $editMode;
&& $this->canValidate();

// form title
echo "<h1 class='form-title'>";
Expand Down Expand Up @@ -597,7 +597,7 @@ public function showForm($ID, $options = []) {
}
}
}
echo $question->getRenderedHtml($domain, $canEdit, $answers, $visibility[$question->getType()][$question->getID()]);
echo $question->getRenderedHtml($domain, $editMode, $answers, $visibility[$question->getType()][$question->getID()]);
$lastQuestion = $question;
}
echo '</div>';
Expand Down
7 changes: 2 additions & 5 deletions inc/formanswervalidation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function computeValidationStatus(PluginFormcreatorFormAnswer $form
$result = $DB->request([
'FROM' => self::getTable(),
'WHERE' => [
$formAnswerFk => $formAnswer->fields['id'],
$formAnswerFk => $formAnswer->getID(),
],
'GROUPBY' => ['level'],
]);
Expand All @@ -104,10 +104,7 @@ public static function computeValidationStatus(PluginFormcreatorFormAnswer $form
'SELECT' => ['MAX' => 'level as level'],
'FROM' => self::getTable(),
'WHERE' => [
$formAnswerFk => $formAnswer->fields['id'],
['NOT' => [
'status' => PluginFormcreatorForm_Validator::VALIDATION_STATUS_WAITING,
]],
$formAnswerFk => $formAnswer->getID(),
],
];
$max = $DB->request($request)->next();
Expand Down

0 comments on commit dc3dcf4

Please sign in to comment.