From bd1f03deccf189ce199194fdff98fcc58ed036f3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 14 Jan 2011 19:28:55 +0000 Subject: [PATCH] Fix: can use alternative path for pdf models --- htdocs/admin/propale.php | 8 +++++--- htdocs/comm/propal.php | 4 ++-- .../modules/propale/modules_propale.php | 19 +++++++++++++------ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 3c6ea7b6f6b..fd4d276c913 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -61,12 +61,13 @@ if ($_GET["action"] == 'specimen') $propal->initAsSpecimen(); // Charge le modele - $dir = DOL_DOCUMENT_ROOT . "/includes/modules/propale/"; + $dir = "/includes/modules/propale/"; $file = "pdf_propale_".$modele.".modules.php"; - if (file_exists($dir.$file)) + $file = dol_buildpath($dir.$file); + if (file_exists($file)) { $classname = "pdf_propale_".$modele; - require_once($dir.$file); + require_once($file); $module = new $classname($db); @@ -183,6 +184,7 @@ llxHeader('',$langs->trans("PropalSetup")); $html=new Form($db); +if ($mesg) print $mesg; $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup'); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 0e88897d8e4..27f6ccf3f4f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010 Juanjo Menent * diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 02ffaa19886..7d34a6a66c4 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -143,19 +143,25 @@ function propale_pdf_create($db, $object, $modele, $outputlangs) global $langs; $langs->load("propale"); - $dir = DOL_DOCUMENT_ROOT."/includes/modules/propale/"; + $dir = "/includes/modules/propale/"; $modelisok=0; // Positionne modele sur le nom du modele de propale a utiliser $file = "pdf_propale_".$modele.".modules.php"; - if ($modele && file_exists($dir.$file)) $modelisok=1; + + // On verifie l'emplacement du modele + $file = dol_buildpath($dir.$file); + + if ($modele && file_exists($file)) $modelisok=1; // Si model pas encore bon if (! $modelisok) { if ($conf->global->PROPALE_ADDON_PDF) $modele = $conf->global->PROPALE_ADDON_PDF; $file = "pdf_propale_".$modele.".modules.php"; - if (file_exists($dir.$file)) $modelisok=1; + // On verifie l'emplacement du modele + $file = dol_buildpath($dir.$file); + if (file_exists($file)) $modelisok=1; } // Si model pas encore bon @@ -166,7 +172,8 @@ function propale_pdf_create($db, $object, $modele, $outputlangs) $liste=$model->liste_modeles($db); $modele=key($liste); // Renvoie premiere valeur de cle trouve dans le tableau $file = "pdf_propale_".$modele.".modules.php"; - if (file_exists($dir.$file)) $modelisok=1; + $file = dol_buildpath($dir.$file); + if (file_exists($file)) $modelisok=1; } @@ -174,7 +181,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs) if ($modelisok) { $classname = "pdf_propale_".$modele; - require_once($dir.$file); + require_once($file); $obj = new $classname($db); @@ -204,7 +211,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs) } else { - print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file); + print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); } return 0; }