diff --git a/ChangeLog b/ChangeLog index c05e9a929d1..db0f8ab8240 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ For users: to define default language for document generation. - New: Can reopen a closed supplier invoice. - New: Move permission "see hidden categories" into "see hidden products/services". +- New: Can delete several files at once in FTP module. - Fix: Format number was wrong for ar_AR language. - Fix: Can change password if has only permission change password. - Fix: Project PDF document show the tasks. diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 29af4fdc935..d19cd5b48b9 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -194,6 +194,57 @@ if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes' } } +// Delete several lines at once +if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("Delete")) +{ + // set up a connection or die + if (! $conn_id) + { + $newsectioniso=utf8_decode($section); + $resultarray=dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso); + $conn_id=$resultarray['conn_id']; + $ok=$resultarray['ok']; + $mesg=$resultarray['mesg']; + } + + if ($conn_id && $ok && ! $mesg) + { + foreach($_POST["const"] as $const) + { + if ($const["check"]) // Is checkbox checked + { + // Remote file + $file=$const["file"]; + $section=$const["section"]; + $remotefile=$section.(preg_match('@[\\\/]$@',$section)?'':'/').$file; + $newremotefileiso=utf8_decode($remotefile); + + //print "x".$newremotefileiso; + dol_syslog("ftp/index.php ftp_delete ".$newremotefileiso); + $result=@ftp_delete($conn_id, $newremotefileiso); + if ($result) + { + $mesg .= '
'.$langs->trans("FileWasRemoved",$file).'
'; + } + else + { + dol_syslog("ftp/index.php ftp_delete", LOG_ERR); + $mesg .= '
'.$langs->trans("FTPFailedToRemoveFile",$file).'
'; + } + + //ftp_close($conn_id); Close later + + $action=''; + } + } + + } + else + { + dol_print_error('',$mesg); + } +} + // Remove directory if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'yes') { @@ -234,7 +285,7 @@ if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'y } } -// Remove directory +// Download directory if ($_REQUEST['action'] == 'download') { // set up a connection or die @@ -351,11 +402,39 @@ else print $langs->trans("Port").': '.$ftp_port.'
'; print $langs->trans("User").': '.$ftp_user.'
'; - print $langs->trans("Directory").': '.$section.'
'; + print $langs->trans("Directory").': '; + $sectionarray=preg_split('|[\/]|',$section); + // For / + $newsection='/'; + print ''; + print '/'; + print ' '; + // For other directories + $i=0; + foreach($sectionarray as $val) + { + if (empty($val)) continue; // Discard first and last entry that should be empty as section start/end with / + if ($i > 0) + { + print ' / '; + $newsection.='/'; + } + $newsection.=$val; + print ''; + print $val; + print ''; + $i++; + } + print '
'; print "
\n"; if ($mesg) { print $mesg."
"; } + + print '
'; + print ''; + + // Construit liste des repertoires print ''."\n"; @@ -484,6 +563,13 @@ else print ''.img_file().''; print '   '; print ''.img_delete().''; + print ''; + print ''; + if ($conf->use_javascript_ajax) + { + print '   '; + print '   '; + } } print ''; print ''."\n"; @@ -496,6 +582,7 @@ else print "
"; + if (! $ok && $mesg) print $mesg; // Actions @@ -506,6 +593,19 @@ else } else print ' '; */ + + if ($conf->use_javascript_ajax) + { + print '
'; + print ''; + print ''; + } + + print "
"; } else {