diff --git a/CHANGELOG.md b/CHANGELOG.md index c2dae283f..31c949327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This file documents all notable changes made to ITFlow. Update from Maintenance > Update as usual. There are no database changes. +### New Features & Updates + +- Texts: tick texts and use Bulk Action - dismiss or mark as spam in Unmatched, clear in Codes, Not Spam or delete in Spam - or empty a tab with Dismiss All, Clear All or Delete All, which say how many first. A code can also be cleared on its own, which wipes it and its words straight away. While codes are ticked, the Codes list waits to refresh so they stay ticked. + ### Bug Fixes - Two-step sign-in no longer says "Your MFA session expired" right after the code is typed. The code boxes send the code on its sixth digit, so pressing Enter out of habit - or a password manager or phone keyboard sending it too, or a double click on Verify & Sign In - sent it a second time, and that second copy signed you out. Each form on the sign-in page now goes once, a second copy that still gets through takes you into ITFlow, and a wrong code sent twice says the code is wrong. @@ -19,6 +23,7 @@ Update from Maintenance > Update as usual. There are no database changes. - `signInNewSession()` in `functions/sign_in.php` replaces `session_regenerate_id(true)` at both sign-ins in `login.php`. After the role choice, the code or a passkey, the old session id is kept for `SIGN_IN_MOVED_SECONDS` (60) holding only the new id and a SHA-256 of that step's pending token; `signInMovedSession()` takes a request with the old id and the same token on to the signed-in session and sends its cookie, so a second copy of the form posted before the first answer came back isn't left with an empty session. An id planted before the sign-in has no token and gets nothing. A password-only or provider sign-in renews the id as before. - `login.php`: the role, code and passkey steps call `signInMovedOn()` when their pending sign-in is gone - into the app for a second copy or a browser already signed in, otherwise "expired" as before. The code step is recognized by `pending_mfa_token` as well as the `mfa_login` button, a retried code keeps its pending token, and `SIGN_IN_CODE_SECONDS` (300) is the code step's window. - `js/login_prevent_resubmit.js` lets each form on the sign-in page submit once (until the page comes back from history, or 10 seconds), and `js/otp_input.js` does the same for any form with a `data-otp-submit` code field - turning on MFA, the client portal's two-step setup and shared-link codes. +- Texts: `smsInboxBulk($action, $ids, $user_id)` in `functions/sms.php` runs an action from `SMS_INBOX_BULK` (dismiss, spam, clear, not_spam, delete => the status it takes texts from and the permission it needs) on the ticked inbound texts, or with `$ids` null on the whole tab, inside `clientScopeSql()`. Spam and not spam block or unblock the numbers and move every text from them, as the single actions do. Clearing a code sets it to dismissed with its body, code and media wiped, so the text log's search can't find its words. `agent/post/texts.php` takes `bulk_texts` (with `sms_message_ids[]`) and `bulk_texts_all`, plus `sms_clear_code` for one code. `agent/texts.php` uses the standard `js/bulk_actions.js` select-all and Bulk Action button. ## [26.12.3] diff --git a/agent/post/texts.php b/agent/post/texts.php index 41b490b77..c96e006a0 100644 --- a/agent/post/texts.php +++ b/agent/post/texts.php @@ -2,7 +2,8 @@ /* * Texts (agent/texts.php) - open a ticket from an unmatched text, dismiss one, mark one spam - * (which blocks its number) or not, say a code isn't one, name a number, and delete spam + * (which blocks its number) or not, say a code isn't one, name a number, and delete spam - + * and dismiss, mark spam, clear codes, say not spam or delete many at once, or a whole tab * (functions/sms.php). */ @@ -163,6 +164,69 @@ if (isset($_GET['sms_delete'])) { } +// Many texts at once - the ticked ones, or with bulk_texts_all every one in the tab (smsInboxBulk()) +if (isset($_POST['bulk_texts']) || isset($_POST['bulk_texts_all'])) { + + validateCSRFToken(); + + $all = isset($_POST['bulk_texts_all']); + $action = (string) ($all ? $_POST['bulk_texts_all'] : $_POST['bulk_texts']); + if (!isset(SMS_INBOX_BULK[$action])) { + flashAlert('That isn\'t something Texts can do.', 'error'); + redirect('texts.php'); + } + enforceUserPermission(SMS_INBOX_BULK[$action][1], 2); + + $ids = $all ? null : (array) ($_POST['sms_message_ids'] ?? []); + if (!$all && !$ids) { + flashAlert('Tick the texts first', 'error'); + redirect(); + } + + $done = smsInboxBulk($action, $ids, intval($session_user_id)); + $texts = $done['texts']; + $numbers = $done['numbers']; + if (!$texts) { + flashAlert('Nothing changed - those texts have moved on, someone may have dealt with them already.', 'error'); + redirect(); + } + $s = $texts === 1 ? '' : 's'; + $ns = $numbers === 1 ? '' : 's'; + + if ($action === 'dismiss') { + logAudit("Text Message", "Edit", "$session_name dismissed $texts text$s"); + flashAlert("$texts text$s dismissed - kept in the text log for " . SMS_SPAM_KEEP_DAYS . " days"); + } elseif ($action === 'clear') { + logAudit("Text Message", "Edit", "$session_name cleared $texts code$s from Texts, wiping them"); + flashAlert("$texts code$s cleared"); + } elseif ($action === 'delete') { + logAudit("Text Message", "Delete", "$session_name deleted $texts spam text$s"); + flashAlert("$texts spam text$s deleted", 'error'); + } elseif ($action === 'spam') { + logAudit("Text Message", "Edit", "$session_name marked texts from $numbers number$ns as spam and blocked them"); + flashAlert("$numbers number$ns blocked - $texts text$s moved to Spam, and what they send goes straight there"); + } else { + logAudit("Text Message", "Edit", "$session_name said texts from $numbers number$ns aren't spam and unblocked them"); + flashAlert("$numbers number$ns unblocked - $texts text$s moved to Unmatched"); + } + redirect(); + +} + +// One code cleared - its words and code wiped now, and out of Codes (smsInboxBulk()) +if (isset($_GET['sms_clear_code'])) { + + validateCSRFToken(); + enforceUserPermission('module_credential', 2); + + $row = textsForRequest($_GET['sms_clear_code'], ['code']); + smsInboxBulk('clear', [intval($row['sms_message_id'])], intval($session_user_id)); + logAudit("Text Message", "Edit", "$session_name cleared a code from " . escapeSql(smsNumberText($row['sms_message_number'])) . " from Texts, wiping it"); + flashAlert('Code cleared'); + redirect(); + +} + if (isset($_GET['sms_not_code'])) { validateCSRFToken(); diff --git a/agent/texts.php b/agent/texts.php index b8fc3d443..e6e30f311 100644 --- a/agent/texts.php +++ b/agent/texts.php @@ -8,7 +8,8 @@ * revealed one at a time (each reveal in the audit log) for SMS_CODE_MASK_MINUTES after * it came, and its words wiped after SMS_CODE_KEEP_HOURS * Spam - blocked numbers and what looks like bait, deleted after SMS_SPAM_KEEP_DAYS - * Texts from contacts, and on tickets, go on their tickets and never wait here. The actions + * Texts from contacts, and on tickets, go on their tickets and never wait here. Ticked texts, + * or a whole tab, can be dismissed, cleared or deleted at once (smsInboxBulk()). The actions * are agent/post/texts.php; revealing a code is ajax.php?sms_reveal_code. */ @@ -46,6 +47,15 @@ if (!isset($tabs[$show])) { $codes = $show === 'codes'; $can_work = lookupUserPermission('module_support') >= 2; $can_codes = lookupUserPermission('module_credential') >= 1; +$can_clear_codes = lookupUserPermission('module_credential') >= 2; +// Ticking texts, and the tab's All button: what it does, its label, icon and look, and what it asks first +$can_bulk = $codes ? $can_clear_codes : $can_work; +$searching = trim((string) ($_GET['q'] ?? '')) !== ''; +$all_action = [ + 'unmatched' => ['dismiss', 'Dismiss All', 'fa-check-double', 'btn-outline-secondary', 'Dismiss all %d unmatched texts?', 'They leave Texts and stay in the text log for ' . SMS_SPAM_KEEP_DAYS . ' days. No number is blocked.'], + 'codes' => ['clear', 'Clear All', 'fa-broom', 'btn-outline-secondary', 'Clear all %d codes?', 'Their words and codes are wiped now - ones that could still be revealed too.'], + 'spam' => ['delete', 'Delete All', 'fa-trash-alt', 'btn-outline-danger', 'Delete all %d spam texts?', 'They are gone for good. Their numbers stay blocked.'], +][$show]; // Only these sort - an unknown column would take the page down $sortable_columns = [ @@ -100,14 +110,52 @@ $provider = smsProvider(); -