From a5211e31bc170f44edce3c80df831e7705e93396 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 5 Sep 2012 21:46:59 -0400 Subject: [PATCH] Add permissions to new files/folders, bug fix for oc-1649 --- apps/files/index.php | 12 ++++++++++++ apps/files/js/filelist.js | 4 ++-- apps/files/templates/index.php | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/files/index.php b/apps/files/index.php index 6d53527025a..ba785f7d6bc 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -89,11 +89,23 @@ $freeSpace=OC_Filesystem::free_space('/'); $freeSpace=max($freeSpace,0); $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); +$permissions = OCP\Share::PERMISSION_READ; +if (OC_Filesystem::isUpdatable($dir.'/')) { + $permissions |= OCP\Share::PERMISSION_UPDATE; +} +if (OC_Filesystem::isDeletable($dir.'/')) { + $permissions |= OCP\Share::PERMISSION_DELETE; +} +if (OC_Filesystem::isSharable($dir.'/')) { + $permissions |= OCP\Share::PERMISSION_SHARE; +} + $tmpl = new OCP\Template( 'files', 'index', 'user' ); $tmpl->assign( 'fileList', $list->fetchPage(), false ); $tmpl->assign( 'breadcrumb', $breadcrumbNav->fetchPage(), false ); $tmpl->assign( 'dir', OC_Filesystem::normalizePath($dir)); $tmpl->assign( 'isCreatable', OC_Filesystem::isCreatable($dir.'/')); +$tmpl->assign('permissions', $permissions); $tmpl->assign( 'files', $files ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index ce215cb8431..a9e48f24052 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -5,7 +5,7 @@ var FileList={ }, addFile:function(name,size,lastModified,loading,hidden){ var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png'); - var html=''; + var html=''; if(name.indexOf('.')!=-1){ var basename=name.substr(0,name.lastIndexOf('.')); var extension=name.substr(name.lastIndexOf('.')); @@ -41,7 +41,7 @@ var FileList={ } }, addDir:function(name,size,lastModified,hidden){ - html = $('').attr({ "data-type": "dir", "data-size": size, "data-file": name}); + html = $('').attr({ "data-type": "dir", "data-size": size, "data-file": name, "data-permissions": $('#permissions').val()}); td = $('').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' }); td.append(''); var link_elem = $('').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index bcf683ae4a8..a874529330b 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -32,6 +32,7 @@ +
-- 2.39.5