summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib_share.php
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2011-07-28 15:31:52 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2011-07-28 15:31:52 -0400
commit31a067b5a39ee9132054d9e5338ad6d745136a3b (patch)
treea6593082a21bad436d36f62414665bd44e587e82 /apps/files_sharing/lib_share.php
parentd36850f0f2b507b566e57de3befb3fb8e2dd5c5a (diff)
downloadnextcloud-server-31a067b5a39ee9132054d9e5338ad6d745136a3b.tar.gz
nextcloud-server-31a067b5a39ee9132054d9e5338ad6d745136a3b.zip
Add support for sharing multiple files from share dialog, move loops outside of OC_SHARE
Diffstat (limited to 'apps/files_sharing/lib_share.php')
-rw-r--r--apps/files_sharing/lib_share.php48
1 files changed, 21 insertions, 27 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 44babc73a76..c0e940754ec 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -43,29 +43,27 @@ class OC_SHARE {
$token = sha1("$uid_owner-$item");
} else {
$query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
- foreach ($uid_shared_with as $uid) {
- $target = "/".$uid."/files/Share/".basename($source);
- $check = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?");
- $result = $check->execute(array($target, $uid))->fetchAll();
- // Check if target already exists for the user, if it does append a number to the name
- if (count($result) > 0) {
- if ($pos = strrpos($target, ".")) {
- $name = substr($target, 0, $pos);
- $ext = substr($target, $pos);
- } else {
- $name = $target;
- $ext = "";
- }
- $counter = 1;
- while (count($result) > 0) {
- $newTarget = $name."_".$counter.$ext;
- $result = $check->execute(array($newTarget, $uid))->fetchAll();
- $counter++;
- }
- $target = $newTarget;
+ $target = "/".$uid_shared_with."/files/Share/".basename($source);
+ $check = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ?");
+ $result = $check->execute(array($target, $uid_shared_with))->fetchAll();
+ // Check if target already exists for the user, if it does append a number to the name
+ if (count($result) > 0) {
+ if ($pos = strrpos($target, ".")) {
+ $name = substr($target, 0, $pos);
+ $ext = substr($target, $pos);
+ } else {
+ $name = $target;
+ $ext = "";
}
- $query->execute(array($uid_owner, $uid, $source, $target, $permissions));
+ $counter = 1;
+ while (count($result) > 0) {
+ $newTarget = $name."_".$counter.$ext;
+ $result = $check->execute(array($newTarget, $uid_shared_with))->fetchAll();
+ $counter++;
+ }
+ $target = $newTarget;
}
+ $query->execute(array($uid_owner, $uid_shared_with, $source, $target, $permissions));
}
}
}
@@ -232,9 +230,7 @@ class OC_SHARE {
*/
public static function setIsWriteable($source, $uid_shared_with, $is_writeable) {
$query = OC_DB::prepare("UPDATE *PREFIX*sharing SET is_writeable = ? WHERE SUBSTR(source, 1, ?) = ? AND uid_shared_with = ? AND uid_owner = ?");
- foreach ($uid_shared_with as $uid) {
- $query->execute(array($is_writeable, strlen($source), $source, $uid_shared_with, OC_USER::getUser()));
- }
+ $query->execute(array($is_writeable, strlen($source), $source, $uid_shared_with, OC_USER::getUser()));
}
/**
@@ -247,9 +243,7 @@ class OC_SHARE {
*/
public static function unshare($source, $uid_shared_with) {
$query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_shared_with = ? AND uid_owner = ?");
- foreach ($uid_shared_with as $uid) {
- $query->execute(array(strlen($source), $source, $uid, OC_USER::getUser()));
- }
+ $query->execute(array(strlen($source), $source, $uid_shared_with, OC_USER::getUser()));
}
/**