Skip to content

Commit ace94c0

Browse files
committed
chore: Update urgency field to use the enum insted of hardcoded value
1 parent 435b48b commit ace94c0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/CommonITILObject.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*
3333
* ---------------------------------------------------------------------
3434
*/
35+
3536
use Glpi\Application\View\TemplateRenderer;
3637
use Glpi\ContentTemplates\Parameters\CommonITILObjectParameters;
3738
use Glpi\DBAL\QueryExpression;
@@ -52,6 +53,7 @@
5253
use Glpi\RichText\UserMention;
5354
use Glpi\Search\Output\HTMLSearchOutput;
5455
use Glpi\Team\Team;
56+
use Glpi\Urgency;
5557
use Safe\Exceptions\DatetimeException;
5658

5759
use function Safe\getimagesize;
@@ -2333,6 +2335,8 @@ public function prepareInputForUpdate($input)
23332335
private function handleReadonlyFields(array $input, bool $isAdd = false): array
23342336
{
23352337
$tt = $this->getITILTemplateFromInput($input);
2338+
$tt->getFromDBWithData($tt->getID()); // We load the fields (predefined and readonly)
2339+
23362340
foreach (array_keys($tt->readonly) as $read_only_field) {
23372341
if ($isAdd && array_key_exists($read_only_field, $tt->predefined)) {
23382342
$input[$read_only_field] = $tt->predefined[$read_only_field];
@@ -2832,7 +2836,7 @@ public function prepareInputForAdd($input)
28322836
}
28332837

28342838
// save value before clean;
2835-
$title = ltrim($input['name']);
2839+
$title = ltrim($input['name'] ?? '');
28362840

28372841
// Set default status to avoid notice
28382842
if (!isset($input["status"])) {
@@ -2843,7 +2847,7 @@ public function prepareInputForAdd($input)
28432847
!isset($input["urgency"])
28442848
|| !($CFG_GLPI['urgency_mask'] & (1 << $input["urgency"]))
28452849
) {
2846-
$input["urgency"] = 3;
2850+
$input["urgency"] = Urgency::MEDIUM->value;
28472851
}
28482852
if (
28492853
!isset($input["impact"])
@@ -2894,8 +2898,8 @@ public function prepareInputForAdd($input)
28942898
}
28952899

28962900
// No name set name
2897-
$input["name"] = ltrim($input["name"]);
2898-
$input['content'] = ltrim($input['content']);
2901+
$input["name"] = ltrim($input["name"] ?? '');
2902+
$input['content'] = ltrim($input['content'] ?? '');
28992903
if (empty($input["name"])) {
29002904
// Build name based on content
29012905

src/Ticket.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use Glpi\RichText\RichText;
4646
use Glpi\RichText\UserMention;
4747
use Glpi\Search\DefaultSearchRequestInterface;
48+
use Glpi\Urgency;
4849
use Safe\DateTime;
4950

5051
use function Safe\preg_match;
@@ -3489,7 +3490,7 @@ public static function getDefaultValues($entity = 0)
34893490
'name' => '',
34903491
'content' => '',
34913492
'itilcategories_id' => 0,
3492-
'urgency' => 3,
3493+
'urgency' => Urgency::MEDIUM->value,
34933494
'impact' => 3,
34943495
'priority' => self::computePriority(3, 3),
34953496
'requesttypes_id' => $requesttype,

0 commit comments

Comments
 (0)