Security sweep 2: API archive, unarchive, resolve and close now check the client named in the call the same as create, update and delete do (every call except read.php and time.php counts as a write); API asset, contact, network and document create/update keep linked contacts, locations, vendors, networks and folders within the record's own client; linking a contact to an asset refuses another client's contact, and unlinking only clears the contact it was linked to; agents limited to certain clients no longer see other clients' names in the asset import template file name, export filter summaries, or the messages from file moves, unlinks, ticket asset removal, bulk project add and bulk interface network; guest quote Accept and Decline post instead of being plain links and check the key with hash_equals; exports that match nothing say so instead of showing a blank page; about 30 handlers now stop with 'no longer exists' when their record was just deleted, instead of showing warnings or an error page and writing history for a record that is gone; restore_contact_note reads its own id parameter; ticket prefix pattern escaped for the v flag; missing user agent and array key parameters handled; CHANGELOG updated

This commit is contained in:
johnnyq
2026-10-26 19:54:36 -04:00
parent 5dbd497c31
commit 01fbcda75d
45 changed files with 373 additions and 67 deletions

View File

@@ -564,6 +564,18 @@ function isExportRequest($trigger) {
return isset($_POST[$trigger]) && in_array($_POST[$trigger], ['csv', 'pdf'], true);
}
/*
* Filters that match nothing say so and go back to the list - the export form
* posts straight to post.php, so returning nothing left a blank page there.
* Call it once the row count is known, before beginExport().
*/
function guardExportHasRows($num_rows, $what) {
if ($num_rows < 1) {
flashAlert("No $what match - nothing to export.", 'error');
redirect();
}
}
/*
* PDF is capped - see EXPORT_PDF_MAX_ROWS. Call this after the row count is known
* and before beginExport(); it redirects rather than returning on refusal.
@@ -751,6 +763,32 @@ function formatExportDateRange($date_from, $date_to) {
return $date_from . ' to ' . $date_to;
}
/*
* The name of a client an export is filtered to, for its summary - only a
* client this agent can reach; '' otherwise, so a made-up filter can't be
* used to read another client's name (the rows are scoped all the same).
*/
function exportClientName($client_id) {
$client_id = intval($client_id);
return $client_id && hasClientAccess($client_id) ? (string) getFieldById('clients', $client_id, 'client_name') : '';
}
/**
* The same for a record an export is filtered to (a site, a project, a vendor) - its $name_column
* when it belongs to no client (the company's own, which every agent sees) or to one this agent can reach.
*/
function exportRecordName($table, $id, $name_column, $client_column) {
$id = intval($id);
if (!$id) {
return '';
}
$client_id = getFieldById($table, $id, $client_column);
if ($client_id === null || $client_id === false || $client_id === '' || (intval($client_id) && !hasClientAccess($client_id))) {
return '';
}
return (string) getFieldById($table, $id, $name_column);
}
/*
* Human-readable one-liner of the same thing, for the PDF subtitle.
*/