summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-02-18 15:39:35 +0100
committerRobin Appelman <icewind@owncloud.com>2014-02-18 15:39:35 +0100
commitd18b9f6ea43b2a9b7bf9d2a71710edc67ec7f705 (patch)
treeb67af1d1b3eea4cae9990359a8a2710c8365c5ba /apps
parent92560c5b86cb88920b6e439bdf4b90f1d59e9b6c (diff)
downloadnextcloud-server-d18b9f6ea43b2a9b7bf9d2a71710edc67ec7f705.tar.gz
nextcloud-server-d18b9f6ea43b2a9b7bf9d2a71710edc67ec7f705.zip
use a FileInfo object of the directory when generting the filelist
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/list.php5
-rw-r--r--apps/files/index.php5
-rw-r--r--apps/files/lib/helper.php22
3 files changed, 6 insertions, 26 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 0be38c3b96f..c8286bc15ca 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -11,7 +11,8 @@ OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
-if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
+$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
+if (!$dirInfo->getType() === 'dir') {
header("HTTP/1.0 404 Not Found");
exit();
}
@@ -20,7 +21,7 @@ $doBreadcrumb = isset($_GET['breadcrumb']);
$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
-$permissions = \OCA\Files\Helper::getDirPermissions($dir);
+$permissions = $dirInfo->getPermissions();
// Make breadcrumb
if($doBreadcrumb) {
diff --git a/apps/files/index.php b/apps/files/index.php
index dd63f29bc28..f8f1618e787 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -37,8 +37,9 @@ OCP\App::setActiveNavigationEntry('files_index');
// Load the files
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
+$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
// Redirect if directory does not exist
-if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
+if (!$dirInfo->getType() === 'dir') {
header('Location: ' . OCP\Util::getScriptName() . '');
exit();
}
@@ -92,7 +93,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=');
-$permissions = \OCA\Files\Helper::getDirPermissions($dir);
+$permissions = $dirInfo->getPermissions();
if ($needUpgrade) {
OCP\Util::addscript('files', 'upgrade');
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index 01fc65d76b7..ac8a2ad3200 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -112,26 +112,4 @@ class Helper
}
return $breadcrumb;
}
-
- /**
- * Returns the numeric permissions for the given directory.
- * @param string $dir directory without trailing slash
- * @return numeric permissions
- */
- public static function getDirPermissions($dir){
- $permissions = \OCP\PERMISSION_READ;
- if (\OC\Files\Filesystem::isCreatable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_CREATE;
- }
- if (\OC\Files\Filesystem::isUpdatable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_UPDATE;
- }
- if (\OC\Files\Filesystem::isDeletable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_DELETE;
- }
- if (\OC\Files\Filesystem::isSharable($dir . '/')) {
- $permissions |= \OCP\PERMISSION_SHARE;
- }
- return $permissions;
- }
}