From 17d1c279abfcb64b1fda7b88615d6c27f359a2c1 Mon Sep 17 00:00:00 2001 From: tnegre Date: Tue, 28 Jan 2025 14:44:10 +0100 Subject: [PATCH] action/list.php : replace comma-joins by INNER JOIN --- htdocs/comm/action/list.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index d3d1ecfb833..cbe3f8b94ee 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -442,20 +442,19 @@ if (empty($user->rights->societe->client->voir) && !$socid) { } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; -$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON c.id = a.fk_action"; // We must filter on resource table if ($resourceid > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as r ON r.element_type = 'action' AND r.element_id = a.id"; } // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type='user'"; } if ($usergroup > 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; } -$sql .= " WHERE c.id = a.fk_action"; -$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; +$sql .= " WHERE a.entity IN (".getEntity('agenda').")"; // Condition on actioncode if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { @@ -486,7 +485,7 @@ if (!empty($actioncode)) { } } if ($resourceid > 0) { - $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".((int) $resourceid); + $sql .= " AND r.resource_id = ".((int) $resourceid); } if ($pid) { $sql .= " AND a.fk_project=".((int) $pid); @@ -497,10 +496,6 @@ if (empty($user->rights->societe->client->voir) && !$socid) { if ($socid > 0) { $sql .= " AND s.rowid = ".((int) $socid); } -// We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) { - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -} if ($type) { $sql .= " AND c.id = ".((int) $type); }