Fix data for shared root folder

This commit is contained in:
Michael Gapczynski 2012-12-29 11:45:13 -05:00
parent fb053f8e73
commit cfc3526b25
4 changed files with 26 additions and 9 deletions

View File

@ -62,7 +62,9 @@ class Shared_Cache extends Cache {
* @return array
*/
public function get($file) {
if (is_string($file)) {
if ($file == '') {
return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
} else if (is_string($file)) {
if ($cache = $this->getSourceCache($file)) {
return $cache->get($this->files[$file]);
}

View File

@ -30,6 +30,9 @@ class Shared_Permissions {
* @return int (-1 if file no permissions set)
*/
static public function get($fileId, $user) {
if ($fileId == -1) {
return \OCP\PERMISSION_READ;
}
$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
if ($source) {
return $source['permissions'];

View File

@ -23,8 +23,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
const FORMAT_SHARED_STORAGE = 0;
const FORMAT_GET_FOLDER_CONTENTS = 1;
const FORMAT_GET_ALL = 2;
const FORMAT_FILE_APP_ROOT = 2;
const FORMAT_OPENDIR = 3;
const FORMAT_GET_ALL = 4;
private $path;
@ -82,24 +83,35 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
$file['parent'] = $item['file_parent'];
$file['name'] = basename($item['file_target']);
$file['mimetype'] = $item['mimetype'];
$file['mimepart'] = $item['mimepart'];
$file['size'] = $item['size'];
$file['mtime'] = $item['mtime'];
$file['encrypted'] = $item['encrypted'];
$files[] = $file;
}
return $files;
} else if ($format == self::FORMAT_FILE_APP_ROOT) {
$mtime = 0;
$size = 0;
foreach ($items as $item) {
if ($item['mtime'] > $mtime) {
$mtime = $item['mtime'];
}
$size += (int)$item['size'];
}
return array('fileid' => -1, 'name' => 'Shared', 'mtime' => $mtime, 'mimetype' => 'httpd/unix-directory', 'size' => $size);
} else if ($format == self::FORMAT_OPENDIR) {
$files = array();
foreach ($items as $item) {
$files[] = basename($item['file_target']);
}
return $files;
} else if ($format == self::FORMAT_GET_ALL) {
$ids = array();
foreach ($items as $item) {
$ids[] = $item['file_source'];
}
return $ids;
} else if ($format == self::FORMAT_OPENDIR) {
$files = array();
foreach ($items as $item) {
$files[] = basename($item['file_target']);
}
return $files;
}
return array();
}

View File

@ -681,7 +681,7 @@ class Share {
}
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `*PREFIX*filecache`.`parent` as `file_parent`, `name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`';