FIX filter on entity must be done as soon as we don't search on rowid.
This commit is contained in:
parent
84983140b6
commit
5a7cb95b72
@ -685,9 +685,10 @@ class Contact extends CommonObject
|
|||||||
* @param int $id id du contact
|
* @param int $id id du contact
|
||||||
* @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
|
* @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
|
||||||
* @param string $ref_ext External reference, not given by Dolibarr
|
* @param string $ref_ext External reference, not given by Dolibarr
|
||||||
|
* @param string $email Email
|
||||||
* @return int -1 if KO, 0 if OK but not found, 1 if OK
|
* @return int -1 if KO, 0 if OK but not found, 1 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($id, $user=0, $ref_ext='')
|
function fetch($id, $user=0, $ref_ext='', $email='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
@ -721,10 +722,16 @@ class Contact extends CommonObject
|
|||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
|
||||||
if ($id) $sql.= " WHERE c.rowid = ". $id;
|
if ($id) $sql.= " WHERE c.rowid = ". $id;
|
||||||
elseif ($ref_ext) {
|
else
|
||||||
|
{
|
||||||
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
|
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
|
||||||
|
if ($ref_ext) {
|
||||||
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
|
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
|
||||||
}
|
}
|
||||||
|
if ($email) {
|
||||||
|
$sql .= " AND c.email = '".$this->db->escape($email)."'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user