aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-24 10:01:01 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-24 10:05:37 -0400
commit36487246eddc87342d113de8f133f8fb910c70ad (patch)
treef073b1cc6089e8b24241995b351ebf77722d06b1 /apps
parentcfec290ad90f8bce01f37cd0ec1f957219770aad (diff)
downloadnextcloud-server-36487246eddc87342d113de8f133f8fb910c70ad.tar.gz
nextcloud-server-36487246eddc87342d113de8f133f8fb910c70ad.zip
Switch to using file cache ids instead of paths for file sharing
Diffstat (limited to 'apps')
-rw-r--r--apps/files/templates/part.list.php2
-rw-r--r--apps/files_sharing/js/share.js10
-rw-r--r--apps/files_sharing/lib/share/file.php26
-rw-r--r--apps/files_sharing/lib/share/folder.php4
4 files changed, 26 insertions, 16 deletions
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index 6667b5488af..8faeae3939c 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -9,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-permissions='<?php echo $file['permissions']; ?>'>
+ <tr data-id="<?php echo $file['id']; ?>" 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="">
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 12c1a3332c9..8754b16b061 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -43,20 +43,20 @@ $(document).ready(function() {
var itemType = 'file';
}
var possiblePermissions = $(tr).data('permissions');
- var appendTo = $('tr').filterAttr('data-file', filename).find('td.filename');
+ var appendTo = $(tr).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);
+ $(tr).addClass('mouseOver');
+ OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
});
} else {
OC.Share.hideDropDown();
}
} else {
- $('tr').filterAttr('data-file',filename).addClass('mouseOver');
- OC.Share.showDropDown(itemType, item, appendTo, true, possiblePermissions);
+ $(tr).addClass('mouseOver');
+ OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
}
});
}
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index ae6315600f8..5005d9a39d6 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -26,30 +26,40 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
const FORMAT_FILE_APP_ROOT = 2;
const FORMAT_OPENDIR = 3;
- public function isValidSource($item, $uid) {
- if (OC_Filesystem::file_exists($item)) {
+ private $path;
+
+ public function isValidSource($itemSource, $uidOwner) {
+ $path = OC_FileCache::getPath($itemSource, $uidOwner);
+ if (OC_Filesystem::file_exists($path)) {
+ $this->path = $path;
return true;
}
return false;
}
- public function getFilePath($item, $uid) {
- return $item;
+ public function getFilePath($itemSource, $uidOwner) {
+ if (isset($this->path)) {
+ $path = $this->path;
+ $this->path = null;
+ return $path;
+ }
+ return false;
}
- public function generateTarget($item, $uid, $exclude = null) {
+ public function generateTarget($itemSource, $shareWith, $exclude = null) {
// TODO Make sure target path doesn't exist already
- return $item;
+ return $itemSource;
}
public function formatItems($items, $format, $parameters = null) {
if ($format == self::FORMAT_SHARED_STORAGE) {
// Only 1 item should come through for this format call
- return array('path' => $items[key($items)]['file_source'], 'permissions' => $items[key($items)]['permissions']);
+ return array('path' => $items[key($items)]['path'], 'permissions' => $items[key($items)]['permissions']);
} else if ($format == self::FORMAT_FILE_APP) {
$files = array();
foreach ($items as $item) {
$file = array();
+ $file['id'] = $item['file_source'];
$file['path'] = $item['file_target'];
$file['name'] = basename($item['file_target']);
$file['ctime'] = $item['ctime'];
@@ -77,7 +87,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
}
$size += $item['size'];
}
- return array(0 => array('name' => 'Shared', 'mtime' => $mtime, 'mimetype' => 'httpd/unix-directory', 'size' => $size, 'writable' => false, 'type' => 'dir', 'directory' => '', 'permissions' => OCP\Share::PERMISSION_READ));
+ return array(0 => array('id' => -1, 'name' => 'Shared', 'mtime' => $mtime, 'mimetype' => 'httpd/unix-directory', 'size' => $size, 'writable' => false, 'type' => 'dir', 'directory' => '', 'permissions' => OCP\Share::PERMISSION_READ));
} else if ($format == self::FORMAT_OPENDIR) {
$files = array();
foreach ($items as $item) {
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php
index b6db96614fd..665583e83ad 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/share/folder.php
@@ -24,7 +24,7 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File {
public function formatItems($items, $format, $parameters = null) {
if ($format == self::FORMAT_SHARED_STORAGE) {
// Only 1 item should come through for this format call
- return array('path' => $items[key($items)]['file_source'], 'permissions' => $items[key($items)]['permissions']);
+ return array('path' => $items[key($items)]['path'], 'permissions' => $items[key($items)]['permissions']);
} else if ($format == self::FORMAT_FILE_APP && isset($parameters['folder'])) {
// Only 1 item should come through for this format call
$folder = $items[key($items)];
@@ -33,7 +33,7 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File {
} else {
$mimetype_filter = '';
}
- $path = $folder['file_source'].substr($parameters['folder'], 7 + strlen($folder['file_target']));
+ $path = $folder['path'].substr($parameters['folder'], 7 + strlen($folder['file_target']));
$files = OC_FileCache::getFolderContent($path, '', $mimetype_filter);
foreach ($files as &$file) {
$file['directory'] = $parameters['folder'];