From 885b8c481bed58a41b5f458decafa8bbfe1635c1 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 22 Aug 2012 12:31:54 -0400 Subject: [PATCH] Check if files_sharing app is enabled, move file specific javascript to files_sharing app --- apps/files_sharing/appinfo/app.php | 1 + apps/files_sharing/js/share.js | 64 ++++++++++++++++++++++++++++++ core/js/share.js | 61 ---------------------------- lib/files.php | 4 +- 4 files changed, 67 insertions(+), 63 deletions(-) create mode 100644 apps/files_sharing/js/share.js diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index fcebacc19d..109f86b2e8 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -6,3 +6,4 @@ OC::$CLASSPATH['OC_Filestorage_Shared'] = "apps/files_sharing/lib/sharedstorage. OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC_Filestorage_Shared', 'setup'); OCP\Share::registerBackend('file', 'OC_Share_Backend_File'); OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file'); +OCP\Util::addScript('files_sharing', 'share'); diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js new file mode 100644 index 0000000000..bcfd42ce21 --- /dev/null +++ b/apps/files_sharing/js/share.js @@ -0,0 +1,64 @@ +$(document).ready(function() { + + if (typeof FileActions !== 'undefined') { + OC.Share.loadIcons('file'); + FileActions.register('all', 'Share', FileActions.PERMISSION_SHARE, function(filename) { + // Return the correct sharing icon + if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback + if ($('#dir').val() == '/') { + var item = $('#dir').val() + filename; + } else { + var item = $('#dir').val() + '/' + filename; + } + // Check if status is in cache + if (OC.Share.statuses[item] === true) { + return OC.imagePath('core', 'actions/public'); + } else if (OC.Share.statuses[item] === false) { + return OC.imagePath('core', 'actions/shared'); + } else { + var last = ''; + var path = OC.Share.dirname(item); + // Search for possible parent folders that are shared + while (path != last) { + if (OC.Share.statuses[path] === true) { + return OC.imagePath('core', 'actions/public'); + } else if (OC.Share.statuses[path] === false) { + return OC.imagePath('core', 'actions/shared'); + } + last = path; + path = OC.Share.dirname(path); + } + return OC.imagePath('core', 'actions/share'); + } + }, function(filename) { + if ($('#dir').val() == '/') { + var item = $('#dir').val() + filename; + } else { + var item = $('#dir').val() + '/' + filename; + } + if ($('tr').filterAttr('data-file', filename).data('type') == 'dir') { + var itemType = 'folder'; + var possiblePermissions = OC.Share.PERMISSION_CREATE | OC.Share.PERMISSION_UPDATE | OC.Share.PERMISSION_DELETE | OC.Share.PERMISSION_SHARE; + } else { + var itemType = 'file'; + var possiblePermissions = OC.Share.PERMISSION_UPDATE | OC.Share.PERMISSION_DELETE | OC.Share.PERMISSION_SHARE; + } + var appendTo = $('tr').filterAttr('data-file', filename).find('td.filename'); + // Check if drop down is already visible for a different file + if (OC.Share.droppedDown) { + if (item != $('#dropdown').data('item')) { + OC.Share.hideDropDown(function () { + $('tr').filterAttr('data-file', filename).addClass('mouseOver'); + OC.Share.showDropDown(itemType, item, appendTo, true, possiblePermissions); + }); + } else { + OC.Share.hideDropDown(); + } + } else { + $('tr').filterAttr('data-file',filename).addClass('mouseOver'); + OC.Share.showDropDown(itemType, item, appendTo, true, possiblePermissions); + } + }); + } + +}); \ No newline at end of file diff --git a/core/js/share.js b/core/js/share.js index c1d66ee921..a552aa8083 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -275,67 +275,6 @@ $(document).ready(function() { } } }); - - if (typeof FileActions !== 'undefined') { - OC.Share.loadIcons('file'); - FileActions.register('all', 'Share', FileActions.PERMISSION_SHARE, function(filename) { - // Return the correct sharing icon - if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback - if ($('#dir').val() == '/') { - var item = $('#dir').val() + filename; - } else { - var item = $('#dir').val() + '/' + filename; - } - // Check if status is in cache - if (OC.Share.statuses[item] === true) { - return OC.imagePath('core', 'actions/public'); - } else if (OC.Share.statuses[item] === false) { - return OC.imagePath('core', 'actions/shared'); - } else { - var last = ''; - var path = OC.Share.dirname(item); - // Search for possible parent folders that are shared - while (path != last) { - if (OC.Share.statuses[path] === true) { - return OC.imagePath('core', 'actions/public'); - } else if (OC.Share.statuses[path] === false) { - return OC.imagePath('core', 'actions/shared'); - } - last = path; - path = OC.Share.dirname(path); - } - return OC.imagePath('core', 'actions/share'); - } - }, function(filename) { - if ($('#dir').val() == '/') { - var item = $('#dir').val() + filename; - } else { - var item = $('#dir').val() + '/' + filename; - } - if ($('tr').filterAttr('data-file', filename).data('type') == 'dir') { - var itemType = 'folder'; - var possiblePermissions = OC.Share.PERMISSION_CREATE | OC.Share.PERMISSION_UPDATE | OC.Share.PERMISSION_DELETE | OC.Share.PERMISSION_SHARE; - } else { - var itemType = 'file'; - var possiblePermissions = OC.Share.PERMISSION_UPDATE | OC.Share.PERMISSION_DELETE | OC.Share.PERMISSION_SHARE; - } - var appendTo = $('tr').filterAttr('data-file', filename).find('td.filename'); - // Check if drop down is already visible for a different file - if (OC.Share.droppedDown) { - if (item != $('#dropdown').data('item')) { - OC.Share.hideDropDown(function () { - $('tr').filterAttr('data-file', filename).addClass('mouseOver'); - OC.Share.showDropDown(itemType, item, appendTo, true, possiblePermissions); - }); - } else { - OC.Share.hideDropDown(); - } - } else { - $('tr').filterAttr('data-file',filename).addClass('mouseOver'); - OC.Share.showDropDown(itemType, item, appendTo, true, possiblePermissions); - } - }); - } $(this).click(function(event) { if (OC.Share.droppedDown && !($(event.target).hasClass('drop')) && $('#dropdown').has(event.target).length === 0) { diff --git a/lib/files.php b/lib/files.php index ce7cf2c446..1a1fffa0a5 100644 --- a/lib/files.php +++ b/lib/files.php @@ -38,7 +38,7 @@ class OC_Files { $directory=''; } $files = array(); - if (substr($directory, 0, 7) == '/Shared') { + if (($directory == '/Shared' || substr($directory, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) { if ($directory == '/Shared') { $files = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP, array('folder' => $directory, 'mimetype_filter' => $mimetype_filter)); } else { @@ -65,7 +65,7 @@ class OC_Files { } $file['permissions'] = $permissions; } - if ($directory == '') { + if ($directory == '' && OC_App::isEnabled('files_sharing')) { // Add 'Shared' folder $files = array_merge($files, OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT)); }