mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
137 lines
7.8 KiB
PHP
137 lines
7.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Admin > Ignored Senders - addresses and domains whose email the ticket mailbox sets aside (functions/mail_ignore.php):
|
|
* no ticket, no reply on one, no answer, no Unprocessed Email entry. Each with why, who added it, and how many emails it
|
|
* set aside and the last. New and edit in modals/email_ignored_sender/email_ignored_sender.php; the handlers are
|
|
* admin/post/email_ignored_sender.php.
|
|
*/
|
|
|
|
// Default Column Sortby Filter
|
|
$sort = "ignored_sender_match";
|
|
$order = "ASC";
|
|
|
|
require_once "includes/inc_all_admin.php";
|
|
|
|
if (!mailIgnoreReady()) { ?>
|
|
<div class="alert alert-warning">Ignored senders need the database update - <a href="update.php" class="alert-link">Maintenance > Update</a>.</div>
|
|
<?php require_once "../includes/footer.php";
|
|
return;
|
|
}
|
|
|
|
// Only these sort - an unknown column would take the page down
|
|
$sortable_columns = [
|
|
'ignored_sender_match' => "ignored_sender_match $order",
|
|
'ignored_sender_matches' => "ignored_sender_matches $order, ignored_sender_match ASC",
|
|
'ignored_sender_matched_at' => "ignored_sender_matched_at IS NULL, ignored_sender_matched_at $order, ignored_sender_match ASC",
|
|
'ignored_sender_created_at' => "ignored_sender_created_at $order, ignored_sender_match ASC",
|
|
];
|
|
if (!isset($sortable_columns[$sort])) {
|
|
$sort = 'ignored_sender_match';
|
|
}
|
|
|
|
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS email_ignored_senders.*, user_name FROM email_ignored_senders
|
|
LEFT JOIN users ON user_id = ignored_sender_created_by
|
|
WHERE (ignored_sender_match LIKE '%$q%' OR ignored_sender_note LIKE '%$q%')
|
|
ORDER BY {$sortable_columns[$sort]}
|
|
LIMIT $record_from, $record_to");
|
|
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|
|
|
?>
|
|
|
|
<div class="card" data-ignored-senders>
|
|
<div class="card-header bg-dark py-2">
|
|
<h3 class="card-title mt-2"><i class="fas fa-fw fa-eye-slash me-2"></i>Ignored Senders</h3>
|
|
<div class="card-tools">
|
|
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="modals/email_ignored_sender/email_ignored_sender.php">
|
|
<i class="fas fa-plus"></i><span class="d-none d-lg-inline ms-2">New Ignored Sender</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-header py-3">
|
|
<p class="small text-body-secondary mb-3">
|
|
Email from these addresses and domains is set aside by the ticket mailbox: no ticket, no reply on one, and no answer - it is moved to the mailbox's
|
|
ITFlow folder like the rest. A domain takes its subdomains too. A mail server's bounce is still read, and an email an agent makes a ticket from in
|
|
<a href="/agent/email_unprocessed.php">Unprocessed Email</a> goes where they say.
|
|
</p>
|
|
<form autocomplete="off">
|
|
<div class="row g-2 align-items-center">
|
|
<div class="col-lg-5 col-md-6">
|
|
<div class="input-group">
|
|
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search ignored senders..." title="An address, a domain, or why">
|
|
<button class="btn btn-dark" title="Search"><i class="fas fa-search"></i></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="table-responsive">
|
|
<table class="table table-hover align-middle mb-0">
|
|
<thead class="table-light text-nowrap <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
|
<tr>
|
|
<th class="ps-3"><?= sortLink('ignored_sender_match', 'Sender') ?></th>
|
|
<th class="d-none d-md-table-cell">Why</th>
|
|
<th><?= sortLink('ignored_sender_matches', 'Set aside') ?></th>
|
|
<th class="d-none d-lg-table-cell"><?= sortLink('ignored_sender_matched_at', 'Last') ?></th>
|
|
<th class="d-none d-lg-table-cell"><?= sortLink('ignored_sender_created_at', 'Added') ?></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php while ($row = mysqli_fetch_assoc($sql)) {
|
|
$id = intval($row['ignored_sender_id']);
|
|
$match = (string) $row['ignored_sender_match'];
|
|
$domain = strpos($match, '@') === false;
|
|
$edit = 'data-modal-url="modals/email_ignored_sender/email_ignored_sender.php?id=' . $id . '"';
|
|
?>
|
|
<tr data-ignored-sender="<?= escapeHtml($match) ?>">
|
|
<td class="ps-3 min-w-0">
|
|
<a class="ajax-modal fw-semibold text-body text-break" href="#" <?= $edit ?>><?= escapeHtml($domain ? "@$match" : $match) ?></a>
|
|
<div class="small text-body-secondary"><?= $domain ? 'Everyone at this domain, and its subdomains' : 'This address' ?></div>
|
|
<?php if (trim((string) $row['ignored_sender_note']) !== '') { ?>
|
|
<div class="small text-body-secondary d-md-none text-break"><?= escapeHtml($row['ignored_sender_note']) ?></div>
|
|
<?php } ?>
|
|
</td>
|
|
<td class="d-none d-md-table-cell small text-break"><?= trim((string) $row['ignored_sender_note']) !== '' ? escapeHtml($row['ignored_sender_note']) : '<span class="text-body-tertiary">-</span>' ?></td>
|
|
<td data-ignored-count><?= number_format(intval($row['ignored_sender_matches'])) ?> <span class="small text-body-secondary">email<?= intval($row['ignored_sender_matches']) === 1 ? '' : 's' ?></span></td>
|
|
<td class="d-none d-lg-table-cell small text-nowrap text-body-secondary"><?= $row['ignored_sender_matched_at'] ? escapeHtml(timeAgo($row['ignored_sender_matched_at'])) : 'Never' ?></td>
|
|
<td class="d-none d-lg-table-cell small text-nowrap text-body-secondary">
|
|
<?= escapeHtml(date('M j, Y', strtotime((string) $row['ignored_sender_created_at']))) ?>
|
|
<?php if ($row['user_name'] !== null) { ?><div><?= escapeHtml($row['user_name']) ?></div><?php } ?>
|
|
</td>
|
|
<td class="text-end pe-3">
|
|
<div class="dropdown dropstart">
|
|
<button class="btn btn-sm btn-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
|
|
<div class="dropdown-menu">
|
|
<a class="dropdown-item ajax-modal" href="#" <?= $edit ?>><i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit</a>
|
|
<div class="dropdown-divider"></div>
|
|
<a class="dropdown-item text-danger confirm-link" href="post.php?delete_ignored_sender=<?= $id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" data-ignored-delete>
|
|
<i class="fas fa-fw fa-trash me-2"></i>Stop Ignoring
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$empty_state = [
|
|
'thing' => 'ignored senders',
|
|
'icon' => 'fa-eye-slash',
|
|
'text' => 'Add an address or a domain whose email should never become a ticket - newsletters, spam that gets through, a noisy system.',
|
|
'actions' => [['label' => 'New Ignored Sender', 'modal' => 'modals/email_ignored_sender/email_ignored_sender.php']],
|
|
];
|
|
require_once "../includes/filter_footer.php";
|
|
?>
|
|
</div>
|
|
|
|
<?php
|
|
require_once "../includes/footer.php";
|