Fix: possibility to use an alternative path

This commit is contained in:
Regis Houssin 2011-04-17 07:15:17 +00:00
parent 7919c35891
commit c50a14c5f7
5 changed files with 327 additions and 307 deletions

View File

@ -1,10 +1,10 @@
<?php <?php
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2008 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 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -245,7 +245,6 @@ if ($_GET["action"] == 'setmodel')
* View * View
*/ */
$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/";
$html=new Form($db); $html=new Form($db);
@ -297,10 +296,15 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
//$dir = "../includes/modules/expedition/"; foreach ($conf->file->dol_document_root as $dirroot)
$handle = opendir($dir);
if (is_resource($handle))
{ {
$dir = $dirroot . "/includes/modules/expedition/";
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
$var=true; $var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
@ -371,6 +375,8 @@ if (is_resource($handle))
} }
} }
closedir($handle); closedir($handle);
}
}
} }
print '</table><br>'; print '</table><br>';
@ -418,10 +424,12 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/"; foreach ($conf->file->dol_document_root as $dirroot)
if(is_dir($dir))
{ {
$dir = $dirroot . "/includes/modules/expedition/pdf/";
if (is_dir($dir))
{
$handle=opendir($dir); $handle=opendir($dir);
$var=true; $var=true;
@ -497,11 +505,9 @@ if(is_dir($dir))
} }
closedir($handle); closedir($handle);
} }
}
} }
else
{
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
}
print '</table>'; print '</table>';

View File

@ -1,10 +1,10 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 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 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -166,7 +166,6 @@ if ($_GET["action"] == 'setmod')
* View * View
*/ */
$dir = DOL_DOCUMENT_ROOT."/includes/modules/livraison/";
$html=new Form($db); $html=new Form($db);
llxHeader("",""); llxHeader("","");
@ -213,11 +212,15 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
$handle = opendir($dir); foreach ($conf->file->dol_document_root as $dirroot)
$var=true;
if (is_resource($handle))
{ {
$dir = $dirroot . "/includes/modules/livraison/";
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
$var=true; $var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -284,7 +287,10 @@ if (is_resource($handle))
} }
} }
closedir($handle); closedir($handle);
}
}
} }
print '</table>'; print '</table>';
@ -331,13 +337,13 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$dir = DOL_DOCUMENT_ROOT."/includes/modules/livraison/pdf/"; foreach ($conf->file->dol_document_root as $dirroot)
if(is_dir($dir))
{ {
$handle=opendir($dir); $dir = $dirroot . "/includes/modules/livraison/pdf/";
$var=true;
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
@ -409,11 +415,9 @@ if(is_dir($dir))
} }
closedir($handle); closedir($handle);
} }
}
} }
else
{
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
}
print '</table>'; print '</table>';
/* /*

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 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) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -71,19 +71,25 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
global $conf,$langs; global $conf,$langs;
$langs->load("sendings"); $langs->load("sendings");
$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/"; $dir = "/includes/modules/expedition/pdf/";
$modelisok=0; $modelisok=0;
// Positionne modele sur le nom du modele de commande a utiliser // Positionne modele sur le nom du modele de commande a utiliser
$file = "pdf_expedition_".$modele.".modules.php"; $file = "pdf_expedition_".$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 // Si model pas encore bon
if (! $modelisok) if (! $modelisok)
{ {
if ($conf->global->EXPEDITION_ADDON_PDF) $modele = $conf->global->EXPEDITION_ADDON_PDF; if ($conf->global->EXPEDITION_ADDON_PDF) $modele = $conf->global->EXPEDITION_ADDON_PDF;
$file = "pdf_expedition_".$modele.".modules.php"; $file = "pdf_expedition_".$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 // Si model pas encore bon
@ -94,7 +100,9 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
$liste=$model->liste_modeles($db); $liste=$model->liste_modeles($db);
$modele=key($liste); // Renvoie premiere valeur de cle trouve dans le tableau $modele=key($liste); // Renvoie premiere valeur de cle trouve dans le tableau
$file = "pdf_expedition_".$modele.".modules.php"; $file = "pdf_expedition_".$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;
} }
// Charge le modele // Charge le modele
@ -102,7 +110,7 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
{ {
dol_syslog("expedition_pdf_create ".$modele); dol_syslog("expedition_pdf_create ".$modele);
$classname = "pdf_expedition_".$modele; $classname = "pdf_expedition_".$modele;
require_once($dir.$file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 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) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2006-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2006-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -144,7 +144,7 @@ function delivery_order_pdf_create($db, $object, $model='', $outputlangs='')
global $conf,$langs; global $conf,$langs;
$langs->load("deliveries"); $langs->load("deliveries");
$dir = DOL_DOCUMENT_ROOT."/includes/modules/livraison/pdf/"; $dir = "/includes/modules/livraison/pdf/";
// Positionne modele sur le nom du modele de bon de livraison a utiliser // Positionne modele sur le nom du modele de bon de livraison a utiliser
if (! dol_strlen($model)) if (! dol_strlen($model))
@ -161,10 +161,12 @@ function delivery_order_pdf_create($db, $object, $model='', $outputlangs='')
} }
// Charge le modele // Charge le modele
$file = "pdf_".$model.".modules.php"; $file = "pdf_".$model.".modules.php";
if (file_exists($dir.$file)) // On verifie l'emplacement du modele
$file = dol_buildpath($dir.$file);
if (file_exists($file))
{ {
$classname = "pdf_".$model; $classname = "pdf_".$model;
require_once($dir.$file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db);