Fix: choice clause OR/AND

This commit is contained in:
Regis Houssin 2011-02-22 17:48:35 +00:00
parent c7cf701c68
commit c9c481e5f5

View File

@ -1120,7 +1120,7 @@ class CommonObject
/** /**
* Load array of objects linked to current object. Links are loaded into this->linked_object array. * Load array of objects linked to current object. Links are loaded into this->linked_object array.
*/ */
function load_object_linked($sourceid='',$sourcetype='',$targetid='',$targettype='') function load_object_linked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
{ {
$this->linked_object=array(); $this->linked_object=array();
@ -1132,8 +1132,8 @@ class CommonObject
// Links beetween objects are stored in this table // Links beetween objects are stored in this table
$sql = 'SELECT fk_source, sourcetype, fk_target, targettype'; $sql = 'SELECT fk_source, sourcetype, fk_target, targettype';
$sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element';
$sql.= " WHERE (fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; $sql.= " WHERE (fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')";
$sql.= " OR (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; $sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')";
dol_syslog("CommonObject::load_object_linked sql=".$sql); dol_syslog("CommonObject::load_object_linked sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1367,13 +1367,16 @@ class CommonObject
if ($num) if ($num)
{ {
$element = $subelement = $objecttype; $element = $subelement = $objecttype;
$tplpath = $element;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{ {
$element = $regs[1]; $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
} }
$classpath = $element.'/class'; $classpath = $element.'/class';
$tplpath = $element;
if ($element == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path if ($element == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path
if ($element == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path if ($element == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; } // To work with non standard path
if ($element == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path if ($element == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path