Skip to content

Commit

Permalink
use helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 committed Jan 6, 2025
1 parent 02b8d45 commit 82c6cf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/CommonITILObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,7 @@ public function canAdminActors()
*/
public function canAssign()
{
$is_closed = isset($this->fields['status']) && in_array($this->fields['status'], static::getClosedStatusArray());
$is_deleted = isset($this->fields['is_deleted']) && (int) $this->fields['is_deleted'] === 1;

if ($is_deleted || (!$this->isNewItem() && $is_closed)) {
if ($this->isDeleted() || (!$this->isNewItem() && !$this->isClosed())) {
return false;
}

Expand Down Expand Up @@ -3589,7 +3586,7 @@ public function isSolved(bool $include_closed = false)
}

return in_array(
$this->fields['status'],
$this->fields['status'] ?? null,
$status
);
}
Expand All @@ -3604,7 +3601,7 @@ public function isSolved(bool $include_closed = false)
public function isClosed()
{
return in_array(
$this->fields['status'],
$this->fields['status'] ?? null,
$this->getClosedStatusArray()
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ public static function getAdditionalMenuLinks()

public function canAssign()
{
$is_closed = isset($this->fields['status']) && in_array($this->fields['status'], static::getClosedStatusArray());
$is_deleted = isset($this->fields['is_deleted']) && (int) $this->fields['is_deleted'] === 1;

if ($is_deleted || (!$this->isNewItem() && $is_closed)) {
if ($this->isDeleted() || (!$this->isNewItem() && !$this->isClosed())) {
return false;
}
return Session::haveRight(static::$rightname, self::ASSIGN);
Expand Down

0 comments on commit 82c6cf9

Please sign in to comment.