Browse Source

The 'action=delete&file=...' has been replaced with
'action=deletefile&file=...' to avoid confusion with deletion of object
lines.

Laurent Destailleur 3 years ago
parent
commit
874731af84

+ 1 - 1
ChangeLog

@@ -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.
 * 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 '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 *****

+ 1 - 1
htdocs/admin/security_file.php

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

+ 1 - 1
htdocs/admin/tools/dolibarr_export.php

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

+ 1 - 1
htdocs/comm/action/rapport/index.php

@@ -163,7 +163,7 @@ if ($resql) {
 
 			// Button to build doc
 			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>';
 
 			$name = "actions-".$obj->month."-".$obj->year.".pdf";

+ 2 - 2
htdocs/core/ajax/ajaxdirpreview.php

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

+ 6 - 6
htdocs/core/class/html.formfile.class.php

@@ -1338,11 +1338,11 @@ class FormFile
 					print '<tr class="oddeven" id="row-'.($filearray[$key]['rowid'] > 0 ? $filearray[$key]['rowid'] : 'AFTER'.$lastrowid.'POS'.($i + 1)).'">';
 
 					// File name
-					print '<td class="minwith200">';
+					print '<td class="minwith200 tdoverflowmax500">';
 
 					// Show file name with link to download
 					//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) {
 						print '&attachment=1';
 					}
@@ -1351,7 +1351,7 @@ class FormFile
 					}
 					print '&file='.urlencode($filepath);
 					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) {
 						print $relativepath;
 					}
@@ -1503,7 +1503,7 @@ class FormFile
 							if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
 								$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>";
 
@@ -1511,10 +1511,10 @@ class FormFile
 							if ($nboffiles > 1 && $conf->browser->layout != 'phone') {
 								print '<td class="linecolmove tdlineupdown center">';
 								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) {
-									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>';
 							} else {

+ 2 - 2
htdocs/core/tpl/document_actions_post_headers.tpl.php

@@ -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
 	print $form->formconfirm(
 		$_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")).'&linkid='.GETPOST('linkid', 'int').(empty($param) ? '' : $param),

+ 7 - 5
htdocs/ecm/ajax/ecmdatabase.php

@@ -17,7 +17,7 @@
 
 /**
  *       \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')) {
@@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 $action = GETPOST('action', 'aZ09');
 $element = GETPOST('element', 'alpha');
 
+
 /*
  * View
  */
@@ -86,7 +87,7 @@ if (isset($action) && !empty($action)) {
 			}
 
 			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);
 
 				// 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
 			$dirtotest = $conf->$element->dir_output.'/'.$dirdesc['fullrelativename'];
 			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->delete($user, 'databaseonly');
 				//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("sql = ".$sql);
+		dol_syslog("Nb of directories added into database = ".$adirwascreated);
+
+		$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);
 	}
 }

+ 4 - 4
htdocs/ecm/dir_card.php

@@ -450,7 +450,7 @@ print dol_get_fiche_end();
 
 
 // Actions buttons
-if ($action != 'edit' && $action != 'delete') {
+if ($action != 'edit' && $action != 'delete' && $action != 'deletefile') {
 	print '<div class="tabsAction">';
 
 	if ($permtoadd) {
@@ -482,8 +482,8 @@ if ($action != 'edit' && $action != 'delete') {
 }
 
 // Confirm remove file
-if ($action == 'delete') {
-	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');
+if ($action == '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
@@ -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);
 }
 
 

+ 3 - 3
htdocs/ecm/file_card.php

@@ -411,8 +411,8 @@ if ($action == 'edit') {
 }
 
 
-// Confirmation de la suppression d'une ligne categorie
-if ($action == 'delete_file') {
+// Confirm deletion of a file
+if ($action == 'deletefile') {
 	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)
 	{
-		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
 	{

+ 2 - 2
htdocs/ecm/index_auto.php

@@ -376,7 +376,7 @@ print dol_get_fiche_head($head, 'index_auto', '', -1, '');
 
 
 // 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);
 }
 
@@ -413,7 +413,7 @@ if ($action == 'delete_section') {
 // 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 '<!-- Title for auto directories -->'."\n";

+ 1 - 1
htdocs/ecm/search.php

@@ -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);
 
 $formfile = new FormFile($db);
-$param = '&amp;section='.$section;
+$param = '&section='.urlencode($section);
 $textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
 $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty);
 

+ 5 - 4
htdocs/ecm/tpl/enablefiletreeajax.tpl.php

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

+ 1 - 1
htdocs/website/index.php

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