mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +00:00
104 lines
5.5 KiB
PHP
104 lines
5.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Tickets > Unprocessed Email > Ignore Sender - its sender's address, or everyone at their domain, added to the ignored
|
|
* senders (functions/mail_ignore.php), so their email is set aside from now on; this email is dismissed, and the others
|
|
* waiting from them if asked. Not a domain anyone can have an address at (gmail.com), nor a client's - those are an
|
|
* admin's, in Admin > Ignored Senders. Saved by ignore_unprocessed_sender (agent/post/email_unprocessed.php).
|
|
*/
|
|
|
|
require_once '../../../includes/modal_header.php';
|
|
|
|
enforceUserPermission('module_support', 2);
|
|
|
|
$row = mailUnprocessedReady() && mailIgnoreReady() ? mailUnprocessedRow($_GET['id'] ?? 0) : null;
|
|
$from = strtolower(trim((string) ($row['email_unprocessed_from_email'] ?? '')));
|
|
if (!$row || !filter_var($from, FILTER_VALIDATE_EMAIL)) {
|
|
echo json_encode(['error' => !$row ? "That email isn't there any more." : 'It has no sender address to ignore.']);
|
|
exit;
|
|
}
|
|
|
|
if (mailIgnoreReach($from)['contacts']) {
|
|
echo json_encode(['error' => "$from is a contact's address - an admin can ignore it, in Admin > Ignored Senders."]);
|
|
exit;
|
|
}
|
|
|
|
$id = intval($row['email_unprocessed_id']);
|
|
$domain = substr($from, strrpos($from, '@') + 1);
|
|
$domain_reach = mailIgnoreReach($domain);
|
|
// Why the domain can't be ignored from here, or ''
|
|
$domain_no = in_array($domain, EMAIL_PUBLIC_DOMAINS, true) ? "Anyone can have an address at $domain"
|
|
: ($domain_reach['clients'] ? 'It is the domain of ' . implode(', ', $domain_reach['clients']) . ' - an admin can, in Admin > Ignored Senders'
|
|
: ($domain_reach['contacts'] ? $domain_reach['contacts'] . ' contact' . ($domain_reach['contacts'] === 1 ? ' has an address' : 's have addresses') . ' there - an admin can, in Admin > Ignored Senders' : ''));
|
|
$waiting = function ($match) use ($mysqli) {
|
|
$count = 0;
|
|
$sql = mysqli_query($mysqli, "SELECT email_unprocessed_from_email FROM email_unprocessed WHERE email_unprocessed_done_at IS NULL AND email_unprocessed_action = ''");
|
|
while ($sql && ($other = mysqli_fetch_row($sql))) {
|
|
$count += mailIgnoreMatches($match, $other[0]) ? 1 : 0;
|
|
}
|
|
return $count;
|
|
};
|
|
$address_others = max(0, $waiting($from) - 1);
|
|
$domain_others = max(0, $waiting($domain) - 1);
|
|
$already = mailIgnoreFind($from);
|
|
|
|
ob_start();
|
|
|
|
?>
|
|
<div class="modal-header bg-dark">
|
|
<h5 class="modal-title"><i class="fas fa-fw fa-eye-slash me-2"></i>Ignore Sender</h5>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<form action="post.php" method="post" autocomplete="off">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<input type="hidden" name="email_unprocessed_id" value="<?= $id ?>">
|
|
<div class="modal-body">
|
|
|
|
<p class="small text-body-secondary">From now on their email is set aside - no ticket, no answer, and nothing here to sort. Admin > Ignored Senders lists who is ignored.</p>
|
|
|
|
<?php if ($already) { ?>
|
|
<div class="alert alert-info small py-2"><i class="fas fa-fw fa-info-circle me-1"></i><?= escapeHtml($already['ignored_sender_match']) ?> is ignored already - this email came before.</div>
|
|
<?php } ?>
|
|
|
|
<div class="mb-3" data-ignore-what>
|
|
<div class="form-check mb-2">
|
|
<input class="form-check-input" type="radio" name="ignore" value="address" id="ignoreAddress" checked>
|
|
<label class="form-check-label" for="ignoreAddress">
|
|
This address - <strong><?= escapeHtml($from) ?></strong>
|
|
<?php if ($address_others) { ?><span class="text-body-secondary small">(<?= $address_others ?> more waiting from it)</span><?php } ?>
|
|
</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="ignore" value="domain" id="ignoreDomain" <?= $domain_no !== '' ? 'disabled' : '' ?>>
|
|
<label class="form-check-label" for="ignoreDomain">
|
|
Everyone at <strong><?= escapeHtml($domain) ?></strong>
|
|
<?php if ($domain_no === '' && $domain_others) { ?><span class="text-body-secondary small">(<?= $domain_others ?> more waiting from there)</span><?php } ?>
|
|
</label>
|
|
<?php if ($domain_no !== '') { ?><div class="form-text" data-ignore-domain-no><?= escapeHtml($domain_no) ?></div><?php } ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label" for="ignoreNote">Why</label>
|
|
<div class="input-group">
|
|
<span class="input-group-text"><i class="fas fa-fw fa-sticky-note"></i></span>
|
|
<input type="text" class="form-control" id="ignoreNote" name="ignored_sender_note" maxlength="255" placeholder="Newsletter, spam, a noisy system">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="dismiss_others" value="1" id="ignoreDismissOthers" checked>
|
|
<label class="form-check-label" for="ignoreDismissOthers">Dismiss the others waiting from them too</label>
|
|
<div class="form-text">This one is dismissed either way.</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="submit" name="ignore_unprocessed_sender" class="btn btn-danger fw-bold"><i class="fas fa-eye-slash me-2"></i>Ignore</button>
|
|
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
|
|
</div>
|
|
</form>
|
|
|
|
<?php
|
|
require_once '../../../includes/modal_footer.php';
|