From c50a14c5f7147247ee503a90ab377eb64e03dade Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 17 Apr 2011 07:15:17 +0000 Subject: [PATCH] Fix: possibility to use an alternative path --- htdocs/admin/expedition.php | 298 +++++++++--------- htdocs/admin/livraison.php | 298 +++++++++--------- .../modules/expedition/modules_expedition.php | 4 +- .../pdf/ModelePdfExpedition.class.php | 22 +- .../modules/livraison/modules_livraison.php | 12 +- 5 files changed, 327 insertions(+), 307 deletions(-) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 43a138af214..2d6bf1c35f4 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -245,7 +245,6 @@ if ($_GET["action"] == 'setmodel') * View */ -$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/"; $html=new Form($db); @@ -297,80 +296,87 @@ print "\n"; clearstatcache(); -//$dir = "../includes/modules/expedition/"; -$handle = opendir($dir); -if (is_resource($handle)) +foreach ($conf->file->dol_document_root as $dirroot) { - $var=true; + $dir = $dirroot . "/includes/modules/expedition/"; - while (($file = readdir($handle))!==false) + if (is_dir($dir)) { - if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php') + $handle = opendir($dir); + if (is_resource($handle)) { - $file = substr($file, 0, dol_strlen($file)-4); - - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/expedition/".$file.".php"); - - $module = new $file; - - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - - if ($module->isEnabled()) + $var=true; + + while (($file = readdir($handle))!==false) { - $var=!$var; - print ''.$module->nom."\n"; - print ''; - print $module->info(); - print ''; - - // Examples - print ''.$module->getExample()."\n"; - - print ''; - if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") + if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php') { - print img_picto($langs->trans("Activated"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Disabled"),'off'); - print ''; - } - print ''; - - $expedition=new Expedition($db); - $expedition->initAsSpecimen(); - - // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $facture->type=0; - $nextval=$module->getNextValue($mysoc,$expedition); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) + $file = substr($file, 0, dol_strlen($file)-4); + + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/expedition/".$file.".php"); + + $module = new $file; + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; + $var=!$var; + print ''.$module->nom."\n"; + print ''; + print $module->info(); + print ''; + + // Examples + print ''.$module->getExample()."\n"; + + print ''; + if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") + { + print img_picto($langs->trans("Activated"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Disabled"),'off'); + print ''; + } + print ''; + + $expedition=new Expedition($db); + $expedition->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type=0; + $nextval=$module->getNextValue($mysoc,$expedition); + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + + print ''; } } - - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - - print ''; } + closedir($handle); } } - closedir($handle); } print '
'; @@ -418,90 +424,90 @@ print "\n"; clearstatcache(); -$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/"; - -if(is_dir($dir)) +foreach ($conf->file->dol_document_root as $dirroot) { - $handle=opendir($dir); - $var=true; + $dir = $dirroot . "/includes/modules/expedition/pdf/"; - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_') - { - $name = substr($file, 15, dol_strlen($file) - 27); - $classname = substr($file, 0, dol_strlen($file) - 12); - - $var=!$var; - print ""; - print $name; - print "\n"; - require_once($dir.$file); - $module = new $classname(); - - print $module->description; - print ''; - - // Active - if (in_array($name, $def)) - { - print "\n"; - if ($conf->global->EXPEDITION_ADDON_PDF != $name) - { - print ''; - print img_picto($langs->trans("Activated"),'on'); - print ''; - } - else - { - print img_picto($langs->trans("Activated"),'on'); - } - print ""; - } - else - { - print "\n"; - print ''.img_picto($langs->trans("Disabled"),'off').''; - print ""; - } - - // Default - print ""; - if ($conf->global->EXPEDITION_ADDON_PDF == $name) - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').''; - print ''; - - print ''; - } - } - closedir($handle); - } -} -else -{ - print "ERROR: $dir is not a directory !\n"; + if (is_dir($dir)) + { + $handle=opendir($dir); + $var=true; + + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_') + { + $name = substr($file, 15, dol_strlen($file) - 27); + $classname = substr($file, 0, dol_strlen($file) - 12); + + $var=!$var; + print ""; + print $name; + print "\n"; + require_once($dir.$file); + $module = new $classname(); + + print $module->description; + print ''; + + // Active + if (in_array($name, $def)) + { + print "\n"; + if ($conf->global->EXPEDITION_ADDON_PDF != $name) + { + print ''; + print img_picto($langs->trans("Activated"),'on'); + print ''; + } + else + { + print img_picto($langs->trans("Activated"),'on'); + } + print ""; + } + else + { + print "\n"; + print ''.img_picto($langs->trans("Disabled"),'off').''; + print ""; + } + + // Default + print ""; + if ($conf->global->EXPEDITION_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + print ''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').''; + print ''; + + print ''; + } + } + closedir($handle); + } + } } + print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 24b3a8e4231..df55fc7b788 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -1,10 +1,10 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -166,7 +166,6 @@ if ($_GET["action"] == 'setmod') * View */ -$dir = DOL_DOCUMENT_ROOT."/includes/modules/livraison/"; $html=new Form($db); llxHeader("",""); @@ -213,78 +212,85 @@ print ''."\n"; clearstatcache(); -$handle = opendir($dir); - -$var=true; -if (is_resource($handle)) +foreach ($conf->file->dol_document_root as $dirroot) { - $var=true; - while (($file = readdir($handle))!==false) - { - if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php') + $dir = $dirroot . "/includes/modules/livraison/"; + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) { - $file = substr($file, 0, dol_strlen($file)-4); - - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/livraison/".$file.".php"); - - $module = new $file; - - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - - if ($module->isEnabled()) + $var=true; + while (($file = readdir($handle))!==false) { - $var=!$var; - print ''.$module->nom."\n"; - print $module->info(); - print ''; - - // Affiche example - print ''.$module->getExample().''; - - print ''; - if ($conf->global->LIVRAISON_ADDON == "$file") + if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php') { - print img_picto($langs->trans("Activated"),'on'); + $file = substr($file, 0, dol_strlen($file)-4); + + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/livraison/".$file.".php"); + + $module = new $file; + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $var=!$var; + print ''.$module->nom."\n"; + print $module->info(); + print ''; + + // Affiche example + print ''.$module->getExample().''; + + print ''; + if ($conf->global->LIVRAISON_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'on'); + } + else + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + + $livraison=new Livraison($db); + $livraison->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type=0; + $nextval=$module->getNextValue($mysoc,$livraison); + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + + print ''; + } } - else - { - print ''.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - - $livraison=new Livraison($db); - $livraison->initAsSpecimen(); - - // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $facture->type=0; - $nextval=$module->getNextValue($mysoc,$livraison); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } - } - - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - - print ''; } + closedir($handle); } - } - closedir($handle); + } } + print ''; @@ -331,89 +337,87 @@ print "\n"; clearstatcache(); -$dir = DOL_DOCUMENT_ROOT."/includes/modules/livraison/pdf/"; - -if(is_dir($dir)) +foreach ($conf->file->dol_document_root as $dirroot) { - $handle=opendir($dir); - $var=true; + $dir = $dirroot . "/includes/modules/livraison/pdf/"; - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') - { - $name = substr($file, 4, dol_strlen($file) - 16); - $classname = substr($file, 0, dol_strlen($file) - 12); - - $var=!$var; - print ""; - print $name; - print "\n"; - require_once($dir.$file); - $module = new $classname($db); - - print $module->description; - print ''; - - // Activ - if (in_array($name, $def)) - { - print "\n"; - if ($conf->global->LIVRAISON_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'on'); - print ''; - } - else - { - print img_picto($langs->trans("Enabled"),'on'); - } - print ""; - } - else - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; - print ""; - } - - // Defaut - print ""; - if ($conf->global->LIVRAISON_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - print ''; - print $html->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''; - print ''.img_object($langs->trans("Preview"),'sending').''; - print ''; - - print ''; - } - } - closedir($handle); - } -} -else -{ - print "ERROR: $dir is not a directory !\n"; + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); + + $var=!$var; + print ""; + print $name; + print "\n"; + require_once($dir.$file); + $module = new $classname($db); + + print $module->description; + print ''; + + // Activ + if (in_array($name, $def)) + { + print "\n"; + if ($conf->global->LIVRAISON_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'on'); + print ''; + } + else + { + print img_picto($langs->trans("Enabled"),'on'); + } + print ""; + } + else + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; + print ""; + } + + // Defaut + print ""; + if ($conf->global->LIVRAISON_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + print ''; + print $html->textwithpicto('',$htmltooltip,1,0); + print ''; + print ''; + print ''.img_object($langs->trans("Preview"),'sending').''; + print ''; + + print ''; + } + } + closedir($handle); + } + } } + print ''; /* diff --git a/htdocs/includes/modules/expedition/modules_expedition.php b/htdocs/includes/modules/expedition/modules_expedition.php index ea0a4a87109..dfdf420e905 100755 --- a/htdocs/includes/modules/expedition/modules_expedition.php +++ b/htdocs/includes/modules/expedition/modules_expedition.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2011 Juanjo Menent * diff --git a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php index a10e15fdaea..9abbf28af0d 100644 --- a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php +++ b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2005-2010 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2011 Regis Houssin * * 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 @@ -71,19 +71,25 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs) global $conf,$langs; $langs->load("sendings"); - $dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/pdf/"; + $dir = "/includes/modules/expedition/pdf/"; $modelisok=0; // Positionne modele sur le nom du modele de commande a utiliser $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 if (! $modelisok) { if ($conf->global->EXPEDITION_ADDON_PDF) $modele = $conf->global->EXPEDITION_ADDON_PDF; $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 @@ -94,7 +100,9 @@ function expedition_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_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 @@ -102,7 +110,7 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs) { dol_syslog("expedition_pdf_create ".$modele); $classname = "pdf_expedition_".$modele; - require_once($dir.$file); + require_once($file); $obj = new $classname($db); diff --git a/htdocs/includes/modules/livraison/modules_livraison.php b/htdocs/includes/modules/livraison/modules_livraison.php index 9f6678423a2..e669e45e321 100644 --- a/htdocs/includes/modules/livraison/modules_livraison.php +++ b/htdocs/includes/modules/livraison/modules_livraison.php @@ -1,8 +1,8 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2006-2009 Regis Houssin + * Copyright (C) 2006-2011 Regis Houssin * * 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 @@ -144,7 +144,7 @@ function delivery_order_pdf_create($db, $object, $model='', $outputlangs='') global $conf,$langs; $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 if (! dol_strlen($model)) @@ -161,10 +161,12 @@ function delivery_order_pdf_create($db, $object, $model='', $outputlangs='') } // Charge le modele $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; - require_once($dir.$file); + require_once($file); $obj = new $classname($db);