summaryrefslogtreecommitdiffstats
path: root/lib/public/share.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-11-15 00:37:54 +0100
committerRobin Appelman <icewind@owncloud.com>2012-11-15 00:37:54 +0100
commitbf2ac9f113d41dc944f42d1516649a3a72e88a65 (patch)
tree36e0c3b8a6327321122fc8a63b7aa23d1ee0f789 /lib/public/share.php
parent41a61bc637c3d60efc5abe81c39fc726fd78cd1d (diff)
parenta418a3ba65d0097047cfcad1b4ee82185c42d22a (diff)
downloadnextcloud-server-bf2ac9f113d41dc944f42d1516649a3a72e88a65.tar.gz
nextcloud-server-bf2ac9f113d41dc944f42d1516649a3a72e88a65.zip
merge master into filesystem
Diffstat (limited to 'lib/public/share.php')
-rw-r--r--lib/public/share.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/public/share.php b/lib/public/share.php
index dd1aac609a5..83c0bcd5e53 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -46,12 +46,8 @@ class Share {
* Check if permission is granted with And (&) e.g. Check if delete is granted: if ($permissions & PERMISSION_DELETE)
* Remove permissions with And (&) and Not (~) e.g. Remove the update permission: $permissions &= ~PERMISSION_UPDATE
* Apps are required to handle permissions on their own, this class only stores and manages the permissions of shares
+ * @see lib/public/constants.php
*/
- const PERMISSION_CREATE = 4;
- const PERMISSION_READ = 1;
- const PERMISSION_UPDATE = 2;
- const PERMISSION_DELETE = 8;
- const PERMISSION_SHARE = 16;
const FORMAT_NONE = -1;
const FORMAT_STATUSES = -2;
@@ -402,7 +398,7 @@ class Share {
// Check if permissions were removed
if ($item['permissions'] & ~$permissions) {
// If share permission is removed all reshares must be deleted
- if (($item['permissions'] & self::PERMISSION_SHARE) && (~$permissions & self::PERMISSION_SHARE)) {
+ if (($item['permissions'] & PERMISSION_SHARE) && (~$permissions & PERMISSION_SHARE)) {
self::delete($item['id'], true);
} else {
$ids = array();
@@ -552,7 +548,7 @@ class Share {
$itemTypes = $collectionTypes;
}
$placeholders = join(',', array_fill(0, count($itemTypes), '?'));
- $where .= ' WHERE item_type IN ('.$placeholders.'))';
+ $where .= ' WHERE `item_type` IN ('.$placeholders.'))';
$queryArgs = $itemTypes;
} else {
$where = ' WHERE `item_type` = ?';
@@ -629,7 +625,7 @@ class Share {
$queryArgs[] = $item;
if ($includeCollections && $collectionTypes) {
$placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
- $where .= ' OR item_type IN ('.$placeholders.'))';
+ $where .= ' OR `item_type` IN ('.$placeholders.'))';
$queryArgs = array_merge($queryArgs, $collectionTypes);
}
}
@@ -677,6 +673,9 @@ class Share {
$root = strlen($root);
$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit);
$result = $query->execute($queryArgs);
+ if (\OC_DB::isError($result)) {
+ \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR);
+ }
$items = array();
$targets = array();
while ($row = $result->fetchRow()) {
@@ -701,7 +700,7 @@ class Share {
$items[$id]['share_with'] = $row['share_with'];
}
// Switch ids if sharing permission is granted on only one share to ensure correct parent is used if resharing
- if (~(int)$items[$id]['permissions'] & self::PERMISSION_SHARE && (int)$row['permissions'] & self::PERMISSION_SHARE) {
+ if (~(int)$items[$id]['permissions'] & PERMISSION_SHARE && (int)$row['permissions'] & PERMISSION_SHARE) {
$items[$row['id']] = $items[$id];
unset($items[$id]);
$id = $row['id'];
@@ -848,7 +847,7 @@ class Share {
throw new \Exception($message);
}
// Check if share permissions is granted
- if ((int)$checkReshare['permissions'] & self::PERMISSION_SHARE) {
+ if ((int)$checkReshare['permissions'] & PERMISSION_SHARE) {
if (~(int)$checkReshare['permissions'] & $permissions) {
$message = 'Sharing '.$itemSource.' failed, because the permissions exceed permissions granted to '.$uidOwner;
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
@@ -1136,7 +1135,7 @@ class Share {
$duplicateParent = $query->execute(array($item['item_type'], $item['item_target'], self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique, $item['uid_owner'], $item['parent']))->fetchRow();
if ($duplicateParent) {
// Change the parent to the other item id if share permission is granted
- if ($duplicateParent['permissions'] & self::PERMISSION_SHARE) {
+ if ($duplicateParent['permissions'] & PERMISSION_SHARE) {
$query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `parent` = ? WHERE `id` = ?');
$query->execute(array($duplicateParent['id'], $item['id']));
continue;