|
|
|
|
@ -1236,13 +1236,16 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('\.meta$
|
|
|
|
|
* @param string $modulepart Module of document
|
|
|
|
|
* @param string $original_file Relative path with filename
|
|
|
|
|
* @param string $entity Restrict onto entity
|
|
|
|
|
* @param User $fuser User object (forced)
|
|
|
|
|
* @param string $refname Ref of object to check permission for external users (autodetect if not provided)
|
|
|
|
|
* @return mixed Array with access information : accessallowed & sqlprotectagainstexternals & original_file (as full path name)
|
|
|
|
|
*/
|
|
|
|
|
function dol_check_secure_access_document($modulepart,$original_file,$entity,$refname='')
|
|
|
|
|
function dol_check_secure_access_document($modulepart,$original_file,$entity,$fuser='',$refname='')
|
|
|
|
|
{
|
|
|
|
|
global $user, $conf, $db;
|
|
|
|
|
|
|
|
|
|
if (! is_object($fuser)) $fuser=$user;
|
|
|
|
|
|
|
|
|
|
if (empty($modulepart)) return 'ErrorBadParameter';
|
|
|
|
|
if (empty($entity)) $entity=0;
|
|
|
|
|
dol_syslog('$modulepart='.$modulepart.' $original_file= '.$original_file);
|
|
|
|
|
@ -1253,7 +1256,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
|
|
|
|
|
// find the subdirectory name as the reference
|
|
|
|
|
if (empty($refname)) $refname=basename(dirname($original_file)."/");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wrapping for some images
|
|
|
|
|
if ($modulepart == 'companylogo')
|
|
|
|
|
{
|
|
|
|
|
@ -1275,101 +1278,101 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les apercu factures
|
|
|
|
|
elseif ($modulepart == 'apercufacture')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->facture->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->facture->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->facture->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping pour les apercu propal
|
|
|
|
|
elseif ($modulepart == 'apercupropal')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->propale->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->propale->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->propal->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping pour les apercu commande
|
|
|
|
|
elseif ($modulepart == 'apercucommande')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->commande->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->commande->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->commande->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping pour les apercu intervention
|
|
|
|
|
elseif ($modulepart == 'apercufichinter')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->ficheinter->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->propale->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->commande->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->commande->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->commande->dir_temp.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
elseif ($modulepart == 'orderstatssupplier')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->fournisseur->commande->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->facture->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->facture->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->facture->dir_temp.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
elseif ($modulepart == 'billstatssupplier')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->fournisseur->facture->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->expedition->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->deplacement->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->adherent->lire) $accessallowed=1;
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->produit->lire || $user->rights->service->lire) $accessallowed=1;
|
|
|
|
|
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')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->tax->charges->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->tax->charges->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->tax->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping for products or services
|
|
|
|
|
elseif ($modulepart == 'actions')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->agenda->myactions->read) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->agenda->myactions->read) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->agenda->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping for categories
|
|
|
|
|
elseif ($modulepart == 'category')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->categorie->lire) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->categorie->lire) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping pour les prelevements
|
|
|
|
|
elseif ($modulepart == 'prelevement')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->prelevement->bons->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->prelevement->bons->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1412,7 +1415,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
elseif ($modulepart == 'scanner_user_temp')
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
$original_file=$conf->scanner->dir_temp.'/'.$user->id.'/'.$original_file;
|
|
|
|
|
$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
// Wrapping pour les images fckeditor
|
|
|
|
|
elseif ($modulepart == 'fckeditor')
|
|
|
|
|
@ -1424,7 +1427,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping for third parties
|
|
|
|
|
else if ($modulepart == 'company' || $modulepart == 'societe')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->societe->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->societe->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1435,7 +1438,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping for invoices
|
|
|
|
|
else if ($modulepart == 'facture' || $modulepart == 'invoice')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1445,7 +1448,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
|
|
|
|
|
else if ($modulepart == 'unpaid')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1455,7 +1458,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les fiches intervention
|
|
|
|
|
else if ($modulepart == 'ficheinter')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->ficheinter->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->ficheinter->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1466,7 +1469,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les deplacements et notes de frais
|
|
|
|
|
else if ($modulepart == 'deplacement')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->deplacement->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->deplacement->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1476,7 +1479,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les propales
|
|
|
|
|
else if ($modulepart == 'propal')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->propale->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->propale->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1488,7 +1491,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les commandes
|
|
|
|
|
else if ($modulepart == 'commande' || $modulepart == 'order')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->commande->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->commande->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1499,7 +1502,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les projets
|
|
|
|
|
else if ($modulepart == 'project')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->projet->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->projet->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1510,7 +1513,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les commandes fournisseurs
|
|
|
|
|
else if ($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->fournisseur->commande->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->fournisseur->commande->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1521,7 +1524,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les factures fournisseurs
|
|
|
|
|
else if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->fournisseur->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->fournisseur->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1532,18 +1535,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les rapport de paiements
|
|
|
|
|
else if ($modulepart == 'facture_paiement')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->facture->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
if ($user->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$user->id.'/'.$original_file;
|
|
|
|
|
if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file;
|
|
|
|
|
else $original_file=$conf->facture->dir_output.'/payments/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wrapping pour les exports de compta
|
|
|
|
|
else if ($modulepart == 'export_compta')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->compta->ventilation->creer || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->compta->ventilation->creer || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1553,7 +1556,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les expedition
|
|
|
|
|
else if ($modulepart == 'expedition')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->expedition->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->expedition->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1563,7 +1566,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les bons de livraison
|
|
|
|
|
else if ($modulepart == 'livraison')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->expedition->livraison->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->expedition->livraison->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1573,7 +1576,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les actions
|
|
|
|
|
else if ($modulepart == 'actions')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->agenda->myactions->read || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->agenda->myactions->read || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1583,7 +1586,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les actions
|
|
|
|
|
else if ($modulepart == 'actionsreport')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->agenda->allactions->read || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->agenda->allactions->read || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1593,7 +1596,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les produits et services
|
|
|
|
|
else if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service')
|
|
|
|
|
{
|
|
|
|
|
if (($user->rights->produit->lire || $user->rights->service->lire) || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if (($fuser->rights->produit->lire || $fuser->rights->service->lire) || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1604,7 +1607,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les contrats
|
|
|
|
|
else if ($modulepart == 'contract')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->contrat->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->contrat->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1614,7 +1617,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les dons
|
|
|
|
|
else if ($modulepart == 'donation')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->don->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->don->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1624,7 +1627,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les remises de cheques
|
|
|
|
|
else if ($modulepart == 'remisecheque')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->banque->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->banque->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1638,7 +1641,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Aucun test necessaire car on force le rep de download sur
|
|
|
|
|
// le rep export qui est propre a l'utilisateur
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
$original_file=$conf->export->dir_temp.'/'.$user->id.'/'.$original_file;
|
|
|
|
|
$original_file=$conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wrapping for import module
|
|
|
|
|
@ -1662,7 +1665,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour les backups
|
|
|
|
|
else if ($modulepart == 'systemtools')
|
|
|
|
|
{
|
|
|
|
|
if ($user->admin)
|
|
|
|
|
if ($fuser->admin)
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1672,7 +1675,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping for upload file test
|
|
|
|
|
else if ($modulepart == 'admin_temp')
|
|
|
|
|
{
|
|
|
|
|
if ($user->admin)
|
|
|
|
|
if ($fuser->admin)
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
$original_file=$conf->admin->dir_temp.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
@ -1689,7 +1692,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Wrapping pour Foundation module
|
|
|
|
|
else if ($modulepart == 'member')
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->adherent->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
if ($fuser->rights->adherent->lire || preg_match('/^specimen/i',$original_file))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1700,7 +1703,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
else if ($modulepart == 'scanner_user_temp')
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
$original_file=$conf->scanner->dir_temp.'/'.$user->id.'/'.$original_file;
|
|
|
|
|
$original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GENERIC Wrapping
|
|
|
|
|
@ -1713,18 +1716,18 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
// Define $accessallowed
|
|
|
|
|
if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg))
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read || ($user->rights->$reg[1]->download)) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->$reg[1]->dir_temp.'/'.$user->id.'/'.$original_file;
|
|
|
|
|
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 ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read || ($user->rights->$reg[1]->download)) $accessallowed=1;
|
|
|
|
|
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 ($user->rights->$reg[1]->lire || $user->rights->$reg[1]->read || ($user->rights->$reg[1]->download)) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->$reg[1]->dir_output.'/'.$user->id.'/'.$original_file;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -1732,24 +1735,24 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
$subperm=GETPOST('subperm');
|
|
|
|
|
if ($perm || $subperm)
|
|
|
|
|
{
|
|
|
|
|
if (($perm && ! $subperm && $user->rights->$modulepart->$perm) || ($perm && $subperm && $user->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
|
|
|
|
|
if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($user->rights->$modulepart->lire || $user->rights->$modulepart->read) $accessallowed=1;
|
|
|
|
|
if ($fuser->rights->$modulepart->lire || $fuser->rights->$modulepart->read) $accessallowed=1;
|
|
|
|
|
$original_file=$conf->$modulepart->dir_output.'/'.$original_file;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a specimen
|
|
|
|
|
if ($user->admin) $accessallowed=1; // If user is admin
|
|
|
|
|
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';
|
|
|
|
|
if (! empty($conf->global->$subPermCategoryConstName))
|
|
|
|
|
{
|
|
|
|
|
$subPermCategory = $conf->global->$subPermCategoryConstName;
|
|
|
|
|
if (! empty($subPermCategory) && (($user->rights->$modulepart->$subPermCategory->lire) || ($user->rights->$modulepart->$subPermCategory->read) || ($user->rights->$modulepart->$subPermCategory->download)))
|
|
|
|
|
if (! empty($subPermCategory) && (($fuser->rights->$modulepart->$subPermCategory->lire) || ($fuser->rights->$modulepart->$subPermCategory->read) || ($fuser->rights->$modulepart->$subPermCategory->download)))
|
|
|
|
|
{
|
|
|
|
|
$accessallowed=1;
|
|
|
|
|
}
|
|
|
|
|
@ -1763,7 +1766,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$re
|
|
|
|
|
eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ret = array(
|
|
|
|
|
'accessallowed' => $accessallowed,
|
|
|
|
|
'sqlprotectagainstexternals'=>$sqlprotectagainstexternals,
|
|
|
|
|
|