Add support for renaming, moving, and deleting shared files

This commit is contained in:
Michael Gapczynski 2011-07-06 15:17:03 -04:00
parent cf33995892
commit 732ad7f6c1
2 changed files with 23 additions and 15 deletions

View file

@ -91,13 +91,22 @@ class OC_SHARE {
* Unshare the item, removes it from all users specified
* @param array $uid_shared_with
*/
public static function unshare($item, $uid_shared_with) {
$query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE item = ? AND uid_shared_with = ? AND uid_owner = ?");
public static function unshare($source, $uid_shared_with) {
$query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? AND uid_owner = ?");
foreach ($uid_shared_with as $uid) {
$query->execute(array($item, $uid, $_SESSION['user_id']));
$query->execute(array($source, $uid, $_SESSION['user_id']));
}
}
/**
* Unshare the item from the current user - used when the user deletes the item
* @param $target
*/
public static function unshareFromSelf($target) {
$query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE target COLLATE latin1_bin LIKE ? AND uid_shared_with = ?");
$query->execute(array($target, $_SESSION['user_id']));
}
/**
* Set the source location to a new value
* @param $oldSource The current source location

View file

@ -27,7 +27,7 @@ OC_FILESYSTEM::registerStorageType('shared','OC_FILESTORAGE_SHARED',array('datad
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
class OC_FILESTORAGE_SHARED {
class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE {
private $sourcePaths = array();
@ -320,17 +320,16 @@ class OC_FILESTORAGE_SHARED {
}
}
// TODO OC_SHARE::getPermissions()
public function unlink($path) {
$source = $this->getSource($path);
if ($source) {
$storage = OC_FILESYSTEM::getStorage($source);
return $storage->unlink($this->getInternalPath($source));
}
// The file will be removed from the database, but won't be deleted from the owner's filesystem
$target = OC_FILESYSTEM::getStorageMountPoint($this).$path;
OC_SHARE::unshareFromSelf($target);
}
public function rename($path1, $path2) {
OC_SHARE::setTarget($path1, $path2);
$oldTarget = OC_FILESYSTEM::getStorageMountPoint($this).$path1;
$newTarget = OC_FILESYSTEM::getStorageMountPoint($this).$path2;
OC_SHARE::setTarget($oldTarget, $newTarget);
}
public function copy($path1, $path2) {