summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-08-29 23:45:02 +0200
committerVincent Petry <pvince81@owncloud.com>2013-09-13 19:59:15 +0200
commit364e7991a42c92affb9085082ff79f6b653de6dd (patch)
treeb35f0e1c85a7e992f43a4710eb702ac046f322b2 /apps/files
parent4549cf519e838a2dd2828453c4157231bccd3287 (diff)
downloadnextcloud-server-364e7991a42c92affb9085082ff79f6b653de6dd.tar.gz
nextcloud-server-364e7991a42c92affb9085082ff79f6b653de6dd.zip
Fixed ajax support to also update the current dir permissions
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/list.php4
-rw-r--r--apps/files/index.php14
-rw-r--r--apps/files/js/filelist.js16
-rw-r--r--apps/files/lib/helper.php22
-rw-r--r--apps/files/templates/index.php10
5 files changed, 45 insertions, 21 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 035ffc0e393..f1b713b5534 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -20,6 +20,8 @@ $doBreadcrumb = isset($_GET['breadcrumb']);
$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
+$permissions = \OCA\files\lib\Helper::getDirPermissions($dir);
+
// Make breadcrumb
if($doBreadcrumb) {
$breadcrumb = \OCA\files\lib\Helper::makeBreadcrumb($dir);
@@ -38,6 +40,8 @@ $list = new OCP\Template("files", "part.list", "");
$list->assign('files', $files, false);
$list->assign('baseURL', $baseUrl, false);
$list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
+$list->assign('isPublic', false);
$data['files'] = $list->fetchPage();
+$data['permissions'] = $permissions;
OCP\JSON::success(array('data' => $data));
diff --git a/apps/files/index.php b/apps/files/index.php
index ec824f895b6..4b930f89024 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -65,19 +65,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?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;
-}
+$permissions = \OCA\files\lib\Helper::getDirPermissions($dir);
if ($needUpgrade) {
OCP\Util::addscript('files', 'upgrade');
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 638864d9eca..07605a7d891 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -7,9 +7,11 @@ var FileList={
});
},
update:function(fileListHtml) {
- var $fileList = $('#fileList');
+ var $fileList = $('#fileList'),
+ permissions = $('#permissions').val(),
+ isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0;
$fileList.empty().html(fileListHtml);
- $('#emptycontent').toggleClass('hidden', $fileList.find('tr').length > 0);
+ $('#emptycontent').toggleClass('hidden', !isCreatable || $fileList.find('tr').length > 0);
$fileList.find('tr').each(function () {
FileActions.display($(this).children('td.filename'));
});
@@ -216,6 +218,10 @@ var FileList={
return;
}
+ if (result.data.permissions){
+ FileList.setDirectoryPermissions(result.data.permissions);
+ }
+
if(typeof(result.data.breadcrumb) != 'undefined'){
$controls.find('.crumb').remove();
$controls.prepend(result.data.breadcrumb);
@@ -232,6 +238,12 @@ var FileList={
FileList.update(result.data.files);
},
+ setDirectoryPermissions: function(permissions){
+ var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0;
+ $('#permissions').val(permissions);
+ $('.creatable').toggleClass('hidden', !isCreatable);
+ $('.notCreatable').toggleClass('hidden', isCreatable);
+ },
remove:function(name){
$('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy');
$('tr').filterAttr('data-file',name).remove();
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index 282f0678a9a..3c13b8ea6e2 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -111,4 +111,26 @@ 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;
+ }
}
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 9ca115f7711..0105f4370e5 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -1,8 +1,7 @@
<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}table td{position:static !important;}</style><![endif]-->
<div id="controls">
<?php print_unescaped($_['breadcrumb']); ?>
- <?php if ($_['isCreatable']):?>
- <div class="actions <?php if (isset($_['files']) and count($_['files'])==0):?>emptycontent<?php endif; ?>">
+ <div class="actions creatable <?php if (!$_['isCreatable']):?>hidden<?php endif; ?> <?php if (isset($_['files']) and count($_['files'])==0):?>emptycontent<?php endif; ?>">
<div id="new" class="button">
<a><?php p($l->t('New'));?></a>
<ul>
@@ -50,10 +49,9 @@
</div>
</div>
<div id="file_action_panel"></div>
- <?php elseif( !$_['isPublic'] ):?>
- <div class="actions"><input type="button" disabled value="<?php p($l->t('You don’t have write permissions here.'))?>"></div>
- <input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir">
- <?php endif;?>
+ <div class="notCreatable notPublic <?php if ($_['isCreatable'] or $_['isPublic'] ):?>hidden<?php endif; ?>">
+ <div class="actions"><input type="button" disabled value="<?php p($l->t('You don’t have write permissions here.'))?>"></div>
+ </div>
<input type="hidden" name="permissions" value="<?php p($_['permissions']); ?>" id="permissions">
</div>