Skip to content

Commit

Permalink
Change constant name from STATUS_WAITING to STATUS_APPROVAL
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLvr committed Feb 9, 2024
1 parent b1a21d8 commit d53bd46
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion inc/common.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static function getTicketStatusForIssue(Ticket $item) : int {
switch ($item->fields['global_validation']) {
case CommonITILValidation::WAITING:
if (!in_array($item->fields['status'], [Ticket::SOLVED, Ticket::CLOSED])) {
$status = PluginFormcreatorFormAnswer::STATUS_WAITING;
$status = PluginFormcreatorFormAnswer::STATUS_APPROVAL;
}
break;
case CommonITILValidation::REFUSED:
Expand Down
6 changes: 3 additions & 3 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function getMenuContent() {
title="' . PluginFormcreatorIssue::getTypeName(Session::getPluralNumber()) . '"></i>';

$menu['links']['search'] = PluginFormcreatorFormList::getSearchURL(false);
$menu['links'][$validation_image] = PluginFormcreatorFormAnswer::getSearchURL(false).'?criteria[0][link]=AND&criteria[0][field]=8&criteria[0][searchtype]=equals&criteria[0][value]=' . PluginFormcreatorFormAnswer::STATUS_WAITING;
$menu['links'][$validation_image] = PluginFormcreatorFormAnswer::getSearchURL(false).'?criteria[0][link]=AND&criteria[0][field]=8&criteria[0][searchtype]=equals&criteria[0][value]=' . PluginFormcreatorFormAnswer::STATUS_APPROVAL;
$menu['links'][$import_image] = PluginFormcreatorForm::getFormURL(false)."?import_form=1";
$menu['links'][$requests_image] = PluginFormcreatorIssue::getSearchURL(false);
return $menu;
Expand Down Expand Up @@ -939,7 +939,7 @@ protected function showMyLastForms() : void {
echo '<ul class="list-group">';
foreach ($search['data']['rows'] as $formAnswer) {
switch ($formAnswer['raw']["{$rawKeyBase}_8"]) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
case PluginFormcreatorFormAnswer::STATUS_APPROVAL:
$status = CommonITILObject::WAITING;
break;
case PluginFormcreatorFormAnswer::STATUS_REFUSED:
Expand Down Expand Up @@ -1010,7 +1010,7 @@ protected function showMyLastForms() : void {
echo '<ul class="list-group">';
foreach ($search['data']['rows'] as $formAnswer) {
switch ($formAnswer['raw']["{$rawKeyBase}_8"]) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
case PluginFormcreatorFormAnswer::STATUS_APPROVAL:
$status = CommonITILObject::WAITING;
break;
case PluginFormcreatorFormAnswer::STATUS_REFUSED:
Expand Down
28 changes: 14 additions & 14 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PluginFormcreatorFormAnswer extends CommonDBTM

// Values choosen to not conflict with status of ticket constants
// @see PluginFormcreatorIssue::getNewStatusArray
const STATUS_WAITING = 101;
const STATUS_APPROVAL = 101;
const STATUS_REFUSED = 102;
const STATUS_ACCEPTED = 103;

Expand All @@ -75,7 +75,7 @@ class PluginFormcreatorFormAnswer extends CommonDBTM

public static function getStatuses() {
return [
self::STATUS_WAITING => __('Waiting for approval'),
self::STATUS_APPROVAL => __('Waiting for approval'),
self::STATUS_REFUSED => __('Refused', 'formcreator'),
self::STATUS_ACCEPTED => __('Accepted', 'formcreator'),
];
Expand Down Expand Up @@ -361,7 +361,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options
case 'status' :
if (!isAPI()) {
switch ($values[$field]) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
case PluginFormcreatorFormAnswer::STATUS_APPROVAL:
$status = CommonITILObject::WAITING;
break;
case PluginFormcreatorFormAnswer::STATUS_REFUSED:
Expand Down Expand Up @@ -619,7 +619,7 @@ public function showForm($ID, $options = []) {
// Can the current user edit the answers ?
$canEdit = $this->fields['status'] == self::STATUS_REFUSED
&& Session::getLoginUserID() == $this->fields['requester_id']
|| $this->fields['status'] == self::STATUS_WAITING
|| $this->fields['status'] == self::STATUS_APPROVAL
&& $this->canValidate() && $editMode;

// form title
Expand Down Expand Up @@ -727,7 +727,7 @@ public function showForm($ID, $options = []) {
echo '</div>';
echo '</div>';

} else if (($this->fields['status'] == self::STATUS_WAITING) && $this->canValidate()) {
} else if (($this->fields['status'] == self::STATUS_APPROVAL) && $this->canValidate()) {
// Display validation form
echo '<div class="form-group required line1">';
echo '<label for="comment">' . __('Comment', 'formcreator') . ' <span class="red">*</span></label>';
Expand Down Expand Up @@ -873,7 +873,7 @@ public function prepareInputForUpdate($input) {
}

$skipValidation = false;
$input['status'] = self::STATUS_WAITING;
$input['status'] = self::STATUS_APPROVAL;
if (isset($input['refuse_formanswer']) || isset($input['accept_formanswer'])) {
// The formanswer is being acepted or refused

Expand Down Expand Up @@ -1238,7 +1238,7 @@ public function post_addItem() {

// 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
$formAnswer->updateStatus(self::STATUS_WAITING);
$formAnswer->updateStatus(self::STATUS_APPROVAL);
return;
}
}
Expand Down Expand Up @@ -1290,7 +1290,7 @@ public function post_updateItem($history = 1) {

// TODO: find a way to validate the answers
// If the form is not being validated, nothing gives the power to anyone to validate the answers
$this->updateStatus(self::STATUS_WAITING);
$this->updateStatus(self::STATUS_APPROVAL);
return;
}
}
Expand Down Expand Up @@ -1319,7 +1319,7 @@ public function post_purgeItem() {
);

// If the form was waiting for validation
if ($this->fields['status'] == self::STATUS_WAITING) {
if ($this->fields['status'] == self::STATUS_APPROVAL) {
// Notify the requester
NotificationEvent::raiseEvent('plugin_formcreator_deleted', $this);
}
Expand Down Expand Up @@ -1503,7 +1503,7 @@ protected function validateValidator(array $input): bool {

private function sendNotification() {
switch ($this->input['status']) {
case self::STATUS_WAITING :
case self::STATUS_APPROVAL :
// Notify the requester
NotificationEvent::raiseEvent('plugin_formcreator_form_created', $this);
// Notify the validator
Expand Down Expand Up @@ -1803,7 +1803,7 @@ protected function setValidator(array $input): array {
// The requester is the validator. No need to validate
break;
}
$input['status'] = self::STATUS_WAITING;
$input['status'] = self::STATUS_APPROVAL;
break;

case PluginFormcreatorForm::VALIDATION_GROUP:
Expand All @@ -1816,7 +1816,7 @@ protected function setValidator(array $input): array {
// The requester is a member of the validator group
break;
}
$input['status'] = self::STATUS_WAITING;
$input['status'] = self::STATUS_APPROVAL;
break;
}
}
Expand Down Expand Up @@ -1919,7 +1919,7 @@ public function getApprovers(array $crit = []): ?array {
* @return array|null
*/
public function getCurrentApprovers(): ?array {
if ($this->fields['status'] != self::STATUS_WAITING) {
if ($this->fields['status'] != self::STATUS_APPROVAL) {
return null;
}

Expand Down Expand Up @@ -2003,7 +2003,7 @@ public function getAggregatedStatus(): ?int {
continue;
}
$ticketStatus = PluginFormcreatorCommon::getTicketStatusForIssue($generatedTarget);
if ($ticketStatus >= PluginFormcreatorFormAnswer::STATUS_WAITING) {
if ($ticketStatus >= PluginFormcreatorFormAnswer::STATUS_APPROVAL) {
// Ignore tickets refused or pending for validation
// getTicketStatusForIssue() does not returns STATUS_ACCEPTED
continue;
Expand Down
8 changes: 4 additions & 4 deletions inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
IF(`$ticketTable`.`status` IN ('" . CommonITILObject::SOLVED . "', '" . CommonITILObject::CLOSED . "'),
`$ticketTable`.`status`,
IF(`$ticketTable`.`global_validation` = '" . CommonITILValidation::WAITING . "',
'" . PluginFormcreatorFormAnswer::STATUS_WAITING . "',
'" . PluginFormcreatorFormAnswer::STATUS_APPROVAL . "',
'" . PluginFormcreatorFormAnswer::STATUS_REFUSED . "'
)
)
Expand Down Expand Up @@ -1134,7 +1134,7 @@ static function getNewStatusArray() {
}

static function getPendingStatusArray() {
return [Ticket::WAITING, PluginFormcreatorFormAnswer::STATUS_WAITING];
return [Ticket::WAITING, PluginFormcreatorFormAnswer::STATUS_APPROVAL];
}

static function getProcessStatusArray() {
Expand All @@ -1147,7 +1147,7 @@ static function getReopenableStatusArray() {

static function getAllStatusArray($withmetaforsearch = false) {
$ticket_status = Ticket::getAllStatusArray($withmetaforsearch);
$form_status = [PluginFormcreatorFormAnswer::STATUS_WAITING, PluginFormcreatorFormAnswer::STATUS_ACCEPTED, PluginFormcreatorFormAnswer::STATUS_REFUSED];
$form_status = [PluginFormcreatorFormAnswer::STATUS_APPROVAL, PluginFormcreatorFormAnswer::STATUS_ACCEPTED, PluginFormcreatorFormAnswer::STATUS_REFUSED];
$form_status = array_combine($form_status, $form_status);
$all_status = $ticket_status + $form_status;
return $all_status;
Expand Down Expand Up @@ -1189,7 +1189,7 @@ static function getValidateCriteria() {
return ['criteria' => [['link' => 'AND',
'field' => 4,
'searchtype' => 'equals',
'value' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'value' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
],
],
'reset' => 'reset'];
Expand Down
2 changes: 1 addition & 1 deletion tests/3-unit/PluginFormcreatorCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function providerGetTicketStatusForIssue() {
$ticket->fields['global_validation'] = \CommonITILValidation::WAITING;
$dataSet = [
'ticket' => $ticket,
'expected' => \PluginFormcreatorFormAnswer::STATUS_WAITING
'expected' => \PluginFormcreatorFormAnswer::STATUS_APPROVAL
];
yield $dataSet;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/3-unit/PluginFormcreatorFormAnswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function providerPrepareInputForAdd() {
'formcreator_validator' => $user::getType() . '_' . $user->getID(),
'users_id_validator' => $user->getID(),
'groups_id_validator' => 0,
'status' => $testedClassName::STATUS_WAITING,
'status' => $testedClassName::STATUS_APPROVAL,
'request_date' => $_SESSION['glpi_currenttime'],
'comment' => '',
],
Expand Down
4 changes: 2 additions & 2 deletions tests/3-unit/PluginFormcreatorIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function providerGetsyncIssuesRequest_ticketUnderValidation() {
'items_id' => $ticket->getID(),
'display_id' => 't_' . $ticket->getID(),
'name' => $ticket->fields['name'],
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'requester_id' => $ticket->fields['users_id_recipient'],
'date_creation' => $ticket->fields['date'],
'date_mod' => $ticket->fields['date_mod'],
Expand Down Expand Up @@ -422,7 +422,7 @@ public function providerGetsyncIssuesRequest_validatedTicket() {
'items_id' => $ticket2->getID(),
'display_id' => 't_' . $ticket2->getID(),
'name' => $ticket2->fields['name'],
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'requester_id' => $ticket2->fields['users_id_recipient'],
'date_creation' => $ticket2->fields['date'],
'date_mod' => $ticket2->fields['date_mod'],
Expand Down
10 changes: 5 additions & 5 deletions tests/3-unit/PluginFormcreatorTargetTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public function providerSetTargetType() {
PluginFormcreatorForm::getForeignKeyField() => $form1->getID(),
'name' => $form1->fields['name'],
'requester_id' => 2, // glpi user id
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'formcreator_validator' => 2, // Glpi user ID
'formcreator_field_' . $question1->getID() => (string) Ticket::INCIDENT_TYPE,
]),
Expand All @@ -565,7 +565,7 @@ public function providerSetTargetType() {
PluginFormcreatorForm::getForeignKeyField() => $form1->getID(),
'name' => $form1->fields['name'],
'requester_id' => 2, // glpi user id
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'formcreator_validator' => 2, // Glpi user ID
'formcreator_field_' . $question1->getID() => (string) Ticket::DEMAND_TYPE,
]),
Expand All @@ -577,7 +577,7 @@ public function providerSetTargetType() {
PluginFormcreatorForm::getForeignKeyField() => $form2->getID(),
'name' => $form2->fields['name'],
'requester_id' => 2, // glpi user id
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'formcreator_validator' => 2, // Glpi user ID
'formcreator_field_' . $question2->getID() => (string) Ticket::DEMAND_TYPE,
]),
Expand All @@ -589,7 +589,7 @@ public function providerSetTargetType() {
PluginFormcreatorForm::getForeignKeyField() => $form2->getID(),
'name' => $form2->fields['name'],
'requester_id' => 2, // glpi user id
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'formcreator_validator' => 2, // Glpi user ID
'formcreator_field_' . $question2->getID() => (string) Ticket::INCIDENT_TYPE,
]),
Expand Down Expand Up @@ -1100,7 +1100,7 @@ public function providerSetTargetAssociatedItem_1() {
PluginFormcreatorForm::getForeignKeyField() => $form->getID(),
'name' => $form->fields['name'],
'requester_d' => 2, // glpi user id
'status' => PluginFormcreatorFormAnswer::STATUS_WAITING,
'status' => PluginFormcreatorFormAnswer::STATUS_APPROVAL,
'formcreator_field_' . $question->getID() => (string) $computer->getID(),
]);
$this->boolean($formAnswer->isNewItem())->isFalse();
Expand Down

0 comments on commit d53bd46

Please sign in to comment.