diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index ca6a5e93daea66f5b5733753023d1ff9715bd772..c25fc7d3194cc851abbdfe936ad9ddc2e09ceb2d 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -198,6 +198,8 @@ if ($_GET["action"] == 'addthumb')
if ($_GET["action"] == 'removelogo')
{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+
$logofile=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
dol_delete_file($logofile);
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO",$conf->entity);
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index eb1b3d440c6368ced94bfd9161aef189578db830..73a0de79f82d68304357ea6dd0ac75b0a0685d8f 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -25,6 +25,7 @@
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$langs->load("companies");
$langs->load("products");
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php
index 588fb7557b0fc0b2b04e514834890226914ead4c..82a531a1d9dc7940bd6603a0f4c8c188bf9f1b90 100644
--- a/htdocs/admin/tools/export.php
+++ b/htdocs/admin/tools/export.php
@@ -24,6 +24,7 @@
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
include_once $dolibarr_main_document_root."/lib/databases/".$conf->db->type.".lib.php";
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 18d5b7dfbfd4e148ea03ce2a9c6116ef8e807501..cb7691f2481a7eac1045f3aaf2008479314bb061 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -273,9 +273,9 @@ class Categorie
global $conf,$langs;
$error=0;
-
+
dol_syslog("Categorie::remove");
-
+
$this->db->begin();
if (! $error)
@@ -322,7 +322,7 @@ class Categorie
$error++;
}
}
-
+
// Link childs to parent
if (! $error)
{
@@ -358,7 +358,7 @@ class Categorie
// Fin appel triggers
}
}
-
+
if (! $error)
{
$this->db->commit();
@@ -1197,7 +1197,9 @@ class Categorie
*/
function delete_photo($file)
{
- $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+
+ $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
$filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 8d19c3f3f151c0b3509d543b71ac76d2ab224d41..52a7837855877b90bae65a177aa56346a52fce7c 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1592,6 +1592,7 @@ class Propal extends CommonObject
function delete($user, $notrigger=0)
{
global $conf,$langs;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 2bbc1b395885775e1c2a95e72deaf42768339716..f10924b2f095e61e7de22efcc81c9fa680beb890 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -170,6 +170,7 @@ class Commande extends CommonObject
function valid($user)
{
global $conf,$langs;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
@@ -2034,6 +2035,7 @@ class Commande extends CommonObject
function delete($user)
{
global $conf, $langs;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$err = 0;
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index eeff76857db79fe5584a719154b8e6b505d794bb..6f2b905de0d76a5e20d03c82c48a7efeb7283535 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -862,6 +862,8 @@ if ($_REQUEST['action'] == 'remove_file')
{
if ($object->fetch($id))
{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+
$upload_dir = $conf->commande->dir_output . "/";
$file = $upload_dir . '/' . $_GET['file'];
dol_delete_file($file);
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 234b7527dd1da52e4596d4340d945ad19c36ace8..2d99b46403b5fc93a4ee0d9b651eeb17e096b091 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1383,6 +1383,7 @@ class Facture extends CommonObject
function validate($user, $force_number='')
{
global $conf,$langs;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 6c0ccede91640bbfa74d2472d7550e6485104c62..89a2e9e4227a7719075db9011c0466a7d53ef12c 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -108,7 +108,8 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
// Delete
if ($action=='delete')
{
- $facture = new Facture($db);
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+ $facture = new Facture($db);
$facid=$_GET["id"];
if ($facture->fetch($facid))
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index d8af6d6626100e457b0cee974ab86589ee347a02..8f70fa2787648856e8b9242b6399d11a8da639bd 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -21,11 +21,11 @@
*/
/**
- \file htdocs/contrat/document.php
- \ingroup contrat
- \brief Page des documents joints sur les contrats
- \version $Id$
-*/
+ * \file htdocs/contrat/document.php
+ * \ingroup contrat
+ * \brief Page des documents joints sur les contrats
+ * \version $Id$
+ */
require ("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/contract.lib.php");
diff --git a/htdocs/ecm/docother.php b/htdocs/ecm/docother.php
index cb5048ae7bf39b7c2d922bd00c2a02f54187546b..1cc94cfbd2a81d2e3c8d7ecf7eafaac1d1f243df 100644
--- a/htdocs/ecm/docother.php
+++ b/htdocs/ecm/docother.php
@@ -3,15 +3,16 @@
*/
/**
- \file htdocs/ecm/docother.php
- \ingroup ecm
- \brief Main ecm page
- \version $Id$
- \author Laurent Destailleur
+ * \file htdocs/ecm/docother.php
+ * \ingroup ecm
+ * \brief Main ecm page
+ * \version $Id$
+ * \author Laurent Destailleur
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// Load traductions files
$langs->load("ecm");
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index cc1f52dedafac963f80e7435b4f2a1a12f514c2c..7e5a90911078e9987fc925cff148c24ffc6832c0 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -389,6 +389,7 @@ class Expedition extends CommonObject
function valid($user)
{
global $conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
dol_syslog("Expedition::valid");
@@ -727,10 +728,11 @@ class Expedition extends CommonObject
}
/**
- * \brief Delete shipping
+ * Delete shipping
*/
function delete()
{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index e26ab4bc00a3007e7ba1b83a55297f3653b1ec6c..259b4baa6c5cdec379570c9fac7239868e291ecf 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -517,6 +517,7 @@ class Fichinter extends CommonObject
function delete($user)
{
global $conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index f56091a872d2fceca54deb22c41acf04fe4f99fa..ace4a2e26a6872ee33704ffa75701ac7bce9b17a 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -255,6 +255,7 @@ class CommandeFournisseur extends Commande
function valid($user)
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;
@@ -828,7 +829,7 @@ class CommandeFournisseur extends Commande
if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
-
+
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
@@ -845,7 +846,7 @@ class CommandeFournisseur extends Commande
$pu=$pu_ttc;
}
$desc=trim($desc);
-
+
// Check parameters
if ($qty < 1 && ! $fk_product)
@@ -1148,10 +1149,10 @@ class CommandeFournisseur extends Commande
}
/**
- * \bref Set a delivery in database for this supplier order
- * \param user User that input data
- * \param date Date of reception
- * \param type Type of receipt
+ * Set a delivery in database for this supplier order
+ * @param user User that input data
+ * @param date Date of reception
+ * @param type Type of receipt
*/
function Livraison($user, $date, $type, $comment)
{
@@ -1390,7 +1391,7 @@ class CommandeFournisseur extends Commande
if (empty($txlocaltax2)) $txlocaltax2=0;
if (empty($remise)) $remise=0;
if (empty($remise_percent)) $remise_percent=0;
-
+
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
if (! $qty) $qty=1;
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index ef31e077a9d53104aa09747f5d98b2e5f037eab6..6d555bc25939514d0bd67827a44ee3174b11373e 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -523,7 +523,8 @@ if ($action == 'builddoc') // En get ou en post
// Delete file in doc form
if ($action=='remove_file')
{
- $commande = new CommandeFournisseur($db);
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+ $commande = new CommandeFournisseur($db);
if ($commande->fetch($id))
{
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 69a92b7798ce37bca4e7f65cc484c4f576e53ee5..86901f87d5945a645949b1cec2a98f72a69faf5f 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -851,6 +851,7 @@ if ($_REQUEST['action'] == 'builddoc')
// Delete file in doc form
if ($action=='remove_file')
{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$facture = new FactureFournisseur($db);
if ($facture->fetch($id))
diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php
index 3782766710fb071b1efb76b23d9d4e7a882a7d89..a905fef48086bb713085f7159a2f2523eebf4e7a 100644
--- a/htdocs/includes/modules/commande/modules_commande.php
+++ b/htdocs/includes/modules/commande/modules_commande.php
@@ -221,6 +221,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs)
function commande_delete_preview($db, $commandeid, $commanderef='')
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (!$commanderef)
{
diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php
index b286d87efa5f4946ed026ba4ca94f1f2def03876..c1c7a6966b546e6cccd4919946dda6079cdfbf88 100644
--- a/htdocs/includes/modules/facture/modules_facture.php
+++ b/htdocs/includes/modules/facture/modules_facture.php
@@ -293,6 +293,7 @@ function facture_meta_create($db, $facid, $message="")
function facture_delete_preview($db, $facid)
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$fac = new Facture($db,"",$facid);
$fac->fetch($facid);
diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php
index 362f3c59885aece947665e4b87a84210926e1a83..0b9f4c62e966bd2232e4452a9e8f099608a4ec47 100644
--- a/htdocs/includes/modules/fichinter/modules_fichinter.php
+++ b/htdocs/includes/modules/fichinter/modules_fichinter.php
@@ -210,6 +210,7 @@ function fichinter_create($db, $object, $modele='', $outputlangs='')
function fichinter_delete_preview($db, $fichinterid, $fichinterref='')
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (!$fichinterref)
{
diff --git a/htdocs/includes/modules/livraison/modules_livraison.php b/htdocs/includes/modules/livraison/modules_livraison.php
index 7d44cd756a0435a4df03014234fa89276493eaa4..9f6678423a2f84b680925dbd4c0025c2bb37e1a9 100644
--- a/htdocs/includes/modules/livraison/modules_livraison.php
+++ b/htdocs/includes/modules/livraison/modules_livraison.php
@@ -198,6 +198,7 @@ function delivery_order_pdf_create($db, $object, $model='', $outputlangs='')
function delivery_order_delete_preview($db, $deliveryid)
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$delivery = new Livraison($db,"",$deliveryid);
$delivery->fetch($deliveryid);
diff --git a/htdocs/includes/modules/project/modules_project.php b/htdocs/includes/modules/project/modules_project.php
index 6a10252bc57c096e65f92c958f09fabbc1381491..868ddf3a3f9bf23dd1415bfea9c9e3b4a95b0dc0 100644
--- a/htdocs/includes/modules/project/modules_project.php
+++ b/htdocs/includes/modules/project/modules_project.php
@@ -208,6 +208,7 @@ function project_pdf_create($db, $object, $model,$outputlangs)
function project_delete_preview($db, $objectid)
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$project = new Project($db);
$project->fetch($objectid);
diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php
index f3fea58c8b554a5300c677eb363ba8e001451df8..aa7f5e38dcbd3ccc7c4cfcac671fdf9b8c3f9f94 100644
--- a/htdocs/includes/modules/propale/modules_propale.php
+++ b/htdocs/includes/modules/propale/modules_propale.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/includes/modules/propale/modules_propale.php
* \ingroup propale
- * \brief Fichier contenant la classe mere de generation des propales en PDF
+ * \brief Fichier contenant la classe mere de generation des propales en PDF
* et la classe mere de numerotation des propales
* \version $Id$
*/
@@ -148,10 +148,10 @@ function propale_pdf_create($db, $object, $modele, $outputlangs)
// Positionne modele sur le nom du modele de propale a utiliser
$file = "pdf_propale_".$modele.".modules.php";
-
+
// On verifie l'emplacement du modele
$file = dol_buildpath($dir.$file);
-
+
if ($modele && file_exists($file)) $modelisok=1;
// Si model pas encore bon
@@ -226,6 +226,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs)
function propale_delete_preview($db, $propalid, $propalref='')
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if (!$propalref)
{
diff --git a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
index dd972c9a4c22fa78bb418fd0e49b147593762bee..9c78596cee123aa89804ab9822a09b4b8e14cb70 100755
--- a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
+++ b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php
@@ -129,6 +129,7 @@ function supplier_invoice_pdf_create($db, $object, $model, $outputlangs)
function supplier_invoice_delete_preview($db, $objectid)
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$comfourn = new FactureFournisseur($db,"",$objectid);
$comfourn->fetch($objectid);
diff --git a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php
index e2bcd7a9326c039fa3e3797141bc0275be083bcc..8f32ca7c7a15735ce42167409c6ef34101a811ae 100644
--- a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php
+++ b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php
@@ -204,6 +204,7 @@ function supplier_order_pdf_create($db, $object, $model, $outputlangs)
function supplier_order_delete_preview($db, $objectid)
{
global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$comfourn = new CommandeFournisseur($db,"",$objectid);
$comfourn->fetch($objectid);
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index a92f71d099bfeeee70cd1316b499e26247bd9d32..c763f7f15abb6b2eb0b2b78161174e52becd0794 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -39,6 +39,7 @@ require_once($dolibarr_main_document_root . '/commande/class/commande.class.php'
require_once($dolibarr_main_document_root . '/fourn/class/fournisseur.commande.class.php');
require_once($dolibarr_main_document_root . '/lib/price.lib.php');
require_once($dolibarr_main_document_root . '/core/class/menubase.class.php');
+require_once($dolibarr_main_document_root . '/lib/files.lib.php');
$grant_query='';
$etape = 2;
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 328590249b711e9f801ed2df9f33bfe5606839d2..3c37d9212c862b03acdc58b4d2436001b7b0ece7 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -316,6 +316,7 @@ class Livraison extends CommonObject
function valid($user)
{
global $conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
dol_syslog("livraison.class.php::valid begin");
@@ -501,7 +502,7 @@ class Livraison extends CommonObject
$line->qty = $expedition->lines[$i]->qty_shipped;
$line->fk_product = $expedition->lines[$i]->fk_product;
$line->ref = $expedition->lines[$i]->ref;
-
+
$this->lines[$i] = $line;
}
@@ -559,10 +560,10 @@ class Livraison extends CommonObject
/**
* Supprime la fiche
- *
*/
function delete()
{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
@@ -790,7 +791,7 @@ class Livraison extends CommonObject
$line->description = 'Description';
$line->price = 100;
$line->total_ht = 100;
-
+
$this->lines[$i] = $line;
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 090f22e67fb5f7560220c4cae8002f4bc7e21f50..c479381e83b6d95fed24213d09a1954bfca23ccb 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2682,7 +2682,9 @@ class Product extends CommonObject
*/
function delete_photo($file)
{
- $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+
+ $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
$filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 56a333911f32b6a4cd68d95a42fdc0bee88bd440..06b6381b95b7a063f4178b2b93cd9f59508cdf10 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -376,10 +376,12 @@ class Project extends CommonObject
* Delete a project from database
* @param user User
* @param notrigger Disable triggers
+ * @return int <0 if KO, 0 if not possible, >0 if OK
*/
function delete($user, $notrigger=0)
{
- global $conf;
+ global $langs,$conf;
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$error=0;