From 2e02df90026a7d5732136bb142ad5c73e2b6124c Mon Sep 17 00:00:00 2001 From: minimexat Date: Fri, 27 Feb 2026 16:37:29 +0100 Subject: [PATCH] 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 --- htdocs/comm/action/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4ccaf4d2f33..95c3c23e52a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -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();