fix delete and sort files
This commit is contained in:
parent
5bfff6c56e
commit
dea0d20a9a
|
@ -12,18 +12,15 @@ $files = isset($_POST["file"]) ? stripslashes($_POST["file"]) : stripslashes($_P
|
|||
|
||||
$files = explode(';', $files);
|
||||
$filesWithError = '';
|
||||
if (OC_User::isLoggedIn()) {
|
||||
$success = true;
|
||||
|
||||
//Now delete
|
||||
foreach ($files as $file) {
|
||||
if ($dir != '' || $file != 'Shared' && !\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
|
||||
$success = true;
|
||||
|
||||
//Now delete
|
||||
foreach ($files as $file) {
|
||||
if (($dir === '' && $file === 'Shared') || !\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
|
||||
$filesWithError .= $file . "\n";
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
return;
|
||||
|
||||
set_time_limit(0);//scanning can take ages
|
||||
|
||||
$force=isset($_GET['force']) and $_GET['force']=='true';
|
||||
|
|
|
@ -43,6 +43,16 @@ if(!\OC\Files\Filesystem::is_dir($dir.'/')) {
|
|||
exit();
|
||||
}
|
||||
|
||||
function fileCmp($a, $b) {
|
||||
if ($a['type'] == 'dir' and $b['type'] != 'dir') {
|
||||
return -1;
|
||||
} elseif ($a['type'] != 'dir' and $b['type'] == 'dir') {
|
||||
return 1;
|
||||
} else {
|
||||
return strnatcasecmp($a['name'], $b['name']);
|
||||
}
|
||||
}
|
||||
|
||||
$files = array();
|
||||
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
|
||||
$i['date'] = OCP\Util::formatDate($i['mtime'] );
|
||||
|
@ -62,6 +72,8 @@ foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
|
|||
$files[] = $i;
|
||||
}
|
||||
|
||||
usort($files, "fileCmp");
|
||||
|
||||
// Make breadcrumb
|
||||
$breadcrumb = array();
|
||||
$pathtohere = '';
|
||||
|
|
|
@ -187,7 +187,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
|||
$tmpl->assign('uidOwner', $uidOwner);
|
||||
$tmpl->assign('dir', basename($dir));
|
||||
$tmpl->assign('filename', basename($path));
|
||||
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
|
||||
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
|
||||
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
|
||||
if (isset($_GET['path'])) {
|
||||
$getPath = $_GET['path'];
|
||||
|
@ -200,7 +200,7 @@ if (isset($_GET['file']) || isset($_GET['dir'])) {
|
|||
$tmpl->assign('uidOwner', $uidOwner);
|
||||
$tmpl->assign('dir', dirname($path));
|
||||
$tmpl->assign('filename', basename($path));
|
||||
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
|
||||
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
|
||||
if ($type == 'file') {
|
||||
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.urlencode($_GET['file']).'&download', false);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue