Fix external user 'Access Forbidden' on agenda event card (#37362)

External users (fk_soc set) were blocked from opening agenda events
because GETPOSTINT('socid') returns 0 when no socid param is in the URL
(ActionComm::getNomUrl() only generates ?id=XXXXX).

The condition 0 != $user->socid then triggers accessforbidden() for
every external user.

Fix: fall back to $user->socid when socid is not in the URL, consistent
with the pattern used in all other card pages (contracts, invoices,
orders, etc.).

The existing restrictedArea() check still validates that the event's
fk_soc matches the user's company, so security is preserved.

Fixes #37361

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
minimexat 2026-02-27 16:37:29 +01:00 committed by GitHub
parent 23f9aeded0
commit 2e02df9002
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,6 +116,9 @@ if (GETPOSTISSET("limityear") && GETPOSTINT("limityear") < 2100) {
// Security check
$socid = GETPOSTINT('socid');
if (empty($socid)) {
$socid = $user->socid; // External users: fall back to their own company (consistent with other card pages)
}
$id = GETPOSTINT('id');
if ($user->socid && ($socid != $user->socid)) {
accessforbidden();