diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 99e94aec30623..d70703a50fc3d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1752,7 +1752,7 @@ public function select_thirdparty_list($selected = '', $htmlname = 'socid', $fil */ public function selectcontacts($socid, $selected = array(), $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $options_only = 0, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0, $filter = '') { - global $conf, $langs, $hookmanager, $action; + global $conf, $user, $langs, $hookmanager, $action; $langs->load('companies'); @@ -1812,6 +1812,7 @@ public function selectcontacts($socid, $selected = array(), $htmlname = 'contact $sql .= " LEFT OUTER JOIN " . $this->db->prefix() . "societe as s ON s.rowid=sp.fk_soc"; } $sql .= " WHERE sp.entity IN (" . getEntity('contact') . ")"; + $sql .= " AND ((sp.fk_user_creat = ".((int) $user->id)." AND sp.priv = 1) OR sp.priv = 0)"; // check if this is a private contact if ($socid > 0 || $socid == -1) { $sql .= " AND sp.fk_soc = " . ((int) $socid); }