Compare commits

...

58 Commits
5.0.0 ... 4.0.5

Author SHA1 Message Date
Laurent Destailleur
4d7b059eb3 Release 4.0.5 2017-04-02 18:50:34 +02:00
Laurent Destailleur
2164d93f36 Merge pull request #6622 from marcosgdf/bug-6505
FIX #6621 Documents tab shows greyed out upload form even if the option to show actions not available is disabled
2017-03-31 19:22:49 +02:00
Laurent Destailleur
7b0c6ea940 Merge pull request #6620 from marcosgdf/bug-6619
FIX #6619 Template invoices list do not respect restricted thirdparty user rights
2017-03-31 18:41:46 +02:00
Laurent Destailleur
93b5801592 Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 4.0 2017-03-31 18:30:56 +02:00
Laurent Destailleur
911d5832c6 Merge branch '3.9' of git@github.com:Dolibarr/dolibarr.git into 4.0 2017-03-31 18:30:41 +02:00
Laurent Destailleur
b44143d24d Merge branch '3.8' of git@github.com:Dolibarr/dolibarr.git into 3.9 2017-03-31 18:29:15 +02:00
Laurent Destailleur
b970596310 Merge pull request #6481 from Hugome/fix-agenda-merge
FIX : Agenda getCalendarEvents hook
2017-03-31 18:26:45 +02:00
Laurent Destailleur
b642a8fe51 Merge pull request #6609 from atm-ph/fix_4.0_photo_jpeg_not_show
Fix picture with jpeg extension are not visible
2017-03-31 17:43:46 +02:00
Marcos García de La Fuente
cd5b074a48 FIX #6621 Documents tab shows greyed out upload form even if the option to show actions not available is disabled 2017-03-30 15:21:20 +02:00
Marcos García de La Fuente
2448b9ee55 FIX #6619 Template invoices list do not respect restricted thirdparty user rights 2017-03-30 14:52:26 +02:00
phf
2dc721c538 Fix picture with jpeg extension are not visible 2017-03-29 16:10:59 +02:00
Laurent Destailleur
90a90e1a3c FIX #6533 #6590 2017-03-28 12:45:09 +02:00
Laurent Destailleur
61031f1633 FIX Missing total on project overview. 2017-03-21 19:10:43 +01:00
Laurent Destailleur
e7e51d9e4f Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 4.0
Conflicts:
	htdocs/projet/class/project.class.php
2017-03-21 17:19:30 +01:00
Laurent Destailleur
43e70830ed Merge branch '3.9' of git@github.com:Dolibarr/dolibarr.git into 4.0 2017-03-21 17:18:41 +01:00
Laurent Destailleur
9e545e9628 Merge pull request #6538 from hregis/4.0_bug3
FIX wrong user fetch when same login in different entity
2017-03-18 03:55:20 +01:00
Regis Houssin
f03bdb91a4 Merge remote-tracking branch 'origin/4.0' into 4.0_bug3 2017-03-17 12:42:54 +01:00
Regis Houssin
9e944e4525 Fix: wrong user fetch when same login in different entity 2017-03-17 12:41:56 +01:00
Laurent Destailleur
9827887643 Merge pull request #6519 from marcosgdf/bug-multiprices
FIX Corrected bug where product multiprices admin page would not render properly due to a PHP fatal error
2017-03-14 10:45:47 +01:00
Laurent Destailleur
60a9268ff5 Merge pull request #6518 from marcosgdf/bug-6505
FIX #6505 Project elements page shows greyed-out links even if the option to show actions not available is disabled
2017-03-14 10:45:09 +01:00
Laurent Destailleur
214350a8f5 Merge pull request #6509 from marcosgdf/bug-6507
FIX #6507: Statistics counter show wrong total Contract numbers when the user does not have full access
2017-03-14 10:30:25 +01:00
Laurent Destailleur
53abc326b6 Merge pull request #6508 from marcosgdf/bug-6503
FIX #6503: SQL error in "Last pending payment invoices"
2017-03-14 10:25:59 +01:00
Laurent Destailleur
9e7230e63a Merge pull request #6484 from fmarcet/3.9
Fix: Error when references are numeric
2017-03-14 10:24:44 +01:00
Marcos García de La Fuente
15d0e6abc5 Corrected bug where product multiprices admin page would not render properly due to a PHP fatal error 2017-03-13 20:33:21 +01:00
Marcos García de La Fuente
cd349ab6cc FIX #6505 Project elements page shows greyed-out links even if the option to show actions not available is disabled
Close #6505
2017-03-13 20:17:31 +01:00
hugome
38ccf7ffdd Fix : Agenda getCalendarEvents hook
Return of getCalendarEvents on agenda page :
The array_merge change key of merged array.
2017-03-13 11:35:49 +01:00
Laurent Destailleur
6aeae12775 Fix medias could not be loaded 2017-03-13 02:28:58 +01:00
Marcos García de La Fuente
e9d5b44009 Fixed Project counter showing total amount of projects instead of just the projects current user can see 2017-03-12 15:31:39 +01:00
Marcos García de La Fuente
f15c6da887 Typo 2017-03-11 19:24:05 +01:00
Marcos García de La Fuente
e9c7b02049 FIX #6507: Statistics counter show wrong total Contract numbers when the user does not have full access
Close #6507
2017-03-11 19:22:01 +01:00
Marcos García de La Fuente
a39dccad19 FIX #6503: SQL error in "Last pending payment invoices"
Close #6503
2017-03-11 19:00:44 +01:00
Laurent Destailleur
277fa7dbe1 FIX #6444 2017-03-10 14:08:53 +01:00
Laurent Destailleur
fbbcec2ba3 FIX #6444 2017-03-10 14:04:06 +01:00
Laurent Destailleur
86d8fe1285 Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 4.0 2017-03-10 13:41:55 +01:00
Laurent Destailleur
1a57d1864a FIX #6443 2017-03-10 13:39:11 +01:00
Laurent Destailleur
427f656bac Merge pull request #6500 from atm-florian/4.0
FIX : Can use quote into supplier ref on order line add
2017-03-10 12:49:36 +01:00
Laurent Destailleur
6977daf76a Merge pull request #6491 from atm-gauthier/4.0_fix_supplierinvoiceline_fetch
FIX : forgotten fk_facture_fourn attribute on supplierinvoice line ob…
2017-03-10 12:31:20 +01:00
Laurent Destailleur
66d30344f9 Merge pull request #6490 from atm-gauthier/4.0_fix_fetch_infos_multicurrency
FIX : load multicurrency informations on supplier order and bill line…
2017-03-10 12:30:56 +01:00
Laurent Destailleur
bf34543085 FIX #6443 2017-03-10 12:19:50 +01:00
florian HENRY
9b10c9f6d1 FIX : Can use quote into supplier ref on order line add 2017-03-10 09:19:42 +01:00
gauthier
9eb3975803 FIX : forgotten fk_facture_fourn attribute on supplierinvoice line object 2017-03-07 15:18:20 +01:00
gauthier
b192b6cd50 FIX : multicurrency_subprice 2017-03-07 11:33:18 +01:00
gauthier
6e0589ce2c FIX : load multicurrency informations on supplier order and bill lines fetch 2017-03-07 10:55:17 +01:00
Laurent Destailleur
ee25a412dd Merge branch '3.9' of git@github.com:Dolibarr/dolibarr.git into 4.0
Conflicts:
	htdocs/commande/list.php
2017-03-05 22:02:16 +01:00
Laurent Destailleur
3ff456d8ef Merge pull request #6472 from atm-gauthier/FIX_param_billed
FIX : param billed when we change page
2017-03-05 21:33:42 +01:00
fmarcet
e1f459d67a Fix: Error when references are numeric 2017-03-03 12:57:52 +01:00
gauthier
9cd807af1a FIX : param billed when we change page 2017-02-28 12:31:45 +01:00
Laurent Destailleur
f579fc6b2d Code comment 2017-02-27 12:07:38 +01:00
Laurent Destailleur
1be389fd3e FIX deletion of bank tag 2017-02-27 12:06:45 +01:00
Laurent Destailleur
10838983b5 FIX error management in bank account deletion. 2017-02-27 11:38:19 +01:00
Laurent Destailleur
024cecec29 FIX Error management during bank account creation 2017-02-27 11:16:46 +01:00
Laurent Destailleur
0f8a8869cb FIX Error management during bank account creation 2017-02-27 11:15:59 +01:00
Laurent Destailleur
cff284b2f3 Merge branch '3.9' of git@github.com:Dolibarr/dolibarr.git into 4.0
Conflicts:
	htdocs/compta/bank/categ.php
2017-02-27 10:55:18 +01:00
Laurent Destailleur
9ecc56ad4d Merge branch '3.8' of git@github.com:Dolibarr/dolibarr.git into 3.9 2017-02-27 10:48:36 +01:00
Laurent Destailleur
e559834379 Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 4.0 2017-02-25 11:54:28 +01:00
Laurent Destailleur
08915d88d0 FIX the dolCopyDir fails if target dir does not exists. 2017-02-25 11:53:50 +01:00
Laurent Destailleur
290caba160 Merge pull request #6413 from atm-gauthier/3.8_FIX_delete_bank_class_when_delete_bank_categ
FIX : delete bank class lines when we delete bank_categ
2017-02-12 20:45:57 +01:00
gauthier
c01988ba43 FIX : delete bank class lines when we delete bank_categ 2017-02-09 17:28:37 +01:00
21 changed files with 379 additions and 189 deletions

View File

@@ -12,6 +12,42 @@ Upgrading to any other version or any other database system is abolutely require
make a Dolibarr upgrade.
***** ChangeLog for 4.0.5 to 4.0.4 *****
FIX: #6234
FIX: #6259
FIX: #6330
FIX: #6360
FIX: #6411
FIX: #6443
FIX: #6444
FIX: #6453
FIX: #6503: SQL error in "Last pending payment invoices"
FIX: #6505 Project elements page shows greyed-out links even if the option to show actions not available is disabled
FIX: #6507: Statistics counter show wrong total Contract numbers when the user does not have full access
FIX: #6533 #6590
FIX: #6619 Template invoices list do not respect restricted thirdparty user rights
FIX: #6621 Documents tab shows greyed out upload form even if the option to show actions not available is disabled
FIX: add entity param to document link
FIX: Can use quote into supplier ref on order line add
FIX: Change the customer code only if error on duplicate
FIX: Creation of credit note on invoice with deposit stole the discount.
FIX: delete bank class lines when we delete bank_categ
FIX: deletion of bank tag
FIX: detail of deposit and credit not was not visible into final invoice
FIX: Error management during bank account creation
FIX: error management in bank account deletion.
FIX: event status is not modified when assign an user
FIX: forgotten fk_facture_fourn attribute on supplierinvoice line object
FIX: If bank module on, field must be required to register payment of expense report.
FIX: load multicurrency informations on supplier order and bill lines fetch
FIX: Missing total on project overview.
FIX: multicurrency_subprice
FIX: param billed when we change page
FIX: protection against infinite loop on hierarchy
FIX: Supplier Order list filter by project
FIX: the dolCopyDir fails if target dir does not exists.
FIX: use param for http links
***** ChangeLog for 4.0.4 to 4.0.3 *****
FIX: #6227 Document models table header "Unit" is shown in 2 lines in Spanish
FIX: #6230

View File

@@ -1489,14 +1489,14 @@ class Categorie extends CommonObject
{
while (($file = readdir($handle)) !== false)
{
if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$dir.$file))
if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$dir.$file))
{
$nbphoto++;
$photo = $file;
// On determine nom du fichier vignette
$photo_vignette='';
if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs))
if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs))
{
$photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo).'_small'.$regs[0];
}
@@ -1539,7 +1539,7 @@ class Categorie extends CommonObject
dol_delete_file($file,1);
// Si elle existe, on efface la vignette
if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$filename,$regs))
if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$filename,$regs))
{
$photo_vignette=preg_replace('/'.$regs[0].'/i','',$filename).'_small'.$regs[0];
if (file_exists($dirthumb.$photo_vignette))

View File

@@ -933,7 +933,14 @@ if (count($listofextcals))
// Complete $eventarray with events coming from external module
$parameters=array(); $object=null;
$reshook=$hookmanager->executeHooks('getCalendarEvents',$parameters,$object,$action);
if (! empty($hookmanager->resArray['eventarray'])) $eventarray=array_merge($eventarray, $hookmanager->resArray['eventarray']);
if (! empty($hookmanager->resArray['eventarray'])) {
foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
if (!isset($eventarray[$keyDate])) {
$eventarray[$keyDate]=array();
}
$eventarray[$keyDate]=array_merge($eventarray[$keyDate], $events);
}
}

View File

@@ -401,6 +401,8 @@ if ($resql)
if ($search_total_vat != '') $param.='&search_total_vat='.$search_total_vat;
if ($search_total_ttc != '') $param.='&search_total_ttc='.$search_total_ttc;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($billed != '') $param.='&billed='.$billed;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{

View File

@@ -60,10 +60,12 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($account->table_element);
/*
* Actions
*/
if ($_POST["action"] == 'add')
if ($action == 'add')
{
$error=0;
@@ -129,6 +131,8 @@ if ($_POST["action"] == 'add')
if (! $error)
{
$db->begin();
$id = $account->create($user);
if ($id > 0)
{
@@ -137,15 +141,20 @@ if ($_POST["action"] == 'add')
$account->setCategories($categories);
$_GET["id"]=$id; // Force chargement page en mode visu
$action='';
$db->commit();
}
else {
$db->rollback();
setEventMessages($account->error, $account->errors, 'errors');
$action='create'; // Force chargement page en mode creation
}
}
}
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
if ($action == 'update' && ! $_POST["cancel"])
{
$error=0;
@@ -226,16 +235,25 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
}
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
{
// Delete
$account = new Account($db);
$account->fetch($_GET["id"]);
$account->delete();
$result = $account->delete($user);
if ($result > 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
exit;
}
else
{
setEventMessages($account->error, $account->errors, 'errors');
$action='';
}
}
/*

View File

@@ -72,6 +72,7 @@ if ($categid) {
}
}
/*
* View
*/

View File

@@ -596,12 +596,15 @@ class Account extends CommonObject
$accline->datec = $this->db->idate($now);
$accline->label = '('.$langs->trans("InitialBankBalance").')';
$accline->amount = price2num($this->solde);
$accline->fk_user_author = $user->id;
$accline->fk_account = $this->id;
$accline->datev = $this->db->idate($this->date_solde);
$accline->dateo = $this->db->idate($this->date_solde);
$accline->fk_type = 'SOLD';
if ($accline->insert() < 0) {
$this->error = $accline->error;
$this->errors = $accline->errors;
return -3;
}
@@ -947,29 +950,60 @@ class Account extends CommonObject
{
global $conf;
$error=0;
$this->db->begin();
// Delete link between tag and bank account
if (! $error)
{
//$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class"; // No more used
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_account = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
$this->error = "Error ".$this->db->lasterror();
}
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE rowid = ".$this->rowid;
$sql.= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
if ($result)
{
// Remove extrafields
if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
return -1;
}
}
}
else
{
$error++;
$this->error = "Error ".$this->db->lasterror();
}
}
if (! $error)
{
$this->db->commit();
return 1;
}
else {
dol_print_error($this->db);
else
{
$this->db->rollback();
return -1;
}
}

View File

@@ -197,18 +197,49 @@ class BankCateg // extends CommonObject
global $conf;
$error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
$sql .= " WHERE rowid=".$this->id;
$sql .= " AND entity = ".$conf->entity;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
// Delete link between tag and bank account
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_categorie = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql) {
if (!$resql)
{
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
// Delete link between tag and bank lines
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";
$sql.= " WHERE fk_categ = ".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
// Delete bank categ
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
$sql .= " WHERE rowid=".$this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
// Commit or rollback
if ($error) {

View File

@@ -1384,8 +1384,14 @@ else
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency,";
$sql.= " f.date_last_gen, f.date_when";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;
if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($search_ref) $sql .= natural_search('f.titre', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_frequency) $sql .= natural_search('f.frequency', $search_frequency);

View File

@@ -2045,7 +2045,7 @@ class Contrat extends CommonObject
$sql = "SELECT count(c.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if (!$user->rights->contrat->lire && !$user->societe_id)
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql.= " WHERE sc.fk_user = " .$user->id;

View File

@@ -78,8 +78,9 @@ class box_factures_imp extends ModeleBoxes
$sql.= " f.total_ttc,";
$sql.= " f.paye, f.fk_statut, f.rowid as facid";
$sql.= ", sum(pf.amount) as am";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity;

View File

@@ -89,6 +89,11 @@ class FormFile
}
else
{
//If there is no permission and the option to hide unauthorized actions is enabled, then nothing is printed
if (!$perm && !empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
return 1;
}
$maxlength=$size;
$out = "\n\n<!-- Start form attach new file -->\n";

View File

@@ -868,13 +868,23 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
$result=0;
dol_syslog("files.lib.php::dolCopyr srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
if (empty($srcfile) || empty($destfile)) return -1;
$destexists=dol_is_dir($destfile);
if (! $overwriteifexists && $destexists) return 0;
if (! $destexists)
{
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
umask(0);
$dirmaskdec=octdec($newmask);
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
dol_mkdir($destfile."/".$file, '', decoct($dirmaskdec));
}
$srcfile=dol_osencode($srcfile);
$destfile=dol_osencode($destfile);
@@ -891,6 +901,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
{
if (!is_dir($destfile."/".$file))
{
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
umask(0);
$dirmaskdec=octdec($newmask);
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
@@ -1055,7 +1066,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
}
// Security:
// On interdit fichiers caches, remontees de repertoire ainsi que les pipes dans les noms de fichiers.
// We refuse cache files/dirs, upload using .. and pipes into filenames.
if (preg_match('/^\./',$src_file) || preg_match('/\.\./',$src_file) || preg_match('/[<>|]/',$src_file))
{
dol_syslog("Refused to deliver file ".$src_file, LOG_WARNING);
@@ -1128,6 +1139,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
* @param int $nohook Disable all hooks
* @param object $object Current object in use
* @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error
* @see dol_delete_dir
*/
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null)
{
@@ -1139,6 +1151,14 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
dol_syslog("dol_delete_file file=".$file." disableglob=".$disableglob." nophperrors=".$nophperrors." nohook=".$nohook);
// Security:
// We refuse transversal using .. and pipes into filenames.
if (preg_match('/\.\./',$file) || preg_match('/[<>|]/',$file))
{
dol_syslog("Refused to delete file ".$file, LOG_WARNING);
return False;
}
if (empty($nohook))
{
$hookmanager->initHooks(array('fileslib'));
@@ -1203,9 +1223,18 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
* @param string $dir Directory to delete
* @param int $nophperrors Disable all PHP output errors
* @return boolean True if success, false if error
* @see dol_delete_file
*/
function dol_delete_dir($dir,$nophperrors=0)
{
// Security:
// We refuse transversal using .. and pipes into filenames.
if (preg_match('/\.\./',$dir) || preg_match('/[<>|]/',$dir))
{
dol_syslog("Refused to delete dir ".$dir, LOG_WARNING);
return False;
}
$dir_osencoded=dol_osencode($dir);
return ($nophperrors?@rmdir($dir_osencoded):rmdir($dir_osencoded));
}
@@ -1778,6 +1807,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta
function dol_check_secure_access_document($modulepart,$original_file,$entity,$fuser='',$refname='')
{
global $user, $conf, $db;
global $dolibarr_main_data_root;
if (! is_object($fuser)) $fuser=$user;
@@ -1792,120 +1822,122 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
// find the subdirectory name as the reference
if (empty($refname)) $refname=basename(dirname($original_file)."/");
$relative_original_file = $original_file;
// Wrapping for some images
if ($modulepart == 'companylogo')
if ($modulepart == 'companylogo' && !empty($conf->mycompany->dir_output))
{
$accessallowed=1;
$original_file=$conf->mycompany->dir_output.'/logos/'.$original_file;
}
// Wrapping for users photos
elseif ($modulepart == 'userphoto')
elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output))
{
$accessallowed=1;
$original_file=$conf->user->dir_output.'/'.$original_file;
}
// Wrapping for members photos
elseif ($modulepart == 'memberphoto')
elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output))
{
$accessallowed=1;
$original_file=$conf->adherent->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu factures
elseif ($modulepart == 'apercufacture')
elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output))
{
if ($fuser->rights->facture->lire) $accessallowed=1;
$original_file=$conf->facture->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu propal
elseif ($modulepart == 'apercupropal')
elseif ($modulepart == 'apercupropal' && !empty($conf->propal->dir_output))
{
if ($fuser->rights->propale->lire) $accessallowed=1;
$original_file=$conf->propal->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu commande
elseif ($modulepart == 'apercucommande')
elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output))
{
if ($fuser->rights->commande->lire) $accessallowed=1;
$original_file=$conf->commande->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu intervention
elseif ($modulepart == 'apercufichinter')
elseif ($modulepart == 'apercufichinter' && !empty($conf->ficheinter->dir_output))
{
if ($fuser->rights->ficheinter->lire) $accessallowed=1;
$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
}
// Wrapping pour les images des stats propales
elseif ($modulepart == 'propalstats')
elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp))
{
if ($fuser->rights->propale->lire) $accessallowed=1;
$original_file=$conf->propal->dir_temp.'/'.$original_file;
}
// Wrapping pour les images des stats commandes
elseif ($modulepart == 'orderstats')
elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp))
{
if ($fuser->rights->commande->lire) $accessallowed=1;
$original_file=$conf->commande->dir_temp.'/'.$original_file;
}
elseif ($modulepart == 'orderstatssupplier')
elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output))
{
if ($fuser->rights->fournisseur->commande->lire) $accessallowed=1;
$original_file=$conf->fournisseur->dir_output.'/commande/temp/'.$original_file;
}
// Wrapping pour les images des stats factures
elseif ($modulepart == 'billstats')
elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp))
{
if ($fuser->rights->facture->lire) $accessallowed=1;
$original_file=$conf->facture->dir_temp.'/'.$original_file;
}
elseif ($modulepart == 'billstatssupplier')
elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output))
{
if ($fuser->rights->fournisseur->facture->lire) $accessallowed=1;
$original_file=$conf->fournisseur->dir_output.'/facture/temp/'.$original_file;
}
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'expeditionstats')
elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp))
{
if ($fuser->rights->expedition->lire) $accessallowed=1;
$original_file=$conf->expedition->dir_temp.'/'.$original_file;
}
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'tripsexpensesstats')
elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp))
{
if ($fuser->rights->deplacement->lire) $accessallowed=1;
$original_file=$conf->deplacement->dir_temp.'/'.$original_file;
}
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'memberstats')
elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp))
{
if ($fuser->rights->adherent->lire) $accessallowed=1;
$original_file=$conf->adherent->dir_temp.'/'.$original_file;
}
// Wrapping pour les images des stats produits
elseif (preg_match('/^productstats_/i',$modulepart))
elseif (preg_match('/^productstats_/i',$modulepart) && !empty($conf->product->dir_temp))
{
if ($fuser->rights->produit->lire || $fuser->rights->service->lire) $accessallowed=1;
$original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file;
}
// Wrapping for products or services
elseif ($modulepart == 'tax')
elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output))
{
if ($fuser->rights->tax->charges->lire) $accessallowed=1;
$original_file=$conf->tax->dir_output.'/'.$original_file;
}
// Wrapping for products or services
elseif ($modulepart == 'actions')
elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
{
if ($fuser->rights->agenda->myactions->read) $accessallowed=1;
$original_file=$conf->agenda->dir_output.'/'.$original_file;
}
// Wrapping for categories
elseif ($modulepart == 'category')
elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output))
{
if ($fuser->rights->categorie->lire) $accessallowed=1;
$original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file;
}
// Wrapping pour les prelevements
elseif ($modulepart == 'prelevement')
elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output))
{
if ($fuser->rights->prelevement->bons->lire || preg_match('/^specimen/i',$original_file))
{
@@ -1914,19 +1946,19 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$original_file=$conf->prelevement->dir_output.'/'.$original_file;
}
// Wrapping pour les graph energie
elseif ($modulepart == 'graph_stock')
elseif ($modulepart == 'graph_stock' && !empty($conf->stock->dir_temp))
{
$accessallowed=1;
$original_file=$conf->stock->dir_temp.'/'.$original_file;
}
// Wrapping pour les graph fournisseurs
elseif ($modulepart == 'graph_fourn')
elseif ($modulepart == 'graph_fourn' && !empty($conf->fournisseur->dir_temp))
{
$accessallowed=1;
$original_file=$conf->fournisseur->dir_temp.'/'.$original_file;
}
// Wrapping pour les graph des produits
elseif ($modulepart == 'graph_product')
elseif ($modulepart == 'graph_product' && !empty($conf->product->dir_temp))
{
$accessallowed=1;
$original_file=$conf->product->multidir_temp[$entity].'/'.$original_file;
@@ -1935,32 +1967,31 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
elseif ($modulepart == 'barcode')
{
$accessallowed=1;
// If viewimage is called for barcode, we try to output an image on the fly,
// with not build of file on disk.
// If viewimage is called for barcode, we try to output an image on the fly, with no build of file on disk.
//$original_file=$conf->barcode->dir_temp.'/'.$original_file;
$original_file='';
}
// Wrapping pour les icones de background des mailings
elseif ($modulepart == 'iconmailing')
elseif ($modulepart == 'iconmailing' && !empty($conf->mailing->dir_temp))
{
$accessallowed=1;
$original_file=$conf->mailing->dir_temp.'/'.$original_file;
}
// Wrapping pour les icones de background des mailings
elseif ($modulepart == 'scanner_user_temp')
// Wrapping pour le scanner
elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp))
{
$accessallowed=1;
$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
}
// Wrapping pour les images fckeditor
elseif ($modulepart == 'fckeditor')
elseif ($modulepart == 'fckeditor' && !empty($conf->fckeditor->dir_output))
{
$accessallowed=1;
$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
}
// Wrapping for third parties
else if ($modulepart == 'company' || $modulepart == 'societe')
else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output))
{
if ($fuser->rights->societe->lire || preg_match('/^specimen/i',$original_file))
{
@@ -1971,7 +2002,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for contact
else if ($modulepart == 'contact')
else if ($modulepart == 'contact' && !empty($conf->societe->dir_output))
{
if ($fuser->rights->societe->lire)
{
@@ -1981,7 +2012,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for invoices
else if ($modulepart == 'facture' || $modulepart == 'invoice')
else if (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->dir_output))
{
if ($fuser->rights->facture->lire || preg_match('/^specimen/i',$original_file))
{
@@ -1990,7 +2021,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$original_file=$conf->facture->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
else if ($modulepart == 'massfilesarea_facture')
else if ($modulepart == 'massfilesarea_facture' && !empty($conf->facture->dir_output))
{
if ($fuser->rights->facture->lire || preg_match('/^specimen/i',$original_file))
{
@@ -1999,8 +2030,8 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
// Wrapping pour les fiches intervention
else if ($modulepart == 'ficheinter')
// Wrapping for interventions
else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output))
{
if ($fuser->rights->ficheinter->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2011,7 +2042,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les deplacements et notes de frais
else if ($modulepart == 'deplacement')
else if ($modulepart == 'deplacement' && !empty($conf->deplacement->dir_output))
{
if ($fuser->rights->deplacement->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2021,7 +2052,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
//$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
// Wrapping pour les propales
else if ($modulepart == 'propal')
else if ($modulepart == 'propal' && !empty($conf->propal->dir_output))
{
if ($fuser->rights->propale->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2033,7 +2064,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les commandes
else if ($modulepart == 'commande' || $modulepart == 'order')
else if (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->dir_output))
{
if ($fuser->rights->commande->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2044,7 +2075,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les projets
else if ($modulepart == 'project')
else if ($modulepart == 'project' && !empty($conf->projet->dir_output))
{
if ($fuser->rights->projet->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2053,7 +2084,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$original_file=$conf->projet->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
else if ($modulepart == 'project_task')
else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output))
{
if ($fuser->rights->projet->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2062,19 +2093,9 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$original_file=$conf->projet->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
// Wrapping for interventions
else if ($modulepart == 'fichinter')
{
if ($fuser->rights->ficheinter->lire || preg_match('/^specimen/i',$original_file))
{
$accessallowed=1;
}
$original_file=$conf->ficheinter->dir_output.'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
// Wrapping pour les commandes fournisseurs
else if ($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier')
else if (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output))
{
if ($fuser->rights->fournisseur->commande->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2085,7 +2106,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les factures fournisseurs
else if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier')
else if (($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') && !empty($conf->fournisseur->facture->dir_output))
{
if ($fuser->rights->fournisseur->facture->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2096,7 +2117,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les rapport de paiements
else if ($modulepart == 'facture_paiement')
else if ($modulepart == 'facture_paiement' && !empty($conf->facture->dir_output))
{
if ($fuser->rights->facture->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2107,7 +2128,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for accounting exports
else if ($modulepart == 'export_compta')
else if ($modulepart == 'export_compta' && !empty($conf->accounting->dir_output))
{
if ($fuser->rights->accounting->ventilation->dispatch || preg_match('/^specimen/i',$original_file))
{
@@ -2117,7 +2138,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les expedition
else if ($modulepart == 'expedition')
else if ($modulepart == 'expedition' && !empty($conf->expedition->dir_output))
{
if ($fuser->rights->expedition->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2127,7 +2148,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les bons de livraison
else if ($modulepart == 'livraison')
else if ($modulepart == 'livraison' && !empty($conf->livraison->dir_output))
{
if ($fuser->rights->expedition->livraison->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2137,7 +2158,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les actions
else if ($modulepart == 'actions')
else if ($modulepart == 'actions' && !empty($conf->agenda->dir_output))
{
if ($fuser->rights->agenda->myactions->read || preg_match('/^specimen/i',$original_file))
{
@@ -2147,7 +2168,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les actions
else if ($modulepart == 'actionsreport')
else if ($modulepart == 'actionsreport' && !empty($conf->agenda->dir_temp))
{
if ($fuser->rights->agenda->allactions->read || preg_match('/^specimen/i',$original_file))
{
@@ -2168,7 +2189,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les contrats
else if ($modulepart == 'contract')
else if ($modulepart == 'contract' && !empty($conf->contrat->dir_output))
{
if ($fuser->rights->contrat->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2178,7 +2199,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les dons
else if ($modulepart == 'donation')
else if ($modulepart == 'donation' && !empty($conf->donation->dir_output))
{
if ($fuser->rights->don->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2188,7 +2209,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour les remises de cheques
else if ($modulepart == 'remisecheque')
else if ($modulepart == 'remisecheque' && !empty($conf->banque->dir_output))
{
if ($fuser->rights->banque->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2199,7 +2220,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for bank
else if ($modulepart == 'bank')
else if ($modulepart == 'bank' && !empty($conf->bank->dir_output))
{
if ($fuser->rights->banque->lire)
{
@@ -2209,7 +2230,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for export module
else if ($modulepart == 'export')
else if ($modulepart == 'export' && !empty($conf->export->dir_temp))
{
// Aucun test necessaire car on force le rep de download sur
// le rep export qui est propre a l'utilisateur
@@ -2218,47 +2239,42 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for import module
else if ($modulepart == 'import')
else if ($modulepart == 'import' && !empty($conf->import->dir_temp))
{
$accessallowed=1;
$original_file=$conf->import->dir_temp.'/'.$original_file;
}
// Wrapping pour l'editeur wysiwyg
else if ($modulepart == 'editor')
else if ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output))
{
$accessallowed=1;
$original_file=$conf->fckeditor->dir_output.'/'.$original_file;
}
// Wrapping for miscellaneous medias files
elseif ($modulepart == 'medias')
elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root))
{
$accessallowed=1;
global $dolibarr_main_data_root;
$original_file=$dolibarr_main_data_root.'/medias/'.$original_file;
}
// Wrapping for backups
else if ($modulepart == 'systemtools')
else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output))
{
if ($fuser->admin)
{
$accessallowed=1;
}
if ($fuser->admin) $accessallowed=1;
$original_file=$conf->admin->dir_output.'/'.$original_file;
}
// Wrapping for upload file test
else if ($modulepart == 'admin_temp')
else if ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp))
{
if ($fuser->admin)
$accessallowed=1;
if ($fuser->admin) $accessallowed=1;
$original_file=$conf->admin->dir_temp.'/'.$original_file;
}
// Wrapping pour BitTorrent
else if ($modulepart == 'bittorrent')
else if ($modulepart == 'bittorrent' && !empty($conf->bittorrent->dir_output))
{
$accessallowed=1;
$dir='files';
@@ -2267,7 +2283,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping pour Foundation module
else if ($modulepart == 'member')
else if ($modulepart == 'member' && !empty($conf->adherent->dir_output))
{
if ($fuser->rights->adherent->lire || preg_match('/^specimen/i',$original_file))
{
@@ -2277,7 +2293,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
}
// Wrapping for Scanner
else if ($modulepart == 'scanner_user_temp')
else if ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp))
{
$accessallowed=1;
$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
@@ -2290,19 +2306,37 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
// If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart
else
{
if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
if ($fuser->admin) $accessallowed=1; // If user is admin
// Define $accessallowed
if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
{
if (empty($conf->{$reg[1]}->dir_temp)) // modulepart not supported
{
dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1;
$original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file;
}
else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg))
{
if (empty($conf->{$reg[1]}->dir_temp)) // modulepart not supported
{
dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1;
$original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file;
}
else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg))
{
if (empty($conf->{$reg[1]}->dir_output)) // modulepart not supported
{
dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')');
exit;
}
if ($fuser->rights->{$reg[1]}->lire || $fuser->rights->{$reg[1]}->read || ($fuser->rights->{$reg[1]}->download)) $accessallowed=1;
$original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file;
}
@@ -2327,8 +2361,6 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
}
}
if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a specimen
if ($fuser->admin) $accessallowed=1; // If user is admin
// For modules who wants to manage different levels of permissions for documents
$subPermCategoryConstName = strtoupper($modulepart).'_SUBPERMCATEGORY_FOR_DOCUMENTS';

View File

@@ -1457,7 +1457,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", '".$localtax1_type."',";
$sql.= " '".$localtax2_type."'";
$sql.= ", ".$remise_percent.",'".price2num($subprice,'MU')."','".$ref."',";
$sql.= ", ".$remise_percent.",'".price2num($subprice,'MU')."','".$this->db->escape($ref)."',";
$sql.= "'".price2num($total_ht)."',";
$sql.= "'".price2num($total_tva)."',";
$sql.= "'".price2num($total_localtax1)."',";
@@ -2752,7 +2752,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
$sql.= ' cd.total_localtax1, cd.total_localtax2,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
$sql.= ' cd.date_start, cd.date_end, cd.fk_unit';
$sql.= ' cd.date_start, cd.date_end, cd.fk_unit,';
$sql.= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
$sql.= ' WHERE cd.rowid = '.$rowid;
@@ -2787,6 +2788,11 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->date_end = $this->db->jdate($objp->date_end);
$this->fk_unit = $objp->fk_unit;
$this->multicurrency_subprice = $objp->multicurrency_subprice;
$this->multicurrency_total_ht = $objp->multicurrency_total_ht;
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$this->db->free($result);
return 1;
}

View File

@@ -2076,8 +2076,9 @@ class SupplierInvoiceLine extends CommonObjectLine
{
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
$sql.= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
$sql.= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
$sql.= ' WHERE f.rowid = '.$rowid;
@@ -2098,6 +2099,7 @@ class SupplierInvoiceLine extends CommonObjectLine
$this->id = $obj->rowid;
$this->rowid = $obj->rowid;
$this->fk_facture_fourn = $obj->fk_facture_fourn;
$this->description = $obj->description;
$this->product_ref = $obj->product_ref;
$this->ref = $obj->product_ref;
@@ -2130,6 +2132,11 @@ class SupplierInvoiceLine extends CommonObjectLine
$this->rang = $obj->rang;
$this->fk_unit = $obj->fk_unit;
$this->multicurrency_subprice = $obj->multicurrency_subprice;
$this->multicurrency_total_ht = $obj->multicurrency_total_ht;
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
return 1;
}

View File

@@ -565,19 +565,16 @@ if (empty($action))
if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,';
$sql.= ' SUM(f.amount)';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid)
{
$sql .= ' AND f.fk_soc = '.$socid;
}
if ($socid > 0) $sql .= ' AND f.fk_soc = '.$socid;
// Search criteria
if ($search_ref) $sql .= natural_search('p.rowid', $search_ref);
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;

View File

@@ -576,9 +576,10 @@ if (! defined('NOLOGIN'))
{
// We are already into an authenticated session
$login=$_SESSION["dol_login"];
dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login, LOG_DEBUG);
$entity=$_SESSION["dol_entity"];
dol_syslog("This is an already logged session. _SESSION['dol_login']=".$login." _SESSION['dol_entity']=".$entity, LOG_DEBUG);
$resultFetchUser=$user->fetch('',$login);
$resultFetchUser=$user->fetch('',$login,'',1,($entity > 0 ? $entity : -1));
if ($resultFetchUser <= 0)
{
// Account has been removed after login

View File

@@ -155,7 +155,6 @@ $genPriceOptions = function($level) use ($price_options) {
return $return;
};
?>
<table class="noborder">
@@ -173,7 +172,8 @@ $genPriceOptions = function($level) use ($price_options) {
<td class="fieldrequired" style="text-align: center"><?php
echo $langs->trans('SellingPrice').' '.$i;
// Label of price
if (! empty($conf->global->{"PRODUIT_MULTIPRICES_LABEL$i"})) {
$keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i;
if (! empty($conf->global->$keyforlabel)) {
print ' - '.$langs->trans($conf->global->$keyforlabel);
}
?>

View File

@@ -12,7 +12,7 @@
* Copyright (C) 2014 Henry Florian <florian.henry@open-concept.pro>
* Copyright (C) 2014-2016 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2014 Ion agorria <ion@agorria.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016-2017 Ferran Marcet <fmarcet@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
@@ -816,7 +816,7 @@ class Product extends CommonObject
// End call triggers
}
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
{
// We remove directory
if ($conf->product->dir_output)

View File

@@ -3,7 +3,8 @@
* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014-2017 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@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
@@ -292,7 +293,7 @@ class Project extends CommonObject
}
}
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref))
{
// We remove directory
if ($conf->projet->dir_output)
@@ -1689,16 +1690,20 @@ class Project extends CommonObject
*/
function load_state_board()
{
global $conf;
global $user;
$this->nb=array();
$sql = "SELECT count(u.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as u";
$sql.= " WHERE";
//$sql.= " WHERE u.fk_statut > 0";
//$sql.= " AND employee != 0";
$sql.= " u.entity IN (".getEntity('projet', 1).")";
$sql = "SELECT DISTINCT
count(p.rowid) as nb
FROM ".MAIN_DB_PREFIX."projet AS p LEFT JOIN ".MAIN_DB_PREFIX."societe AS s ON p.fk_soc = s.rowid
LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status AS cls ON p.fk_opp_status = cls.rowid
WHERE p.entity IN (".getEntity('projet', 1).")";
if (! $user->rights->projet->all->lire) {
$projectsListId = $this->getProjectsAuthorizedForUser($user,0,1);
$sql .= "AND p.rowid IN (".$projectsListId.")";
}
$resql=$this->db->query($sql);
if ($resql)

View File

@@ -612,7 +612,9 @@ foreach ($listofreferent as $key => $value)
{
$addform.='<div class="inline-block valignmiddle">';
if ($testnew) $addform.='<a class="buttonxxx" href="'.$urlnew.'">'.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).'</a>';
else $addform.='<a class="buttonxxx buttonRefused" disabled="disabled" href="#">'.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).'</a>';
elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
$addform.='<a class="buttonxxx buttonRefused" disabled="disabled" href="#">'.($buttonnew?$langs->trans($buttonnew):$langs->trans("Create")).'</a>';
}
$addform.='<div>';
}
@@ -954,7 +956,7 @@ foreach ($listofreferent as $key => $value)
print '<td align="right">';
if (empty($value['disableamount']))
{
if (! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht);
if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht);
}
print '</td>';
//if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>';
@@ -962,8 +964,7 @@ foreach ($listofreferent as $key => $value)
print '<td align="right">';
if (empty($value['disableamount']))
{
if (! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc);
if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc);
}
print '</td>';
print '<td>&nbsp;</td>';