From 48bde14815314319549503d4a313f84eb3e6090b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 15 Nov 2010 21:29:26 +0000 Subject: [PATCH] Fix: add entity filter --- htdocs/core/class/commonobject.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 898a46b9b5e..a58bd636ff4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -397,13 +397,19 @@ class CommonObject */ function getIdContact($source,$code,$status=0) { + global $conf; + $result=array(); $i=0; $sql = "SELECT ec.fk_socpeople"; $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec,"; + if ($source == 'internal') $sql.= " ".MAIN_DB_PREFIX."user as c"; + if ($source == 'external') $sql.= " ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE ec.element_id = ".$this->id; + $sql.= " AND ec.fk_socpeople = c.rowid"; + $sql.= " AND c.entity = ".$conf->entity; $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$this->element."'"; $sql.= " AND tc.source = '".$source."'";