diff options
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/index.php | 2 | ||||
-rw-r--r-- | apps/files/js/fileactions.js | 54 | ||||
-rw-r--r-- | apps/files/js/files.js | 35 | ||||
-rwxr-xr-x | apps/files/share.php | 38 | ||||
-rw-r--r-- | apps/files/templates/index.php | 10 | ||||
-rw-r--r-- | apps/files/templates/part.list.php | 3 |
6 files changed, 100 insertions, 42 deletions
diff --git a/apps/files/index.php b/apps/files/index.php index 79bed8e357e..225e2d7ac13 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -93,7 +93,7 @@ $tmpl = new OCP\Template( 'files', 'index', 'user' ); $tmpl->assign( 'fileList', $list->fetchPage(), false ); $tmpl->assign( 'breadcrumb', $breadcrumbNav->fetchPage(), false ); $tmpl->assign( 'dir', $dir); -$tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir.'/')); +$tmpl->assign( 'isCreatable', OC_Filesystem::isCreatable($dir.'/')); $tmpl->assign( 'files', $files ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 4dc05088eed..d54dd466469 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -1,19 +1,28 @@ FileActions={ + PERMISSION_CREATE:4, + PERMISSION_READ:1, + PERMISSION_UPDATE:2, + PERMISSION_DELETE:8, + PERMISSION_SHARE:16, actions:{}, defaults:{}, icons:{}, currentFile:null, - register:function(mime,name,icon,action){ + register:function(mime,name,permissions,icon,action){ if(!FileActions.actions[mime]){ FileActions.actions[mime]={}; } - FileActions.actions[mime][name]=action; + if (!FileActions.actions[mime][name]) { + FileActions.actions[mime][name] = {}; + } + FileActions.actions[mime][name]['action'] = action; + FileActions.actions[mime][name]['permissions'] = permissions; FileActions.icons[name]=icon; }, setDefault:function(mime,name){ FileActions.defaults[mime]=name; }, - get:function(mime,type){ + get:function(mime,type,permissions){ var actions={}; if(FileActions.actions.all){ actions=$.extend( actions, FileActions.actions.all ) @@ -32,9 +41,15 @@ FileActions={ actions=$.extend( actions, FileActions.actions[type] ) } } - return actions; + var filteredActions = {}; + $.each(actions, function(name, action) { + if (action.permissions & permissions) { + filteredActions[name] = action.action; + } + }); + return filteredActions; }, - getDefault:function(mime,type){ + getDefault:function(mime,type,permissions){ if(mime){ var mimePart=mime.substr(0,mime.indexOf('/')); } @@ -48,22 +63,20 @@ FileActions={ }else{ name=FileActions.defaults.all; } - var actions=this.get(mime,type); + var actions=this.get(mime,type,permissions); return actions[name]; }, - display:function(parent, filename, type){ + display:function(parent){ FileActions.currentFile=parent; $('#fileList span.fileactions, #fileList td.date a.action').remove(); - var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType()); + var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType(), FileActions.getCurrentPermissions()); var file=FileActions.getCurrentFile(); if($('tr').filterAttr('data-file',file).data('renaming')){ return; } parent.children('a.name').append('<span class="fileactions" />'); - var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType()); + var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType(), FileActions.getCurrentPermissions()); for(name in actions){ - // no rename and share action for the 'Shared' dir - if((name=='Rename' || name =='Share') && type=='dir' && filename=='Shared') { continue; } if((name=='Download' || actions[name]!=defaultAction) && name!='Delete'){ var img=FileActions.icons[name]; if(img.call){ @@ -86,16 +99,12 @@ FileActions={ parent.find('a.name>span.fileactions').append(element); } } - if(actions['Delete'] && (type!='dir' || filename != 'Shared')){ // no delete action for the 'Shared' dir + if(actions['Delete']){ var img=FileActions.icons['Delete']; if(img.call){ img=img(file); } - if ($('#dir').val().indexOf('Shared') != -1) { - var html='<a href="#" original-title="' + t('files', 'Unshare') + '" class="action delete" style="display:none" />'; - } else { - var html='<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />'; - } + var html='<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />'; var element=$(html); if(img){ element.append($('<img src="'+img+'"/>')); @@ -131,6 +140,9 @@ FileActions={ }, getCurrentType:function(){ return FileActions.currentFile.parent().attr('data-type'); + }, + getCurrentPermissions:function() { + return FileActions.currentFile.parent().data('permissions'); } } @@ -140,12 +152,12 @@ $(document).ready(function(){ } else { var downloadScope = 'file'; } - FileActions.register(downloadScope,'Download',function(){return OC.imagePath('core','actions/download')},function(filename){ + FileActions.register(downloadScope,'Download', FileActions.PERMISSION_READ, function(){return OC.imagePath('core','actions/download')},function(filename){ window.location=OC.filePath('files', 'ajax', 'download.php') + encodeURIComponent('?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val())); }); }); -FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){ +FileActions.register('all','Delete', FileActions.PERMISSION_DELETE, function(){return OC.imagePath('core','actions/delete')},function(filename){ if(Files.cancelUpload(filename)) { if(filename.substr){ filename=[filename]; @@ -162,11 +174,11 @@ FileActions.register('all','Delete',function(){return OC.imagePath('core','actio } }); -FileActions.register('all','Rename',function(){return OC.imagePath('core','actions/rename')},function(filename){ +FileActions.register('all','Rename', FileActions.PERMISSION_UPDATE, function(){return OC.imagePath('core','actions/rename')},function(filename){ FileList.rename(filename); }); -FileActions.register('dir','Open','',function(filename){ +FileActions.register('dir','Open', FileActions.PERMISSION_READ, '', function(filename){ window.location=OC.linkTo('files', 'index.php') + '&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a4e2361feeb..daa250c9bd4 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -56,7 +56,7 @@ $(document).ready(function() { // Sets the file-action buttons behaviour : $('tr').live('mouseenter',function(event) { - FileActions.display($(this).children('td.filename'), $(this).attr('data-file'), $(this).attr('data-type')); + FileActions.display($(this).children('td.filename')); }); $('tr').live('mouseleave',function(event) { FileActions.hide(); @@ -106,7 +106,8 @@ $(document).ready(function() { if(!renaming && !FileList.isLoading(filename)){ var mime=$(this).parent().parent().data('mime'); var type=$(this).parent().parent().data('type'); - var action=FileActions.getDefault(mime,type); + var permissions = $(this).parent().parent().data('permissions'); + var action=FileActions.getDefault(mime,type, permissions); if(action){ action(filename); } @@ -462,14 +463,18 @@ $(document).ready(function() { $.post( OC.filePath('files','ajax','newfile.php'), {dir:$('#dir').val(),filename:name,content:" \n"}, - function(data){ - var date=new Date(); - FileList.addFile(name,0,date); - var tr=$('tr').filterAttr('data-file',name); - tr.data('mime','text/plain'); - getMimeIcon('text/plain',function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); - }); + function(result){ + if (result.status == 'success') { + var date=new Date(); + FileList.addFile(name,0,date); + var tr=$('tr').filterAttr('data-file',name); + tr.data('mime','text/plain'); + getMimeIcon('text/plain',function(path){ + tr.find('td.filename').attr('style','background-image:url('+path+')'); + }); + } else { + OC.dialogs.alert(result.data.message, 'Error'); + } } ); break; @@ -477,9 +482,13 @@ $(document).ready(function() { $.post( OC.filePath('files','ajax','newfolder.php'), {dir:$('#dir').val(),foldername:name}, - function(data){ - var date=new Date(); - FileList.addDir(name,0,date); + function(result){ + if (result.status == 'success') { + var date=new Date(); + FileList.addDir(name,0,date); + } else { + OC.dialogs.alert(result.data.message, 'Error'); + } } ); break; diff --git a/apps/files/share.php b/apps/files/share.php new file mode 100755 index 00000000000..4f7c1f55fcf --- /dev/null +++ b/apps/files/share.php @@ -0,0 +1,38 @@ +<?php + +/** +* ownCloud +* +* @author Michael Gapczynski +* @copyright 2012 Michael Gapczynski mtgap@owncloud.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + +class OC_Share_Backend_Files extends OCP\Share_Backend { + + public function getSource($item, $uid) { + return $item; + } +} + +class OC_Share_Backend_Folders extends OC_Share_Backend_Files { + + public function share($ + public function getDirectoryContent($folder) { + + } +} + +?>
\ No newline at end of file diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 44000171a17..bcf683ae4a8 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -1,8 +1,8 @@ <!--[if IE 8]><style>input[type="checkbox"]{padding:0;}table td{position:static !important;}</style><![endif]--> <div id="controls"> <?php echo($_['breadcrumb']); ?> - <?php if (!isset($_['readonly']) || !$_['readonly']):?> - <div class="actions <?php if (isset($_['files']) and ! $_['readonly'] and count($_['files'])==0):?>emptyfolder<?php endif; ?>"> + <?php if ($_['isCreatable']):?> + <div class="actions <?php if (isset($_['files']) and count($_['files'])==0):?>emptyfolder<?php endif; ?>"> <div id='new' class='button'> <a><?php echo $l->t('New');?></a> <ul class="popup popupTop"> @@ -35,7 +35,7 @@ </div> <div id='notification'></div> -<?php if (isset($_['files']) and ! $_['readonly'] and count($_['files'])==0):?> +<?php if (isset($_['files']) and $_['isCreatable'] and count($_['files'])==0):?> <div id="emptyfolder"><?php echo $l->t('Nothing in here. Upload something!')?></div> <?php endif; ?> @@ -43,7 +43,7 @@ <thead> <tr> <th id='headerName'> - <?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" id="select_all" /><?php } ?> + <input type="checkbox" id="select_all" /> <span class='name'><?php echo $l->t( 'Name' ); ?></span> <span class='selectedActions'> <!-- <a href="" class="share"><img class='svg' alt="Share" src="<?php echo OCP\image_path("core", "actions/share.svg"); ?>" /> <?php echo $l->t('Share')?></a> --> @@ -56,7 +56,7 @@ <th id="headerDate"><span id="modified"><?php echo $l->t( 'Modified' ); ?></span><span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span></th> </tr> </thead> - <tbody id="fileList" data-readonly="<?php echo $_['readonly'];?>"> + <tbody id="fileList"> <?php echo($_['fileList']); ?> </tbody> </table> diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 4506630c16d..6667b5488af 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,5 +1,4 @@ <?php foreach($_['files'] as $file): - $write = ($file['writable']) ? 'true' : 'false'; $simple_file_size = OCP\simple_file_size($file['size']); $simple_size_color = intval(200-$file['size']/(1024*1024)*2); // the bigger the file, the darker the shade of grey; megabytes*2 if($simple_size_color<0) $simple_size_color = 0; @@ -10,7 +9,7 @@ $name = str_replace('%2F','/', $name); $directory = str_replace('+','%20',urlencode($file['directory'])); $directory = str_replace('%2F','/', $directory); ?> - <tr data-file="<?php echo $name;?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mimetype']?>" data-size='<?php echo $file['size'];?>' data-write='<?php echo $write;?>'> + <tr data-file="<?php echo $name;?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mimetype']?>" data-size='<?php echo $file['size'];?>' data-permissions='<?php echo $file['permissions']; ?>'> <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo OCP\mimetype_icon('dir'); else echo OCP\mimetype_icon($file['mimetype']); ?>)"> <?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" /><?php } ?> <a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$directory.'/'.$name; else echo $_['downloadURL'].$directory.'/'.$name; ?>" title=""> |