diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 144b3d02ca4b76d993d188df114b4638270f3ff6..36efb483c94b8ba89396663af9f15b9007d10d34 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -334,11 +334,11 @@ print '</table><br>'; /* - * Modeles de documents + * Document templates generators */ print_titre($langs->trans("OrdersModelModule")); -// Defini tableau def de modele +// Load array def with activated templates $type='order'; $def = array(); $sql = "SELECT nom"; @@ -365,12 +365,11 @@ else print "<table class=\"noborder\" width=\"100%\">\n"; print "<tr class=\"liste_titre\">\n"; -print ' <td width="100">'.$langs->trans("Name")."</td>\n"; -print " <td>".$langs->trans("Description")."</td>\n"; -print '<td align="center" width="40">'.$langs->trans("Status")."</td>\n"; -print '<td align="center" width="40">'.$langs->trans("Default")."</td>\n"; -print '<td align="center" width="40">'.$langs->trans("Infos").'</td>'; -print '<td align="center" width="40">'.$langs->trans("Preview").'</td>'; +print '<td>'.$langs->trans("Name").'</td>'; +print '<td>'.$langs->trans("Description").'</td>'; +print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n"; +print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n"; +print '<td align="center" width="38" colspan="2">'.$langs->trans("Infos").'</td>'; print "</tr>\n"; clearstatcache(); @@ -387,11 +386,13 @@ foreach ($conf->file->dol_document_root as $dirroot) $handle=opendir($dir); if (is_resource($handle)) { + while (($file = readdir($handle))!==false) { $filelist[]=$file; } closedir($handle); + arsort($filelist); foreach($filelist as $file) { diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 40b7cef01c415dabc45dbd33d1b10c7511dacb18..bd145f32ae45dacf618248f76f1d503b4f2bb4ff 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -439,10 +439,11 @@ print '<br>'; print_titre($langs->trans("BillsPDFModules")); // Load array def with activated templates +$type='invoice'; $def = array(); $sql = "SELECT nom"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = 'invoice'"; +$sql.= " WHERE type = '".$type."'"; $sql.= " AND entity = ".$conf->entity; $resql=$db->query($sql); if ($resql) @@ -472,7 +473,6 @@ print "</tr>\n"; clearstatcache(); - $var=true; foreach ($conf->file->dol_document_root as $dirroot) { @@ -490,6 +490,7 @@ foreach ($conf->file->dol_document_root as $dirroot) $filelist[]=$file; } closedir($handle); + arsort($filelist); foreach($filelist as $file) { diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 57ee3b7e395d5c7aa00e096c2455962c9fc4d17f..cd56a0f032a2425144bdbc274b1093fb5a975715 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -472,7 +472,7 @@ dol_fiche_end(); print '<div class="tabsAction">'; print '</div>'; -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 7e57e60d2f6347327cb3e6c0712feb7f225d5bec..1689a406f881a0c4908a9245c070fd89c3aaa3bf 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -422,6 +422,7 @@ foreach ($conf->file->dol_document_root as $dirroot) $filelist[]=$file; } closedir($handle); + arsort($filelist); foreach($filelist as $file) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index b9cf7b682411dc7bff023e4c9021dc267539d968..0decdf402f751865de2154e1bd3b3e9da006e2c7 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -422,33 +422,48 @@ function dol_filemtime($pathoffile) } /** - * Copy a file to another file + * Copy a file to another file. * * @param string $srcfile Source file (can't be a directory) * @param string $destfile Destination file (can't be a directory) * @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK) * @param int $overwriteifexists Overwrite file if exists (1 by default) - * @return boolean True if OK, false if KO + * @return int <0 if error, 0 if nothing done (dest file already exists and overwriteifexists=0), >0 if OK */ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) { global $conf; - $result=false; dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists); - if ($overwriteifexists || ! dol_is_file($destfile)) - { - $newpathofsrcfile=dol_osencode($srcfile); - $newpathofdestfile=dol_osencode($destfile); + $destexists=dol_is_file($destfile); + if (! $overwriteifexists && $destexists) return 0; - $result=@copy($newpathofsrcfile, $newpathofdestfile); - //$result=copy($srcfile, $destfile); // To see errors, remove @ - if (! $result) dol_syslog("files.lib.php::dol_copy failed", LOG_WARNING); - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; - @chmod($newpathofdestfile, octdec($newmask)); + $newpathofsrcfile=dol_osencode($srcfile); + $newpathofdestfile=dol_osencode($destfile); + $newdirdestfile=dirname($newpathofdestfile); + + if ($destexists && ! is_writable($newpathofdestfile)) + { + dol_syslog("files.lib.php::dol_copy failed Permission denied to overwrite target file", LOG_WARNING); + return -1; + } + if (! is_writable($newdirdestfile)) + { + dol_syslog("files.lib.php::dol_copy failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING); + return -2; + } + // Copy with overwriting if exists + $result=@copy($newpathofsrcfile, $newpathofdestfile); + //$result=copy($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ + if (! $result) + { + dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING); + return -3; } + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + @chmod($newpathofdestfile, octdec($newmask)); - return $result; + return 1; } /** diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 216fd0aa43bafebe9fc3275257c9d50c0bbb3ebf..435d26ab08a66b5a70d2c3e1103e5e7081af6203 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -98,41 +98,38 @@ abstract class DolibarrModules // Create module's directories if (! $err) $err+=$this->create_dirs(); - // Execute les requetes sql complementaires - if (! $err) + // Execute addons requests + $num=count($array_sql); + for ($i = 0; $i < $num; $i++) { - $num=count($array_sql); - for ($i = 0; $i < $num; $i++) + if (! $err) { - if (! $err) + $val=$array_sql[$i]; + $sql=''; + $ignoreerror=0; + if (is_array($val)) + { + $sql=$val['sql']; + $ignoreerror=$val['ignoreerror']; + } + else + { + $sql=$val; + } + + dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror." sql=".$sql, LOG_DEBUG); + $result=$this->db->query($sql); + if (! $result) { - $val=$array_sql[$i]; - $sql=''; - $ignoreerror=0; - if (is_array($val)) + if (! $ignoreerror) { - $sql=$val['sql']; - $ignoreerror=$val['ignoreerror']; + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::_init Error ".$this->error, LOG_ERR); + $err++; } else { - $sql=$val; - } - - dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror." sql=".$sql, LOG_DEBUG); - $result=$this->db->query($sql); - if (! $result) - { - if (! $ignoreerror) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::_init Error ".$this->error, LOG_ERR); - $err++; - } - else - { - dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING); - } + dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING); } } } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 66824db400568c22e560c5f7552c90ed4c1a9388..190e603f74b5bc320891e70ae26b8648d10710fb 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -1,7 +1,7 @@ <?php -/* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> - * + * * 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 * the Free Software Foundation; either version 2 of the License, or @@ -39,13 +39,13 @@ class doc_generic_order_odt extends ModelePDFCommandes var $emetteur; // Objet societe qui emet var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'development'; + var $version = 'dolibarr'; /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function doc_generic_order_odt($db) { @@ -107,7 +107,7 @@ class doc_generic_order_odt extends ModelePDFCommandes 'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), 'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'), - 'object_payment_mode'=>$object->mode_reglement, + 'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_term'=>$object->cond_reglement, 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), @@ -144,7 +144,7 @@ class doc_generic_order_odt extends ModelePDFCommandes ); } - /** + /** * Return description of a module * @param langs Lang object to use for output * @return string Description diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index faea0a306c8d223b6f95872bbe82a3e683655a60..4435a867f1ce993bda3ce5edbcd5c3cc727d8fb1 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2010-2011 Laurent Destailleur <ely@users.sourceforge.net> +/* Copyright (C) 2010-2012 Laurent Destailleur <ely@users.sourceforge.net> * 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 @@ -45,7 +45,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function doc_generic_invoice_odt($db) { @@ -115,7 +115,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures 'object_date_creation'=>dol_print_date($object->date_creation,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), - 'object_payment_mode'=>$object->mode_reglement, + 'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_term'=>$object->cond_reglement, 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 9e4cea75084456aad58a1a6deadf76b3d100872a..4a3267f1976ef6fb0577c14f735b47d9d2c8edd7 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -90,7 +90,7 @@ class modCommande extends DolibarrModules $this->const[$r][2] = "mod_commande_marbre"; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes'; $this->const[$r][4] = 0; - + $r++; $this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; @@ -195,7 +195,7 @@ class modCommande extends DolibarrModules */ function init($options='') { - global $conf; + global $conf,$langs; // Permissions $this->remove(); @@ -204,11 +204,18 @@ class modCommande extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt',$dirodt.'/template_order.odt',0,0); - + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dest=$dirodt.'/template_order.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."'", - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES('".$this->const[0][2]."','order')" + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','order',".$conf->entity.")" ); return $this->_init($sql,$options); @@ -216,8 +223,12 @@ class modCommande extends DolibarrModules /** - * \brief Fonction appelee lors de la desactivation d'un module. - * Supprime de la base les constantes, boites et permissions du module. + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ function remove() { diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index e06da8453f93da75ee51202c8f3750affe55e82d..3c2c68b09cc7a93dbcd0fe6b74ee39d023f5c4f0 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -212,7 +212,7 @@ class modFacture extends DolibarrModules */ function init($options='') { - global $conf; + global $conf,$langs; // Remove permissions and default values $this->remove($options); @@ -220,11 +220,18 @@ class modFacture extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/invoices'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0); + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt'; $dest=$dirodt.'/template_invoice.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")", + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")" ); return $this->_init($sql,$options); diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 6a0eabe0c6f8417a419739ab7e8efab433e72a1c..d7770bb61fa3a475ccc459fbaeb3017c7fb11000 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -190,7 +190,7 @@ class modPropale extends DolibarrModules */ function init($options='') { - global $conf; + global $conf,$langs; // Remove permissions and default values $this->remove(); @@ -199,7 +199,14 @@ class modPropale extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/proposals'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt',$dirodt.'/template_proposal.odt',0,0); + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; $dest=$dirodt.'/template_proposal.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index ab20a588b157261c917d9d8c6091a56b74e05377..224e23d67f1ecc15478b7b92a2edcfab5a6ff269 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -316,7 +316,14 @@ class modSociete extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0); + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; $dest=$dirodt.'/template_thirdparty.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } $sql = array(); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 63a0cef81c528a8f0ca07f3f07090ce4a542ca07..92af7983233e80130414e78d373c9cfd67ac66fb 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -1,7 +1,7 @@ <?php -/* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> - * + * * 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 * the Free Software Foundation; either version 2 of the License, or @@ -39,13 +39,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales var $emetteur; // Objet societe qui emet var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'development'; + var $version = 'dolibarr'; /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function doc_generic_proposal_odt($db) { @@ -102,11 +102,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales 'object_ref_ext'=>$object->ref_ext, 'object_ref_customer'=>$object->ref_client, 'object_date'=>dol_print_date($object->date,'day'), - 'object_fin_validite'=>dol_print_date($object->fin_validite,'dayhour'), + 'object_date_end'=>dol_print_date($object->fin_validite,'day'), 'object_date_creation'=>dol_print_date($object->date_creation,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), - 'object_payment_mode'=>$object->mode_reglement, + 'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_term'=>$object->cond_reglement, 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), @@ -143,7 +143,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales ); } - /** + /** * Return description of a module * @param langs Lang object to use for output * @return string Description diff --git a/htdocs/install/doctemplates/proposals/template_proposal.odt b/htdocs/install/doctemplates/proposals/template_proposal.odt index d3779f546d41850a161e305eda2de068c9dd96f9..e163fef76650e978fce7bcc887354774bd9d01fb 100644 Binary files a/htdocs/install/doctemplates/proposals/template_proposal.odt and b/htdocs/install/doctemplates/proposals/template_proposal.odt differ diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index bdc9868e3ee8ebdaf8f54d7b2bf39432279f2bf7..80568b6ddf532c0352e1e9fe548bfdfa4284203d 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -392,7 +392,7 @@ if (! $error && $db->connected && $action == "set") { // We must ignore errors as an existing old file may already exists and not be replacable or // the installer (like for ubuntu) may not have permission to create another file than conf.php. - // Also no other process must be able to read file or we expose the new file so content with password. + // Also no other process must be able to read file or we expose the new file, so content with password. @dol_copy($conffile, $conffile.'.old', '0400'); } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0817785acceda26458230f8d7ec14c8ca3fdcf58..65a342bf83ab3c2b2c6dfa9d32f944617fc6a52a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -10,6 +10,7 @@ ErrorBadUrl=Url %s is wrong ErrorLoginAlreadyExists=Login %s already exists. ErrorGroupAlreadyExists=Group %s already exists. ErrorRecordNotFound=Record not found. +ErrorFailToCopyFile=Failed to copy file '<b>%s</b>' into '<b>%s</b>'. ErrorFailToRenameFile=Failed to rename file '<b>%s</b>' into '<b>%s</b>'. ErrorFailToDeleteFile=Failed to remove file '<b>%s</b>'. ErrorFailToCreateFile=Failed to create file '<b>%s</b>'. diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index b708c2aba1a10564ade8799f600e72f04946f4e1..870589c83226b5cb4a8f65b6a9b28ec870f64917 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -11,6 +11,7 @@ ErrorLoginAlreadyExists=Le login %s existe déjà. ErrorGroupAlreadyExists=Le groupe %s existe déjà. ErrorRecordNotFound=Enregistrement non trouvé. ErrorDuplicateTrigger=Un fichier trigger de classe '<b>%s</b>' est présent plusieurs fois. Supprimer le doublon du répertoire '<b>%s</b>'. +ErrorFailToCopyFile=Echec de la copie du fichier '<b>%s</b>' en '<b>%s</b>'. ErrorFailToRenameFile=Echec du renommage du fichier '<b>%s</b>' en '<b>%s</b>'. ErrorFailToCreateFile=Echec de la création du fichier '<b>%s</b>'. ErrorFailToDeleteFile=Echec de l'effacement du fichier '<b>%s</b>'. diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index d0e68c1ba7eb98df41b3a52b940663dbb9b1f4da..286be96a8fc6e1cb0f7bb44f551c1e0c497e5e72 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -89,6 +89,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 238ddd48351ab59e23f5ffdba66447a0874c6b8b..c3c490ef4e1b8f9109ff88201941de3754538328 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -121,6 +121,9 @@ class BuildDocTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -133,6 +136,9 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index fccf9e2a3cbae905907dc4182fe4af68c2f2419b..f7bf4791f7ac737486adbe3c9c7c94ff69a989fc 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -89,6 +89,9 @@ class CMailFileTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class CMailFileTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index d254b81ba0ec56ce5ab5a26101e6f7e2a8bc0e36..a5634084c853bfde2879f9a14610f0f244c8ffa8 100755 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -90,6 +90,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index bb9f36b3601e88e6840c1837ad641403c134a43d..829efe78693bb478ca9bdc65add6e66ac58e7130 100755 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -89,6 +89,9 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index f4a30a78f7fb4838f4faf924fdd65818c49fadd0..da459471dd49cacf3add32b7aa34ee32e384f66f 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -90,6 +90,9 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -103,6 +106,9 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index ab92568f43d83bae906c1e9c356992aaae573160..6541d13f9d2be0ac9fc94a865d96f90a0af1e3dd 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -89,6 +89,9 @@ class CommandeTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CommandeTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index 34a01173b22ed5c67b2f47160c2ac93e19ae1f12..cae50abe534a4036c0f7c9b41bb69f0ac93c7beb 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -90,6 +90,9 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 70fc38eea545683ecc46b6536f9292c1899a341b..2c5b95c4e89c266cf4c867f3bb490a93f3510784 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -89,6 +89,9 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index d57ed5154a5439c3579469b54d666a6a61bcff20..f4ea66f0324534e21ebb98ad614462abf35b69d9 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -91,6 +91,9 @@ class ContactTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -103,6 +106,9 @@ class ContactTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -143,7 +149,7 @@ class ContactTest extends PHPUnit_Framework_TestCase $localobject=new Contact($this->savdb); $result=$localobject->fetch($id); - + print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 0d71f2850a16fb44a3690408a6cb5f82e004955a..fbf20f0deafe5698730b3636a47d446c2d2391e8 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -89,6 +89,9 @@ class ContratTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class ContratTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -120,10 +126,10 @@ class ContratTest extends PHPUnit_Framework_TestCase $localobject=new Contrat($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user); - + print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - + return $result; } @@ -141,10 +147,10 @@ class ContratTest extends PHPUnit_Framework_TestCase $localobject=new Contrat($this->savdb); $result=$localobject->fetch($id); - + print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); - + return $localobject; } diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 4ec3b477f3156daacff3f85c9b366cee5c1bea5d..a0eeb7404cc3357cbb2ac75bb33bcdf859fe46f9 100755 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -88,6 +88,9 @@ class CoreTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -100,6 +103,9 @@ class CoreTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 601f81354a3bce9f08e94c4df8c94ad33f994ec7..33c2eddefd21ba3acec242a6fa03948d0ecd7fbb 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -89,6 +89,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index 1b44aeb09f5fd75840b3d738b345ef44e4fc79c2..556acdcec13e780adad00b6c4ea65d3c17b4d9db 100755 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -89,6 +89,9 @@ class DiscountTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class DiscountTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 0e60171790b36b7f81b22ee41156d33ef8b0c612..d7ba76dae2b925131828421129358ac61d22ae15 100755 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -92,9 +92,9 @@ class ExportTest extends PHPUnit_Framework_TestCase } /** - * Ran on start + * Init phpunit tests * - * @return void + * @return void */ protected function setUp() { @@ -107,9 +107,9 @@ class ExportTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** - * Ran on start + * End phpunit tests * - * @return void + * @return void */ protected function tearDown() { diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index c162ec47d6eeb59e99d889a4b97ccdc7ed0d8f85..470fa6c49d68543389a77b56dc77ef613a63b7a0 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -89,6 +89,9 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 5a896452c3a9a53ff8c2aecb844107778bcf4d0f..3a608ce2bbd35da50a65c10b73fc23288185513f 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -90,6 +90,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -109,7 +115,10 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** - */ + * testDolCountNbOfLine + * + * @return int + */ public function testDolCountNbOfLine() { global $conf,$user,$langs,$db; @@ -127,7 +136,10 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** - */ + * testDolIsFileDir + * + * @return int + */ public function testDolIsFileDir() { global $conf,$user,$langs,$db; @@ -150,6 +162,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** + * testDolOther + * + * @return boolean */ public function testDolOther() { @@ -176,5 +191,53 @@ class FilesLibTest extends PHPUnit_Framework_TestCase return $result; } + + /** + * testDolCopyMove + * + * @return int + */ + public function testDolCopyMove() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $file=dirname(__FILE__).'/Example_import_company_1.csv'; + + $result=dol_copy($file, '/adir/that/does/not/exists/file.csv'); + print __METHOD__." result=".$result."\n"; + $this->assertLessThan(0,$result); // We should have error + + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(1,$result); // Should be 1 + + // Again to test with overwriting=0 + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,0); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0,$result); // Should be 0 + + // Again to test with overwriting=1 + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(1,$result); // Should be 1 + + // Again to test with overwriting=1 + $result=dol_move($conf->admin->dir_temp.'/file.csv',$conf->admin->dir_temp.'/file2.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result); + + $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result); + + // Again to test no erreor when deleteing a non existing file + $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result); + } } ?> \ No newline at end of file diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index 407818c2d21a2658996043e7a566c177b96be750..e650a8adb46a8bb5a2a811ea1baf0d44df8b49ac 100755 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -91,6 +91,9 @@ class ImportTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -103,6 +106,9 @@ class ImportTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index df27f147dc418f2587a8cece40251cd76b61a3cc..6df87dde2f2bf74b9c58e95cc29370507a64d952 100755 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -88,6 +88,9 @@ class ModulesTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -100,6 +103,9 @@ class ModulesTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() {