X-Git-Url: http://git.datanom.net/qtadmin.git/blobdiff_plain/2b099ad2fc3663697e45dd16f4b82341e0267c86..f1c0988bd7f213a40ce3cfcf6d7522bd2fd12afa:/quarantine.php?ds=sidebyside diff --git a/quarantine.php b/quarantine.php index 788f78a..28bd2bd 100644 --- a/quarantine.php +++ b/quarantine.php @@ -14,7 +14,7 @@ echo $util->getFooter(); } - function handleRequest($request, $ids) { + function handleRequest($util, $request, $ids) { global $CFG; $query = array(); @@ -55,6 +55,8 @@ $query[] = "UPDATE msgrcpt SET rs = 'R' WHERE mail_id = '$mail_id'"; } else if ($request == 'delete') { $query[] = "UPDATE msgrcpt SET rs = 'D' WHERE mail_id = '$mail_id'"; + } else if ($request == 'block') { + $query[] = $recipient; } else { error("Unknown operation [$request]"); exit; @@ -70,10 +72,26 @@ $request = isset($_GET['op']) ? $_GET['op'] : ''; if ($loggedIn && isset($_GET['id'])) { $ids = explode(',', $_GET['id']); - $query = handleRequest($request, $ids); - $success = $DB->update($query); + if ($request == 'block') { + // /add/(whitelist|blacklist)/(.+) + $query = handleRequest($util, $request, $ids); + $data = json_encode($query); + if ($util->isAdmin()) { + $method = '/add/blacklist'; + } else { + $method = '/add/blacklist/' . $util->getUser(); + } + $success = $util->makeRestCall($method, $data); + } else { + $query = handleRequest($util, $request, $ids); + $success = $DB->update($query); + } if (! $success) { - error("Message not released, contact administrator [$query]"); + if ($request == 'block') { + error("Could not blacklist sender"); + } else { + error("Message not released, contact administrator [$query]"); + } exit; } header('Location: index.php'); @@ -83,8 +101,8 @@ $query = array(); $error = array(); foreach ($marked as $mail_id) { - $mail = $DB->getMail($mail_id); - if (is_object($mail) && true == $util->authorized($mail->recipient)) { + $recipient = $DB->getRecipient($mail_id); + if ($recipient && true == $util->authorized($recipient)) { $query[] = "delete from msgs where mail_id = '$mail_id'"; $query[] = "delete from msgrcpt where mail_id = '$mail_id'"; $query[] = "delete from quarantine where mail_id = '$mail_id'";