Add support for sharing folders
This commit is contained in:
parent
467778d66f
commit
e91f42d249
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
OC_APP::addSettingsPage( array(
|
OC_APP::addSettingsPage( array( "id" => "files_sharing_administration",
|
||||||
"id" => "files_sharing_administration",
|
|
||||||
"order" => 10,
|
"order" => 10,
|
||||||
"href" => OC_HELPER::linkTo( "files_sharing", "admin.php" ),
|
"href" => OC_HELPER::linkTo( "files_sharing", "admin.php" ),
|
||||||
"name" => "Share",
|
"name" => "Share",
|
||||||
|
|
|
@ -81,9 +81,16 @@ class OC_SHARE {
|
||||||
* @return source path
|
* @return source path
|
||||||
*/
|
*/
|
||||||
public static function getSource($target) {
|
public static function getSource($target) {
|
||||||
|
// Break up the $target to get only the first part in case it is inside a folder
|
||||||
|
$parts = explode("/", $target);
|
||||||
$query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?");
|
$query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?");
|
||||||
$result = $query->execute(array($target, $_SESSION['user_id']))->fetchAll();
|
$result = $query->execute(array($parts[0], $_SESSION['user_id']))->fetchAll();
|
||||||
return $result[0]['source'];
|
$source = $result[0]['source'];
|
||||||
|
// Add the $parts back in
|
||||||
|
foreach (array_slice($parts, 1) as $part) {
|
||||||
|
$source .= $part;
|
||||||
|
}
|
||||||
|
return $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,8 +58,8 @@ class OC_FILESTORAGE_SHARED {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add all files from db in array
|
|
||||||
public function opendir($path) {
|
public function opendir($path) {
|
||||||
|
if ($path == "" || $path == "/") {
|
||||||
global $FAKEDIRS;
|
global $FAKEDIRS;
|
||||||
$sharedItems = OC_SHARE::getItemsSharedWith();
|
$sharedItems = OC_SHARE::getItemsSharedWith();
|
||||||
foreach ($sharedItems as $item) {
|
foreach ($sharedItems as $item) {
|
||||||
|
@ -67,6 +67,13 @@ class OC_FILESTORAGE_SHARED {
|
||||||
}
|
}
|
||||||
$FAKEDIRS['shared'] = $files;
|
$FAKEDIRS['shared'] = $files;
|
||||||
return opendir('fakedir://shared');
|
return opendir('fakedir://shared');
|
||||||
|
} else {
|
||||||
|
$source = OC_SHARE::getSource($path);
|
||||||
|
if ($source) {
|
||||||
|
$storage = OC_FILESYSTEM::getStorage($source);
|
||||||
|
return $storage->opendir($this->getInternalPath($source));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function is_dir($path) {
|
public function is_dir($path) {
|
||||||
|
@ -144,7 +151,7 @@ class OC_FILESTORAGE_SHARED {
|
||||||
if ($path == "" || $path == "/") {
|
if ($path == "" || $path == "/") {
|
||||||
$dbpath = $_SESSION['user_id']."/files/Share/";
|
$dbpath = $_SESSION['user_id']."/files/Share/";
|
||||||
} else {
|
} else {
|
||||||
$dbpath = $path;
|
$dbpath = substr(OC_SHARE::getSource($path), 1);
|
||||||
}
|
}
|
||||||
$query = OC_DB::prepare("SELECT size FROM *PREFIX*foldersize WHERE path=?");
|
$query = OC_DB::prepare("SELECT size FROM *PREFIX*foldersize WHERE path=?");
|
||||||
$size = $query->execute(array($dbpath))->fetchAll();
|
$size = $query->execute(array($dbpath))->fetchAll();
|
||||||
|
|
Loading…
Reference in New Issue