Texting isn't set up - an admin sets it up in Admin > Integrations > Text Messaging.
= 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 = [
'sms_message_created_at' => "sms_message_created_at $order",
'sms_message_number' => "sms_message_number $order, sms_message_created_at DESC",
];
if (!isset($sortable_columns[$sort])) {
$sort = 'sms_message_created_at';
}
// A code's words aren't searched - a search that narrows to it would tell what it is
$search = "(sms_message_number LIKE '%$phone_query%' OR sms_number_label LIKE '%$q%' OR contact_name LIKE '%$q%' OR client_name LIKE '%$q%'"
. ($codes ? '' : " OR sms_message_body LIKE '%$q%'") . ")";
$joins = "LEFT JOIN sms_numbers ON sms_number_phone = sms_message_number
LEFT JOIN contacts ON contact_id = sms_message_contact_id AND sms_message_contact_id > 0
LEFT JOIN clients ON client_id = sms_message_client_id AND sms_message_client_id > 0";
$scope = "sms_message_direction = 'in' " . clientScopeSql('sms_message_client_id');
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS sms_message_id, sms_message_number, sms_message_body, sms_message_media, sms_message_code, sms_message_status,
sms_message_created_at, sms_message_error, sms_number_label, contact_name, client_name
FROM sms_messages $joins
WHERE $scope AND $search AND {$tabs[$show][2]}
ORDER BY {$sortable_columns[$sort]}, sms_message_id DESC
LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
// How many in each tab
$count_sql = [];
foreach ($tabs as $key => $tab) {
$count_sql[] = "COALESCE(SUM({$tab[2]}), 0)";
}
$counts = array_combine(array_keys($tabs), array_map('intval', mysqli_fetch_row(mysqli_query($mysqli, "SELECT " . implode(', ', $count_sql) . " FROM sms_messages $joins WHERE $scope"))));
$latest_code = $can_codes ? intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COALESCE(MAX(sms_message_id), 0) FROM sms_messages WHERE sms_message_direction = 'in' AND sms_message_status = 'code'"))[0]) : 0;
$csrf = $_SESSION['csrf_token'];
$provider = smsProvider();
?>
Texts to = escapeHtml(smsNumberText($provider['sms_provider_number'])) ?>
A code can be revealed for = SMS_CODE_MASK_MINUTES ?> minutes after it came - each reveal is in the audit log - and its words are wiped after a day.Texts from numbers that aren't a contact's. Texts from your contacts go on their tickets.From blocked numbers, or what looks like bait. Deleted after = SMS_SPAM_KEEP_DAYS ?> days.
'texts',
'icon' => $tabs[$show][1],
'title' => ['unmatched' => 'Nothing unmatched', 'codes' => 'No codes', 'spam' => 'No spam'][$show] ?? 'No texts',
'text' => ['unmatched' => 'Texts from numbers that aren\'t a contact\'s wait here - texts from your contacts go on their tickets.',
'codes' => 'Verification codes texted to ' . smsNumberText($provider['sms_provider_number']) . ' show here as they come.',
'spam' => 'Texts from blocked numbers, and ones that look like bait, wait here for ' . SMS_SPAM_KEEP_DAYS . ' days.'][$show] ?? '',
];
?>