Migrated confirm modal to sweetalert2 lib

This commit is contained in:
johnnyq
2026-08-14 17:38:21 -04:00
parent bbbfff7413
commit 6fc94d9733
12 changed files with 89 additions and 55 deletions

View File

@@ -1,5 +1,4 @@
<?php
require_once "inc_confirm_modal.php";
?>
<?php
@@ -45,6 +44,7 @@ if (basename(dirname($_SERVER['REQUEST_URI'])) === 'guest') { ?>
<!-- AdminLTE App -->
<script src="/libs/adminlte/js/adminlte.min.js"></script>
<script src="/libs/sweetalert2/js/sweetalert2.min.js"></script>
<script src="/js/autocomplete.js"></script>
<script src="/js/app.js"></script>
<script src="/js/ajax_modal.js"></script>

View File

@@ -29,6 +29,7 @@ header("X-Frame-Options: DENY");
<!-- Custom Styles -->
<link rel="stylesheet" href="/libs/flatpickr/css/flatpickr.min.css">
<link rel="stylesheet" href="/libs/tom-select/css/tom-select.bootstrap5.min.css">
<link rel="stylesheet" href="/libs/sweetalert2/css/sweetalert2.min.css">
<link rel="stylesheet" href="/libs/DataTables/datatables.min.css">
<link rel="stylesheet" href="/libs/intl-tel-input/css/intlTelInput.min.css">
<link rel="stylesheet" href="/libs/adminlte/css/adminlte.min.css">

View File

@@ -36,23 +36,8 @@ if (!empty($_SESSION['alert_message'])) {
$alert_style = $alert_styles[$alert_type] ?? 'text-bg-secondary';
$alert_dark_text = in_array($alert_type, ['warning', 'alert', 'info'], true);
// Escape everything, then put back only these formatting tags.
$alert_allowed_tags = [
'<strong>', '</strong>',
'<b>', '</b>',
'<em>', '</em>',
'<i>', '</i>',
'<code>', '</code>',
'<br>', '<br/>', '<br />',
];
$alert_safe_message = htmlspecialchars($_SESSION['alert_message'], ENT_QUOTES, 'UTF-8');
foreach ($alert_allowed_tags as $alert_tag) {
$alert_safe_message = str_replace(
htmlspecialchars($alert_tag, ENT_QUOTES, 'UTF-8'),
$alert_tag,
$alert_safe_message
);
}
// Escaping lives in one place now - see alertMessageHtml() in functions/sanitize.php
$alert_safe_message = alertMessageHtml($_SESSION['alert_message']);
?>

View File

@@ -1,17 +0,0 @@
<div class="modal fade" id="confirmationModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmationModalLabel">Confirm</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
Are you sure?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirmSubmitBtn">Yes</button>
</div>
</div>
</div>
</div>