Fix: can use alternative path for pdf models

This commit is contained in:
Regis Houssin 2011-01-14 19:28:55 +00:00
parent eb01c964d9
commit bd1f03decc
3 changed files with 20 additions and 11 deletions

View File

@ -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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*

View File

@ -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;
}