From 424eabd13caa01946273d8630220021704d00948 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Feb 2011 16:01:17 +0000 Subject: [PATCH] Fix: compatibility with element and subelement --- htdocs/comm/propal.php | 29 +++++++++++--------- htdocs/commande/fiche.php | 8 +++++- htdocs/compta/facture.php | 16 +++++++---- htdocs/core/class/commonobject.class.php | 34 ++++++++++++++---------- 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 939ffa451dd..8424251b067 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -45,12 +45,11 @@ $langs->load('bills'); $langs->load('orders'); $langs->load('products'); -$sall=isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]; -if (isset($_GET["msg"])) { $mesg=$_GET["mesg"]; } -$year=isset($_GET["year"])?$_GET["year"]:""; -$month=isset($_GET["month"])?$_GET["month"]:""; -$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; -$mesg=isset($_GET['mesg'])?$_GET['mesg']:''; +$sall=GETPOST("sall"); +$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); +$year=GETPOST("year"); +$month=GETPOST("month"); +$socid=GETPOST('socid'); // Security check $module='propale'; @@ -370,11 +369,11 @@ if ($_GET["action"] == 'classifybilled') /* * Cloture de la propale */ -if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer) +if (GETPOST('action') == 'setstatut' && $user->rights->propale->cloturer) { if (! $_POST['cancel']) { - if (empty($_REQUEST['statut'])) + if (! GETPOST('statut')) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'
'; $_REQUEST['action']='statut'; @@ -964,8 +963,8 @@ $companystatic=new Societe($db); $now=dol_now(); -$id = $_REQUEST['id']?$_REQUEST['id']:$_REQUEST['id']; -$ref= $_REQUEST['ref']; +$id = GETPOST('id'); +$ref= GETPOST('ref'); if ($id > 0 || ! empty($ref)) { @@ -973,7 +972,7 @@ if ($id > 0 || ! empty($ref)) * Show object in view mode */ - if ($mesg) + if ($mesg) { if (! preg_match('/div class=/',$mesg)) print '
'.$mesg.'

'; else print $mesg."
"; @@ -1559,7 +1558,13 @@ if ($id > 0 || ! empty($ref)) foreach($object->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + $element = $subelement = $linked_object; + if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if($conf->$element->enabled && $element != $object->element) { $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index ecb1add0890..5fd122a8513 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1860,7 +1860,13 @@ else foreach($object->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + $element = $subelement = $linked_object; + if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if($conf->$element->enabled && $element != $object->element) { $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 44d864743cc..2b9801ff4c6 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1314,20 +1314,20 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a /* * Generate document */ -if ($_REQUEST['action'] == 'builddoc') // En get ou en post +if (GETPOST('action') == 'builddoc') // En get ou en post { $object->fetch($facid); $object->fetch_thirdparty(); - if ($_REQUEST['model']) + if (GETPOST('model')) { - $object->setDocModel($user, $_REQUEST['model']); + $object->setDocModel($user, GETPOST('model')); } // Define output language $outputlangs = $langs; $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; if (! empty($newlang)) { @@ -2780,7 +2780,13 @@ else foreach($object->linked_object as $linked_object => $linked_objectid) { - if($conf->$linked_object->enabled && $linked_object != $object->element) + $element = $subelement = $linked_object; + if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if($conf->$element->enabled && $element != $object->element) { $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c92f96255a5..790e771d18b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1358,22 +1358,28 @@ class CommonObject global $langs,$bc; //print 'objecttype='.$objecttype.'
'; - + $this->objectid = $objectid; $num = sizeof($this->objectid); if ($num) { - $classpath = $objecttype.'/class'; - $tplpath = $objecttype; - if ($objecttype == 'facture') { $tplpath = 'compta/'.$objecttype; $classpath = $tplpath.'/class'; } // To work with non standard path - if ($objecttype == 'propal') { $tplpath = 'comm/'.$objecttype; $classpath = $tplpath.'/class'; } // To work with non standard path - if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; } // To work with non standard path - if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path + $element = $subelement = $objecttype; + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + $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 + if ($element == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; } // To work with non standard path - $classfile = strtolower($objecttype); $classname = ucfirst($objecttype); - if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; } - if ($objecttype == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; } + $classfile = strtolower($subelement); $classname = ucfirst($subelement); + if ($subelement == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; } + if ($subelement == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; } //print $classfile." - ".$classpath." - ".$tplpath; if(!class_exists($classname)) { @@ -1381,7 +1387,7 @@ class CommonObject } $this->linkedObjectBlock = new $classname($this->db); dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php'); - + return $num; } } @@ -1525,7 +1531,7 @@ class CommonObject print ''.$langs->trans('Qty').''; print ''.$langs->trans('ReductionShort').''; } - + /** * Return HTML with list of origin lines */ @@ -1560,7 +1566,7 @@ class CommonObject function printOriginLine($line,$var) { global $langs,$bc; - + //var_dump($line); $date_start=$line->date_debut_prevue; @@ -1627,7 +1633,7 @@ class CommonObject $this->tpl['price'] = price($line->subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? $line->remise_percent.'%' : ' '; - + include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php'); } }