Skip to content

Commit

Permalink
fix(clone): error display (#178)
Browse files Browse the repository at this point in the history
* fix(clone): error display

* changelog
  • Loading branch information
Rom1-B authored Mar 21, 2024
1 parent ef3d6f8 commit c4b20c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fix behavior for ```Ticket status after an escalation``` option
- Fix cloning error display

## [2.9.3] - 2024-02-21

Expand Down
19 changes: 9 additions & 10 deletions inc/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ static function cloneAndLink($tickets_id) {
//get old ticket
$ticket = new Ticket();
if (!$ticket->getFromDB($tickets_id)) {
echo "{\"success\":false, \"message\":\"".__("Error : get old ticket", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : get old ticket', 'escalade'),false, ERROR);
exit;
}

Expand All @@ -740,7 +740,7 @@ static function cloneAndLink($tickets_id) {

//create new ticket (duplicate from previous)
if (! $newID = $ticket->add($fields)) {
echo "{\"success\":false, \"message\":\"".__("Error : adding new ticket", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : adding new ticket', 'escalade'),false, ERROR);
exit;
}

Expand All @@ -751,8 +751,7 @@ static function cloneAndLink($tickets_id) {
'tickets_id_2' => $newID,
'link' => Ticket_Ticket::LINK_TO
])) {
echo "{\"success\":false, \"message\":\"".
__("Error : adding link between the two tickets", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : adding link between the two tickets', 'escalade'),false, ERROR);
exit;
}

Expand All @@ -767,27 +766,27 @@ static function cloneAndLink($tickets_id) {
'is_private' => true,
'requesttypes_id' => 6 //other
])) {
echo "{\"success\":false, \"message\":\"".__("Error : adding followups", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : adding followups', 'escalade'),false, ERROR);
exit;
}

//add actors to the new ticket (without assign)
//users
$query_users = "INSERT INTO glpi_tickets_users
SELECT '' AS id, $newID as tickets_id, users_id, type, use_notification, alternative_email
SELECT null AS id, $newID as tickets_id, users_id, type, use_notification, alternative_email
FROM glpi_tickets_users
WHERE tickets_id = $tickets_id AND type != 2";
if (!$res = $DB->query($query_users)) {
echo "{\"success\":false, \"message\":\"".__("Error : adding actors (user)", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : adding actors (user)', 'escalade'),false, ERROR);
exit;
}
//groups
$query_groups = "INSERT INTO glpi_groups_tickets
SELECT '' AS id, $newID as tickets_id, groups_id, type
SELECT null AS id, $newID as tickets_id, groups_id, type
FROM glpi_groups_tickets
WHERE tickets_id = $tickets_id AND type != 2";
if (!$res = $DB->query($query_groups)) {
echo "{\"success\":false, \"message\":\"".__("Error : adding actors (group)", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : adding actors (group)', "escalade"),false, ERROR);
exit;
}

Expand All @@ -797,7 +796,7 @@ static function cloneAndLink($tickets_id) {
FROM glpi_documents_items
WHERE items_id = $tickets_id AND itemtype = 'Ticket'";
if (! $res = $DB->query($query_docs)) {
echo "{\"success\":false, \"message\":\"".__("Error : adding documents", "escalade")."\"}";
Session::addMessageAfterRedirect(__('Error : adding documents', 'escalade'),false, ERROR);
exit;
}

Expand Down

0 comments on commit c4b20c2

Please sign in to comment.