From c9c481e5f5d32747f4f4cf243a2bf17bd8dd39f0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Feb 2011 17:48:35 +0000 Subject: [PATCH] Fix: choice clause OR/AND --- htdocs/core/class/commonobject.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0c18414f56e..6acbdbdd728 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1120,7 +1120,7 @@ class CommonObject /** * 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(); @@ -1132,8 +1132,8 @@ class CommonObject // Links beetween objects are stored in this table $sql = 'SELECT fk_source, sourcetype, fk_target, targettype'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; - $sql.= " WHERE (fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; - $sql.= " OR (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; + $sql.= " WHERE (fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; + $sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; dol_syslog("CommonObject::load_object_linked sql=".$sql); $resql = $this->db->query($sql); @@ -1367,13 +1367,16 @@ class CommonObject if ($num) { $element = $subelement = $objecttype; + $tplpath = $element; + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) { $element = $regs[1]; $subelement = $regs[2]; + $tplpath = $element.'/'.$subelement; } + $classpath = $element.'/class'; - $tplpath = $element; 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 == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path