Debug v17

This commit is contained in:
Laurent Destailleur 2022-12-09 19:43:09 +01:00
parent 285a5e38f1
commit 97ccdc9207
9 changed files with 52 additions and 55 deletions

View File

@ -93,18 +93,18 @@ if (!empty($section)) {
} }
// Permissions // Permissions
$permtoadd = 0; $permissiontoadd = 0;
$permtoupload = 0; $permissiontoupload = 0;
if ($module == 'ecm') { if ($module == 'ecm') {
$permtoadd = $user->rights->ecm->setup; $permissiontoadd = $user->rights->ecm->setup;
$permtoupload = $user->rights->ecm->upload; $permissiontoupload = $user->rights->ecm->upload;
} }
if ($module == 'medias') { if ($module == 'medias') {
$permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permissiontoadd = ($user->rights->mailing->creer || $user->rights->website->write);
$permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $permissiontoupload = ($user->rights->mailing->creer || $user->rights->website->write);
} }
if (!$permtoadd) { if (!$permissiontoadd) {
accessforbidden(); accessforbidden();
} }
@ -115,7 +115,7 @@ if (!$permtoadd) {
*/ */
// Action ajout d'un produit ou service // Action ajout d'un produit ou service
if ($action == 'add' && $permtoadd) { if ($action == 'add' && $permissiontoadd) {
if ($cancel) { if ($cancel) {
if (!empty($backtopage)) { if (!empty($backtopage)) {
header("Location: ".$backtopage); header("Location: ".$backtopage);
@ -189,7 +189,7 @@ if ($action == 'add' && $permtoadd) {
exit; exit;
} }
} }
} elseif ($action == 'confirm_deletesection' && $confirm == 'yes' && $permtoadd) { } elseif ($action == 'confirm_deletesection' && $confirm == 'yes' && $permissiontoadd) {
// Deleting file // Deleting file
$result = $ecmdir->delete($user); $result = $ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');

View File

@ -90,21 +90,21 @@ if ($module == 'ecm') {
} }
// Permissions // Permissions
$permtoread = 0; $permissiontoread = 0;
$permtoadd = 0; $permissiontoadd = 0;
$permtoupload = 0; $permissiontoupload = 0;
if ($module == 'ecm') { if ($module == 'ecm') {
$permtoread = $user->rights->ecm->read; $permissiontoread = $user->rights->ecm->read;
$permtoadd = $user->rights->ecm->setup; $permissiontoadd = $user->rights->ecm->setup;
$permtoupload = $user->rights->ecm->upload; $permissiontoupload = $user->rights->ecm->upload;
} }
if ($module == 'medias') { if ($module == 'medias') {
$permtoread = ($user->rights->mailing->lire || $user->rights->website->read); $permissiontoread = ($user->rights->mailing->lire || $user->rights->website->read);
$permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permissiontoadd = ($user->rights->mailing->creer || $user->rights->website->write);
$permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $permissiontoupload = ($user->rights->mailing->creer || $user->rights->website->write);
} }
if (!$permtoread) { if (!$permissiontoread) {
accessforbidden(); accessforbidden();
} }
@ -114,7 +114,7 @@ if (!$permtoread) {
*/ */
// Upload file // Upload file
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC) && $permtoupload) { if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC) && $permissiontoupload) {
if (dol_mkdir($upload_dir) >= 0) { if (dol_mkdir($upload_dir) >= 0) {
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']); $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0) { if (is_numeric($resupload) && $resupload > 0) {
@ -139,7 +139,7 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC) && $permtoupload
} }
// Remove file // Remove file
if ($action == 'confirm_deletefile' && $confirm == 'yes' && $permtoupload) { if ($action == 'confirm_deletefile' && $confirm == 'yes' && $permissiontoupload) {
$langs->load("other"); $langs->load("other");
$file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret = dol_delete_file($file); $ret = dol_delete_file($file);
@ -153,7 +153,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && $permtoupload) {
} }
// Remove dir // Remove dir
if ($action == 'confirm_deletedir' && $confirm == 'yes' && $permtoupload) { if ($action == 'confirm_deletedir' && $confirm == 'yes' && $permissiontoupload) {
$backtourl = DOL_URL_ROOT."/ecm/index.php"; $backtourl = DOL_URL_ROOT."/ecm/index.php";
if ($module == 'medias') { if ($module == 'medias') {
$backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1"; $backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1";
@ -189,7 +189,7 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes' && $permtoupload) {
} }
// Update dirname or description // Update dirname or description
if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) { if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permissiontoadd) {
$error = 0; $error = 0;
if ($module == 'ecm') { if ($module == 'ecm') {
@ -454,17 +454,17 @@ print dol_get_fiche_end();
if ($action != 'edit' && $action != 'delete' && $action != 'deletefile') { if ($action != 'edit' && $action != 'delete' && $action != 'deletefile') {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($permtoadd) { if ($permissiontoadd) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().($module ? '&module='.$module : '').'&section='.$section.'">'.$langs->trans('Edit').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().($module ? '&module='.$module : '').'&section='.$section.'">'.$langs->trans('Edit').'</a>';
} }
if ($permtoadd) { if ($permissiontoadd) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&token='.newToken().($module ? '&module='.$module : '').'&catParent='.$section.'">'.$langs->trans('ECMAddSection').'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&token='.newToken().($module ? '&module='.$module : '').'&catParent='.$section.'">'.$langs->trans('ECMAddSection').'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>';
} }
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().($module ? '&module='.urlencode($module) : '').'&section='.urlencode($section).($backtopage ? '&backtopage='.urlencode($backtopage) : ''), '', $permtoadd); print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().($module ? '&module='.urlencode($module) : '').'&section='.urlencode($section).($backtopage ? '&backtopage='.urlencode($backtopage) : ''), '', $permissiontoadd);
print '</div>'; print '</div>';
} }

View File

@ -103,11 +103,11 @@ if ($result < 0) {
} }
// Permissions // Permissions
$permtoread = $user->rights->ecm->read; $permissiontoread = $user->rights->ecm->read;
$permtoadd = $user->rights->ecm->setup; $permissiontoadd = $user->rights->ecm->setup;
$permtoupload = $user->rights->ecm->upload; $permissiontoupload = $user->rights->ecm->upload;
if (!$permtoread) { if (!$permissiontoread) {
accessforbidden(); accessforbidden();
} }
@ -128,7 +128,7 @@ if ($cancel) {
} }
// Rename file // Rename file
if ($action == 'update' && $permtoadd) { if ($action == 'update' && $permissiontoadd) {
$error = 0; $error = 0;
$oldlabel = GETPOST('urlfile', 'alpha'); $oldlabel = GETPOST('urlfile', 'alpha');

View File

@ -108,9 +108,9 @@ if ($result < 0) {
$permissionnote = $user->rights->ecm->setup; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->ecm->setup; // Used by the include of actions_setnotes.inc.php
$permtoread = $user->rights->ecm->read; $permissiontoread = $user->rights->ecm->read;
if (!$permtoread) { if (!$permissiontoread) {
accessforbidden(); accessforbidden();
} }

View File

@ -90,7 +90,7 @@ if ($user->socid) {
} }
$result = restrictedArea($user, 'ecm', 0); $result = restrictedArea($user, 'ecm', 0);
$permtouploadfile = ($user->hasRight('ecm', 'setup') || $user->hasRight('mailing', 'creer') || $user->hasRight('website', 'write')); $permissiontouploadfile = ($user->hasRight('ecm', 'setup') || $user->hasRight('mailing', 'creer') || $user->hasRight('website', 'write'));
$diroutput = $conf->medias->multidir_output[$conf->entity]; $diroutput = $conf->medias->multidir_output[$conf->entity];
$relativepath = $section_dir; $relativepath = $section_dir;
@ -98,7 +98,7 @@ $upload_dir = preg_replace('/\/$/', '', $diroutput).'/'.preg_replace('/^\//', ''
$websitekey = ''; $websitekey = '';
$permissiontoadd = $permtouploadfile; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles $permissiontoadd = $permissiontouploadfile; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
/* /*
@ -123,7 +123,7 @@ if ($action == 'renamefile') { // Must be after include DOL_DOCUMENT_ROOT.'/core
// Add directory // Add directory
if ($action == 'add' && $permtouploadfile) { if ($action == 'add' && $permissiontouploadfile) {
$ecmdir->ref = 'NOTUSEDYET'; $ecmdir->ref = 'NOTUSEDYET';
$ecmdir->label = GETPOST("label"); $ecmdir->label = GETPOST("label");
$ecmdir->description = GETPOST("desc"); $ecmdir->description = GETPOST("desc");

View File

@ -85,9 +85,9 @@ if (!empty($section)) {
} }
} }
$permtoread = $user->rights->ecm->read; $permissiontoread = $user->rights->ecm->read;
if (!$permtoread) { if (!$permissiontoread) {
accessforbidden(); accessforbidden();
} }

View File

@ -42,18 +42,6 @@ if (empty($objectclass) || empty($uploaddir)) {
exit; exit;
} }
// For backward compatibility
if (!empty($permtoread) && empty($permissiontoread)) {
$permissiontoread = $permtoread;
}
if (!empty($permtocreate) && empty($permissiontoadd)) {
$permissiontoadd = $permtocreate;
}
if (!empty($permtodelete) && empty($permissiontodelete)) {
$permissiontodelete = $permtodelete;
}
// Mass actions. Controls on number of lines checked. // Mass actions. Controls on number of lines checked.
$maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); $maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) { if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {

View File

@ -144,19 +144,30 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
// Security check // Security check
if ($search_type == '0') { if ($search_type == '0') {
$result = restrictedArea($user, 'produit', '', '', '', '', '', 0); $result = restrictedArea($user, 'produit', '', '', '', '', '', 0);
$permissiontoread = $user->rights->produit->lire;
$permissiontodelete = $user->rights->produit->supprimer;
} elseif ($search_type == '1') { } elseif ($search_type == '1') {
$result = restrictedArea($user, 'service', '', '', '', '', '', 0); $result = restrictedArea($user, 'service', '', '', '', '', '', 0);
$permissiontoread = $user->rights->service->lire;
$permissiontodelete = $user->rights->service->supprimer;
} else { } else {
$result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0); $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0);
$permissiontoread = $user->rights->produit->lire;
$permissiontodelete = $user->rights->produit->supprimer;
} }
/* /*
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = ''; $action = 'list';
$massaction = '';
} }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = ''; $massaction = '';
@ -192,8 +203,6 @@ if (empty($reshook)) {
$objectlabel = 'Products'; $objectlabel = 'Products';
} }
$permtoread = $user->rights->produit->lire;
$permtodelete = $user->rights->produit->supprimer;
$uploaddir = $conf->product->dir_output; $uploaddir = $conf->product->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }

View File

@ -235,8 +235,8 @@ if (empty($reshook)) {
// Mass actions // Mass actions
$objectclass = "CurrencyRate"; $objectclass = "CurrencyRate";
$uploaddir = $conf->multicurrency->multidir_output; // define only because core/actions_massactions.inc.php want it $uploaddir = $conf->multicurrency->multidir_output; // define only because core/actions_massactions.inc.php want it
$permtoread = $user->admin; $permissiontoread = $user->admin;
$permtodelete = $user->admin; $permissiontodelete = $user->admin;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }