Skip to content

Commit 226b117

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents c8a4645 + 1d47856 commit 226b117

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

main/inc/lib/TicketManager.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,42 @@ public static function saveMessageAttachmentFile(
774774
}
775775
}
776776

777+
public static function deleteTicket($ticketId)
778+
{
779+
$ticketId = (int) $ticketId;
780+
if ($ticketId <= 0) {
781+
return false;
782+
}
783+
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
784+
$table_ticket_message = Database::get_main_table('ticket_message');
785+
$table_ticket_assigned_log = Database::get_main_table('ticket_assigned_log');
786+
$table_ticket_message_attachments = Database::get_main_table('ticket_message_attachments');
787+
788+
$sql_get_message_ids = "SELECT id FROM $table_ticket_message WHERE ticket_id = $ticketId";
789+
$sql_delete_attachments = "DELETE FROM $table_ticket_message_attachments WHERE message_id IN ($sql_get_message_ids)";
790+
Database::query($sql_delete_attachments);
791+
792+
$sql_assigned_log = "DELETE FROM $table_ticket_assigned_log WHERE ticket_id = $ticketId";
793+
Database::query($sql_assigned_log);
794+
795+
$sql_messages = "DELETE FROM $table_ticket_message WHERE ticket_id = $ticketId";
796+
Database::query($sql_messages);
797+
798+
$sql_get_category = "SELECT category_id FROM $table_support_tickets WHERE id = $ticketId";
799+
$res = Database::query($sql_get_category);
800+
if ($row = Database::fetch_array($res)) {
801+
$category_id = (int)$row['category_id'];
802+
$table_ticket_category = Database::get_main_table('ticket_category');
803+
$sql_update_category = "UPDATE $table_ticket_category SET total_tickets = total_tickets - 1 WHERE id = $category_id AND total_tickets > 0";
804+
Database::query($sql_update_category);
805+
}
806+
807+
$sql_ticket = "DELETE FROM $table_support_tickets WHERE id = $ticketId";
808+
Database::query($sql_ticket);
809+
810+
return true;
811+
}
812+
777813
/**
778814
* Get tickets by userId.
779815
*
@@ -1008,6 +1044,14 @@ public static function getTicketsByCurrentUser(
10081044
<div class="blackboard_hide" id="div_'.$row['ticket_id'].'">&nbsp;&nbsp;</div>
10091045
</a>&nbsp;&nbsp;';
10101046
}
1047+
if ($isAdmin) {
1048+
$project_id = isset($row['project_id']) ? $row['project_id'] : (isset($_GET['project_id']) ? $_GET['project_id'] : 0);
1049+
$delete_link = '<a href="tickets.php?action=delete&ticket_id='.$row['ticket_id'].'&project_id='.$project_id.'" onclick="return confirm(\''.htmlentities(get_lang('AreYouSureYouWantToDeleteThisTicket')).'\')">'
1050+
. Display::return_icon('delete.png', get_lang('Delete')) .
1051+
'</a>';
1052+
$ticket[] = $delete_link;
1053+
}
1054+
10111055
$tickets[] = $ticket;
10121056
}
10131057

main/lang/english/trad4all.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9100,4 +9100,6 @@
91009100
$BackToDateOrder = "Return to the chronological order";
91019101
$SeeAlphabeticalOrder = "View in alphabetical order";
91029102
$HideComment = "Hide comments";
9103+
$AreYouSureYouWantToDeleteThisTicket = "Are you sure you want to delete this ticket ?";
9104+
$TicketDeleted = "Ticket deleted";
91039105
?>

main/lang/french/trad4all.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9035,4 +9035,6 @@
90359035
$BackToDateOrder = "Retour à l'ordre chronologique";
90369036
$SeeAlphabeticalOrder = "Voir par ordre alphabétique";
90379037
$HideComment = "Cacher les commentaires";
9038+
$AreYouSureYouWantToDeleteThisTicket = "Êtes vous sûr de vouloir supprimer ce ticket ?";
9039+
$TicketDeleted = "Ticket supprimé";
90389040
?>

main/lang/spanish/trad4all.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9125,4 +9125,6 @@
91259125
$BackToDateOrder = "Retorno al orden cronológico";
91269126
$SeeAlphabeticalOrder = "Ver en orden alfabético";
91279127
$HideComment = "Ocultar comentarios";
9128+
$AreYouSureYouWantToDeleteThisTicket = "¿Estás seguro de que quieres eliminar este ticket?";
9129+
$TicketDeleted = "Ticket eliminado";
91289130
?>

main/ticket/tickets.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ function display_advanced_search_form () {
7272
}
7373

7474
switch ($action) {
75+
case 'delete':
76+
if (isset($_GET['ticket_id'])) {
77+
TicketManager::deleteTicket((int)$_GET['ticket_id']);
78+
Display::addFlash(Display::return_message(
79+
sprintf(
80+
get_lang('TicketDeleted'),
81+
),
82+
null,
83+
false
84+
));
85+
header('Location: '.api_get_self().'?project_id='.$projectId);
86+
exit;
87+
}
88+
break;
7589
case 'alert':
7690
if (!$isAdmin && isset($_GET['ticket_id'])) {
7791
TicketManager::send_alert($_GET['ticket_id'], $user_id);
@@ -409,6 +423,7 @@ function display_advanced_search_form () {
409423
$table->set_header(5, get_lang('CreatedBy'), true);
410424
$table->set_header(6, get_lang('AssignedTo'), true);
411425
$table->set_header(7, get_lang('Message'), true);
426+
$table->set_header(8, get_lang('Delete'), true);
412427
} else {
413428
if ($isAllow == false) {
414429
echo Display::page_subheader(get_lang('MyTickets'));

0 commit comments

Comments
 (0)