From b89556e6d21249f959c4a199d71772afe658c490 Mon Sep 17 00:00:00 2001 From: Romain Lecouvreur <102067890+RomainLvr@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:34:26 +0200 Subject: [PATCH] Fix climbing with history & update full history window (#212) * Fix climbing with history & update full history window * Update CHANGELOG.md --- CHANGELOG.md | 5 ++++ front/climb_group.php | 4 +--- front/popup_histories.php | 4 ---- inc/history.class.php | 50 ++++++++++++++++++++++++++++----------- inc/ticket.class.php | 17 ++++--------- 5 files changed, 46 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ce659..a67a863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Prevent an escalation when a ticket is updated +- Fix climbing with history + +### Changed + +- Full history window (now is a modal) ## [2.9.7] - 2024-07-04 diff --git a/front/climb_group.php b/front/climb_group.php index e806dff..0fa8ea0 100644 --- a/front/climb_group.php +++ b/front/climb_group.php @@ -37,6 +37,4 @@ Html::displayErrorAndDie(__("missing parameters", "escalade")); } -$full_history = (isset($_REQUEST['full_history'])); - -PluginEscaladeTicket::climb_group($_REQUEST['tickets_id'], $_REQUEST['groups_id'], $full_history); +PluginEscaladeTicket::climb_group($_REQUEST['tickets_id'], $_REQUEST['groups_id']); diff --git a/front/popup_histories.php b/front/popup_histories.php index 2da5f02..31f5b97 100644 --- a/front/popup_histories.php +++ b/front/popup_histories.php @@ -30,10 +30,6 @@ include("../../../inc/includes.php"); -Html::popHeader(__("full assignation history", "escalade"), $_SERVER['PHP_SELF']); -echo "

" . __("Close") . ""; -echo "
"; - echo "
"; PluginEscaladeHistory::getHistory($_REQUEST['tickets_id'], true); echo "
"; diff --git a/inc/history.class.php b/inc/history.class.php index b3a80d3..fb94e76 100644 --- a/inc/history.class.php +++ b/inc/history.class.php @@ -93,7 +93,7 @@ public static function getHistory($tickets_id, $full_history = false) $use_filter_assign_group = false; } - $plugin_dir = ($full_history) ? ".." : Plugin::getWebDir('escalade'); + $plugin_dir = Plugin::getWebDir('escalade'); //get all line for this ticket $group = new Group(); @@ -122,18 +122,36 @@ public static function getHistory($tickets_id, $full_history = false) echo "
"; if (! $use_filter_assign_group || isset($filter_groups_id[$hline['groups_id']])) { - //up link and image - echo ""; + $rand = mt_rand(); + // Remplacement du lien par un formulaire + echo "
"; + echo ""; + echo ""; + echo ""; + echo "
"; + + echo ""; } else { echo "   "; } - //group link + //group link echo "  "; if ($group->getFromDB($hline['groups_id'])) { echo self::showGroupLink($group, $full_history); @@ -148,11 +166,15 @@ public static function getHistory($tickets_id, $full_history = false) } //In case there are more than 10 group changes, a popup can display historical - if ($nb_histories - 1 > self::HISTORY_LIMIT && ! $full_history) { - echo "..."; + if ($nb_histories - 1 > self::HISTORY_LIMIT && !$full_history) { + echo Ajax::createModalWindow( + 'full_history', + $plugin_dir . "/front/popup_histories.php?tickets_id=" . $tickets_id, + [ + 'title' => __("full assignation history", "escalade") + ] + ); + echo "..."; } echo "
"; diff --git a/inc/ticket.class.php b/inc/ticket.class.php index c3fe543..4e4d9d5 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -497,7 +497,7 @@ public static function assignUserGroup(Ticket $ticket) * @param int $groups_id the group to assign * @return void */ - public static function climb_group($tickets_id, $groups_id, $full_history = false) + public static function climb_group($tickets_id, $groups_id) { //don't add group if already exist for this ticket $group_ticket = new Group_Ticket(); @@ -517,8 +517,9 @@ public static function climb_group($tickets_id, $groups_id, $full_history = fals if ($_SESSION['plugins']['escalade']['config']['ticket_last_status'] != -1) { $_form_object['status'] = $_SESSION['plugins']['escalade']['config']['ticket_last_status']; } + $ticket_details = $_POST['ticket_details'] ?? $_GET['ticket_details'] ?? []; $updates_ticket = new Ticket(); - $updates_ticket->update($_POST['ticket_details'] + [ + $updates_ticket->update($ticket_details + [ '_actors' => PluginEscaladeTicket::getTicketFieldsWithActors($tickets_id, $groups_id), '_plugin_escalade_no_history' => true, // Prevent a duplicated task to be added 'actortype' => CommonITILActor::ASSIGN, @@ -527,17 +528,7 @@ public static function climb_group($tickets_id, $groups_id, $full_history = fals ]); } - if (!$full_history) { - Html::back(); - } else { - //reload parent window and close popup - echo ""; - } + Html::back(); }