From ef0b84a507bd696769d237471ea32b1a34f0f389 Mon Sep 17 00:00:00 2001 From: bahfir abbes Date: Sat, 12 Sep 2020 16:40:00 +0100 Subject: [PATCH 1/2] allow external users to see thirdparties with printFieldListWhere hook; --- htdocs/societe/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 923e930c796..8ee66b11657 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -433,7 +433,6 @@ if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciau elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -if ($socid) $sql .= " AND s.rowid = ".$socid; if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL"; @@ -488,6 +487,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook) && $socid) $sql .= " AND s.rowid = ".$socid; + $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); From 26b4fb3e68d5a8c683bcd3948556111a2cd7a8ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Sep 2020 00:22:58 +0200 Subject: [PATCH 2/2] Update list.php --- htdocs/societe/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 8ee66b11657..96b50a34bf8 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -483,12 +483,12 @@ if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_s if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - // Add where from hooks -$parameters = array(); +$parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook) && $socid) $sql .= " AND s.rowid = ".$socid; - +if (empty($reshook)) { + if ($socid) $sql .= " AND s.rowid = ".$socid; +} $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder);