Fix permissions #yogosha13771

This commit is contained in:
Laurent Destailleur 2023-02-04 12:31:50 +01:00
parent 53be37148b
commit a7e1ed7c6c
3 changed files with 226 additions and 212 deletions

View File

@ -111,7 +111,7 @@ if (isModEnabled('facture')) {
} }
if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) { if (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) {
print getNumberInvoicesPieChart('fourn'); print getNumberInvoicesPieChart('suppliers');
print '<br>'; print '<br>';
} }

View File

@ -417,13 +417,16 @@ class Utils
} }
// TODO Replace with Utils->executeCLI() function but
// we must first introduce the variant with $lowmemorydump into this method.
if ($execmethod == 1) { if ($execmethod == 1) {
$output_arr = array(); $output_arr = array();
$retval = null; $retval = null;
exec($fullcommandclear, $output_arr, $retval); exec($fullcommandclear, $output_arr, $retval);
// TODO Replace this exec with Utils->executeCLI() function.
// We must check that the case for $lowmemorydump works too...
//$utils = new Utils($db);
//$outputfile = $conf->admin->dir_temp.'/dump.tmp';
//$utils->executeCLI($fullcommandclear, $outputfile, 0);
if ($retval != 0) { if ($retval != 0) {
$langs->load("errors"); $langs->load("errors");
@ -438,6 +441,8 @@ class Utils
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) { if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) {
continue; continue;
} }
// Now check into the result file, that the file end with "-- Dump completed"
// This is possible only if $output_arr is the clear dump file, so not possible with $lowmemorydump set because file is already compressed.
if (!$lowmemorydump) { if (!$lowmemorydump) {
fwrite($handle, $read.($execmethod == 2 ? '' : "\n")); fwrite($handle, $read.($execmethod == 2 ? '' : "\n"));
if (preg_match('/'.preg_quote('-- Dump completed', '/').'/i', $read)) { if (preg_match('/'.preg_quote('-- Dump completed', '/').'/i', $read)) {

View File

@ -280,8 +280,9 @@ function supplier_invoice_rec_prepare_head($object)
function getNumberInvoicesPieChart($mode) function getNumberInvoicesPieChart($mode)
{ {
global $conf, $db, $langs, $user; global $conf, $db, $langs, $user;
if (($mode == 'customers' && isModEnabled('facture') && !empty($user->rights->facture->lire)) if (($mode == 'customers' && isModEnabled('facture') && !empty($user->rights->facture->lire))
|| ($mode = 'suppliers') && (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && !empty($user->rights->facture->lire) || ($mode == 'suppliers' && (isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && !empty($user->rights->facture->lire))
) { ) {
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
@ -406,7 +407,9 @@ function getNumberInvoicesPieChart($mode)
dol_print_error($db); dol_print_error($db);
} }
} }
return '';
} }
/** /**
* Return a HTML table that contains a list with customer invoice drafts * Return a HTML table that contains a list with customer invoice drafts
* *
@ -418,9 +421,11 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0)
{ {
global $conf, $db, $langs, $user, $hookmanager; global $conf, $db, $langs, $user, $hookmanager;
$result = '';
if (isModEnabled('facture') && !empty($user->rights->facture->lire)) {
$maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
$result = '';
$tmpinvoice = new Facture($db); $tmpinvoice = new Facture($db);
$sql = "SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client"; $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total_ht, f.total_tva, f.total_ttc, f.ref_client";
@ -550,6 +555,7 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0)
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
}
return $result; return $result;
} }
@ -565,9 +571,11 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0)
{ {
global $conf, $db, $langs, $user, $hookmanager; global $conf, $db, $langs, $user, $hookmanager;
$result = '';
if ((isModEnabled('fournisseur') || isModEnabled('supplier_invoice')) && !empty($user->rights->facture->lire)) {
$maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
$result = '';
$facturesupplierstatic = new FactureFournisseur($db); $facturesupplierstatic = new FactureFournisseur($db);
$sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye"; $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye";
@ -679,6 +687,7 @@ function getDraftSupplierTable($maxCount = 500, $socid = 0)
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
}
return $result; return $result;
} }