Feature Add Bulk Cancel and Delete to Mail Queue for mail that are any status other than sent
This commit is contained in:
+38
-4
@@ -37,6 +37,24 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="dropdown float-right" id="bulkActionButton" hidden>
|
||||||
|
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||||
|
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<button class="dropdown-item"
|
||||||
|
type="submit" form="bulkActions" name="bulk_cancel_emails">
|
||||||
|
<i class="fas fa-fw fa-ban mr-2"></i>Cancel
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<button class="dropdown-item text-danger text-bold"
|
||||||
|
type="submit" form="bulkActions" name="bulk_delete_emails">
|
||||||
|
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse mt-3 <?php if (!empty($_GET['dtf'])) { echo "show"; } ?>" id="advancedFilter">
|
<div class="collapse mt-3 <?php if (!empty($_GET['dtf'])) { echo "show"; } ?>" id="advancedFilter">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -72,10 +90,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<hr>
|
<hr>
|
||||||
|
<form id="bulkActions" action="post.php" method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
|
||||||
<div class="table-responsive-sm">
|
<div class="table-responsive-sm">
|
||||||
<table class="table table-sm table-striped table-borderless table-hover">
|
<table class="table table-sm table-striped table-borderless table-hover">
|
||||||
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="bg-light pr-0">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=email_id&order=<?php echo $disp; ?>">ID</a></th>
|
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=email_id&order=<?php echo $disp; ?>">ID</a></th>
|
||||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=email_queued_at&order=<?php echo $disp; ?>">Queued</a></th>
|
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=email_queued_at&order=<?php echo $disp; ?>">Queued</a></th>
|
||||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=email_from&order=<?php echo $disp; ?>">From</a></th>
|
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=email_from&order=<?php echo $disp; ?>">From</a></th>
|
||||||
@@ -114,6 +139,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="pr-0 bg-light">
|
||||||
|
<?php if ($email_status !== 3) { ?>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input bulk-select" type="checkbox" name="email_ids[]" value="<?php echo $email_id ?>">
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
<td><?php echo $email_id; ?></td>
|
<td><?php echo $email_id; ?></td>
|
||||||
<td><?php echo $email_queued_at; ?></td>
|
<td><?php echo $email_queued_at; ?></td>
|
||||||
<td><?php echo "$email_from<br><small class='text-secondary'>$email_from_name</small>"?></td>
|
<td><?php echo "$email_from<br><small class='text-secondary'>$email_from_name</small>"?></td>
|
||||||
@@ -132,7 +164,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<!-- Allow cancelling a message if it hasn't yet been picked up (e.g. stuck/bugged) -->
|
<!-- Allow cancelling a message if it hasn't yet been picked up (e.g. stuck/bugged) -->
|
||||||
<?php if ($email_status == 0) { ?>
|
<?php if ($email_status !== 3) { ?>
|
||||||
<a class="btn btn-sm btn-danger confirm-link" href="post.php?cancel_mail=<?php echo $email_id; ?>"><i class="fas fa-fw fa-trash"></i></a>
|
<a class="btn btn-sm btn-danger confirm-link" href="post.php?cancel_mail=<?php echo $email_id; ?>"><i class="fas fa-fw fa-trash"></i></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
@@ -146,11 +178,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<?php require_once "pagination.php";
|
</form>
|
||||||
?>
|
|
||||||
|
<?php require_once "pagination.php"; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="js/bulk_actions.js"></script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "footer.php";
|
require_once "footer.php";
|
||||||
|
|
||||||
|
|||||||
@@ -566,6 +566,63 @@ if (isset($_GET['cancel_mail'])) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['bulk_cancel_emails'])) {
|
||||||
|
validateAdminRole();
|
||||||
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
|
$count = 0; // Default 0
|
||||||
|
$email_ids = $_POST['email_ids']; // Get array of email IDs to be cancelled
|
||||||
|
|
||||||
|
if (!empty($email_ids)) {
|
||||||
|
|
||||||
|
// Cycle through array and mark each email as failed
|
||||||
|
foreach ($email_ids as $email_id) {
|
||||||
|
|
||||||
|
$email_id = intval($email_id);
|
||||||
|
mysqli_query($mysqli,"UPDATE email_queue SET email_status = 2, email_attempts = 99, email_failed_at = NOW() WHERE email_id = $email_id");
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Email', log_action = 'Cancel', log_description = '$session_name bulk cancelled $count emails from the mail Queue', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Cancelled $count email(s)";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['bulk_delete_emails'])) {
|
||||||
|
validateAdminRole();
|
||||||
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
|
$count = 0; // Default 0
|
||||||
|
$email_ids = $_POST['email_ids']; // Get array of email IDs to be deleted
|
||||||
|
|
||||||
|
if (!empty($email_ids)) {
|
||||||
|
|
||||||
|
// Cycle through array and delete each email
|
||||||
|
foreach ($email_ids as $email_id) {
|
||||||
|
|
||||||
|
$email_id = intval($email_id);
|
||||||
|
mysqli_query($mysqli,"DELETE FROM email_queue WHERE email_id = $email_id");
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Email', log_action = 'Delete', log_description = '$session_name bulk deleted $count emails from the mail Queue', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_type'] = "danger";
|
||||||
|
$_SESSION['alert_message'] = "Deleted $count email(s)";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET['download_database'])) {
|
if (isset($_GET['download_database'])) {
|
||||||
|
|
||||||
validateCSRFToken($_GET['csrf_token']);
|
validateCSRFToken($_GET['csrf_token']);
|
||||||
|
|||||||
Reference in New Issue
Block a user