The 'action=delete&file=...' has been replaced with

'action=deletefile&file=...' to avoid confusion with deletion of object
lines.
This commit is contained in:
Laurent Destailleur 2021-10-10 21:11:48 +02:00
parent 1b504b3e2c
commit 874731af84
14 changed files with 37 additions and 34 deletions

View File

@ -14,7 +14,7 @@ Following changes may create regressions for some external modules, but were nec
* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook. * Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook.
* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale. * Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale.
* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param). * The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param).
* The 'action=delete&file=...' has been replaced with 'action=deletefile&file=...' to avoid confusion with deletion of object lines.
***** ChangeLog for 14.0.2 compared to 14.0.1 ***** ***** ChangeLog for 14.0.2 compared to 14.0.1 *****

View File

@ -63,7 +63,7 @@ if ($action == 'updateform') {
if ($res3 && $res4 && $res5 && $res6) { if ($res3 && $res4 && $res5 && $res6) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} }
} elseif ($action == 'delete') { } elseif ($action == 'deletefile') {
// Delete file // Delete file
$langs->load("other"); $langs->load("other");
$file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha'); $file = $conf->admin->dir_temp.'/'.GETPOST('urlfile', 'alpha');

View File

@ -55,7 +55,7 @@ if (!$user->admin) {
* Actions * Actions
*/ */
if ($action == 'delete') { if ($action == 'deletefile') {
if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) { if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) {
$file = $conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $file = $conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
$ret = dol_delete_file($file, 1); $ret = dol_delete_file($file, 1);

View File

@ -163,7 +163,7 @@ if ($resql) {
// Button to build doc // Button to build doc
print '<td class="center">'; print '<td class="center">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&page='.((int) $page).'&month='.((int) $obj->month).'&year='.((int) $obj->year).'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
print '</td>'; print '</td>';
$name = "actions-".$obj->month."-".$obj->year.".pdf"; $name = "actions-".$obj->month."-".$obj->year.".pdf";

View File

@ -396,9 +396,9 @@ if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
//$param.=($param?'?':'').(preg_replace('/^&/','',$param)); //$param.=($param?'?':'').(preg_replace('/^&/','',$param));
if ($useajax || $action == 'delete') { if ($useajax || $action == 'deletefile') {
$urlfile = ''; $urlfile = '';
if ($action == 'delete') { if ($action == 'deletefile') {
$urlfile = GETPOST('urlfile', 'alpha'); $urlfile = GETPOST('urlfile', 'alpha');
} }

View File

@ -1338,11 +1338,11 @@ class FormFile
print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid'] > 0 ? $filearray[$key]['rowid'] : 'AFTER'.$lastrowid.'POS'.($i + 1)).'">'; print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid'] > 0 ? $filearray[$key]['rowid'] : 'AFTER'.$lastrowid.'POS'.($i + 1)).'">';
// File name // File name
print '<td class="minwith200">'; print '<td class="minwith200 tdoverflowmax500">';
// Show file name with link to download // Show file name with link to download
//print "XX".$file['name']; //$file['name'] must be utf8 //print "XX".$file['name']; //$file['name'] must be utf8
print '<a class="paddingright" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; print '<a class="paddingright valignmiddle" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
if ($forcedownload) { if ($forcedownload) {
print '&attachment=1'; print '&attachment=1';
} }
@ -1351,7 +1351,7 @@ class FormFile
} }
print '&file='.urlencode($filepath); print '&file='.urlencode($filepath);
print '">'; print '">';
print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'], 0, 0).')', 'inline-block valignbottom paddingright'); print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'], 0, 0).')', 'inline-block valignmiddle paddingright');
if ($showrelpart == 1) { if ($showrelpart == 1) {
print $relativepath; print $relativepath;
} }
@ -1503,7 +1503,7 @@ class FormFile
if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) { if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
$useajax = 0; $useajax = 0;
} }
print '<a href="'.((($useinecm && $useinecm != 6) && $useajax) ? '#' : ($url.'?action=delete&token='.newToken().'&urlfile='.urlencode($filepath).$param)).'" class="reposition deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>'; print '<a href="'.((($useinecm && $useinecm != 6) && $useajax) ? '#' : ($url.'?action=deletefile&token='.newToken().'&urlfile='.urlencode($filepath).$param)).'" class="reposition deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
} }
print "</td>"; print "</td>";
@ -1511,10 +1511,10 @@ class FormFile
if ($nboffiles > 1 && $conf->browser->layout != 'phone') { if ($nboffiles > 1 && $conf->browser->layout != 'phone') {
print '<td class="linecolmove tdlineupdown center">'; print '<td class="linecolmove tdlineupdown center">';
if ($i > 0) { if ($i > 0) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id.'">'.img_up('default', 0, 'imgupforline').'</a>'; print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">'.img_up('default', 0, 'imgupforline').'</a>';
} }
if ($i < $nboffiles - 1) { if ($i < $nboffiles - 1) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id.'">'.img_down('default', 0, 'imgdownforline').'</a>'; print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">'.img_down('default', 0, 'imgdownforline').'</a>';
} }
print '</td>'; print '</td>';
} else { } else {

View File

@ -63,10 +63,10 @@ if (in_array($modulepart, array('product', 'produit', 'societe', 'user', 'ticket
/* /*
* Confirm form to delete * Confirm form to delete a file
*/ */
if ($action == 'delete') { if ($action == 'deletefile') {
$langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles
print $form->formconfirm( print $form->formconfirm(
$_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param), $_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param),

View File

@ -17,7 +17,7 @@
/** /**
* \file htdocs/ecm/ajax/ecmdatabase.php * \file htdocs/ecm/ajax/ecmdatabase.php
* \brief File to build ecm database * \brief File to build/refresh the ecm database for directories
*/ */
if (!defined('NOTOKENRENEWAL')) { if (!defined('NOTOKENRENEWAL')) {
@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$element = GETPOST('element', 'alpha'); $element = GETPOST('element', 'alpha');
/* /*
* View * View
*/ */
@ -86,7 +87,7 @@ if (isset($action) && !empty($action)) {
} }
if (!$dirisindatabase) { if (!$dirisindatabase) {
$txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it"; $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into table ecm_directories, so we add it";
dol_syslog($txt); dol_syslog($txt);
// We must first find the fk_parent of directory to create $dirdesc['fullname'] // We must first find the fk_parent of directory to create $dirdesc['fullname']
@ -155,15 +156,16 @@ if (isset($action) && !empty($action)) {
foreach ($sqltree as $dirdesc) { // Loop on each sqltree to check dir is on disk foreach ($sqltree as $dirdesc) { // Loop on each sqltree to check dir is on disk
$dirtotest = $conf->$element->dir_output.'/'.$dirdesc['fullrelativename']; $dirtotest = $conf->$element->dir_output.'/'.$dirdesc['fullrelativename'];
if (!dol_is_dir($dirtotest)) { if (!dol_is_dir($dirtotest)) {
$mesg .= $dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."<br>\n"; dol_syslog($dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']);
$ecmdirtmp->id = $dirdesc['id']; $ecmdirtmp->id = $dirdesc['id'];
$ecmdirtmp->delete($user, 'databaseonly'); $ecmdirtmp->delete($user, 'databaseonly');
//exit; //exit;
} }
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown" dol_syslog("Nb of directories added into database = ".$adirwascreated);
dol_syslog("sql = ".$sql);
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cache counting, we set to value -1 = "unknown"
$db->query($sql); $db->query($sql);
} }
} }

View File

@ -450,7 +450,7 @@ print dol_get_fiche_end();
// Actions buttons // Actions buttons
if ($action != 'edit' && $action != 'delete') { if ($action != 'edit' && $action != 'delete' && $action != 'deletefile') {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($permtoadd) { if ($permtoadd) {
@ -482,8 +482,8 @@ if ($action != 'edit' && $action != 'delete') {
} }
// Confirm remove file // Confirm remove file
if ($action == 'delete') { if ($action == 'deletefile') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST("section", 'alpha').'&urlfile='.urlencode($_GET["urlfile"]).($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile'); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode(GETPOST("section", 'alpha')).'&urlfile='.urlencode(GETPOST("urlfile")).($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
} }
// Confirm remove file // Confirm remove file
@ -498,7 +498,7 @@ if ($action == 'delete_dir') {
); );
} }
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section', 'alpha').($module ? '&module='.$module : '').($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode(GETPOST('section', 'alpha')).($module ? '&module='.$module : '').($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1);
} }

View File

@ -411,8 +411,8 @@ if ($action == 'edit') {
} }
// Confirmation de la suppression d'une ligne categorie // Confirm deletion of a file
if ($action == 'delete_file') { if ($action == 'deletefile') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.urlencode($section), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile', $urlfile), 'confirm_deletefile', '', 1, 1);
} }
@ -426,7 +426,7 @@ if ($action != 'edit') {
/* /*
if ($user->rights->ecm->setup) if ($user->rights->ecm->setup)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_file&token='.newToken().'&section='.$section.'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Delete').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=deletefile&token='.newToken().'&section='.$section.'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Delete').'</a>';
} }
else else
{ {

View File

@ -376,7 +376,7 @@ print dol_get_fiche_head($head, 'index_auto', '', -1, '');
// Confirm remove file (for non javascript users) // Confirm remove file (for non javascript users)
if ($action == 'delete' && empty($conf->use_javascript_ajax)) { if ($action == 'deletefile' && empty($conf->use_javascript_ajax)) {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
} }
@ -413,7 +413,7 @@ if ($action == 'delete_section') {
// End confirm // End confirm
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') { if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'deletefile') {
print '<table width="100%" class="liste noborderbottom">'."\n"; print '<table width="100%" class="liste noborderbottom">'."\n";
print '<!-- Title for auto directories -->'."\n"; print '<!-- Title for auto directories -->'."\n";

View File

@ -239,7 +239,7 @@ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$param = '&amp;section='.$section; $param = '&section='.urlencode($section);
$textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection")); $textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
$formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty); $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty);

View File

@ -78,13 +78,14 @@ $(document).ready(function() {
$('#refreshbutton').click( function() { $('#refreshbutton').click( function() {
console.log("Click on refreshbutton"); console.log("Click on refreshbutton");
$.pleaseBePatient("<?php echo $langs->trans('PleaseBePatient'); ?>"); $.pleaseBePatient("<?php echo $langs->trans('PleaseBePatient'); ?>");
$.get( "<?php echo DOL_URL_ROOT.'/ecm/ajax/ecmdatabase.php'; ?>", { $.get("<?php echo DOL_URL_ROOT.'/ecm/ajax/ecmdatabase.php'; ?>", {
action: "build", action: 'build',
element: "ecm" token: '<?php echo newToken(); ?>',
element: 'ecm'
}, },
function(response) { function(response) {
$.unblockUI(); $.unblockUI();
location.href="<?php echo $_SERVER['PHP_SELF']; ?>"; location.href='<?php echo $_SERVER['PHP_SELF']; ?>';
}); });
}); });
}); });

View File

@ -1231,7 +1231,7 @@ if ($action == 'confirm_deletesite' && $confirm == 'yes' && $permissiontodelete)
} }
// Delete page (from website page menu) // Delete page (from website page menu)
if (GETPOSTISSET('pageid') && $action == 'delete' && $permissiontodelete) { if (GETPOSTISSET('pageid') && $action == 'delete' && $permissiontodelete && !GETPOST('file_manager')) {
$error = 0; $error = 0;
$db->begin(); $db->begin();