diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-11-12 00:37:40 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-11-12 00:37:40 +0100 |
commit | 82e010c51ceeb54f35f1f842de664e6734b00382 (patch) | |
tree | faf208b23ca2f96fd06d982946f785ee1e4ef49e /lib/public | |
parent | fd709fc0217b2dc6b9b4a46aae4c9df721641084 (diff) | |
parent | 09d6d843f77d397dfc90931354d3860bd7098f3e (diff) | |
download | nextcloud-server-82e010c51ceeb54f35f1f842de664e6734b00382.tar.gz nextcloud-server-82e010c51ceeb54f35f1f842de664e6734b00382.zip |
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/constants.php | 38 | ||||
-rw-r--r-- | lib/public/share.php | 14 |
2 files changed, 43 insertions, 9 deletions
diff --git a/lib/public/constants.php b/lib/public/constants.php new file mode 100644 index 00000000000..bc979c9031f --- /dev/null +++ b/lib/public/constants.php @@ -0,0 +1,38 @@ +<?php +/** + * ownCloud + * + * @author Thomas Tanghus + * @copyright 2012 Thomas Tanghus (thomas@tanghus.net) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * This file defines common constants used in ownCloud + */ + +namespace OCP; + +/** + * CRUDS permissions. + */ +const PERMISSION_CREATE = 4; +const PERMISSION_READ = 1; +const PERMISSION_UPDATE = 2; +const PERMISSION_DELETE = 8; +const PERMISSION_SHARE = 16; +const PERMISSION_ALL = 31; + diff --git a/lib/public/share.php b/lib/public/share.php index 071304ec249..24de4dcd5b2 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(); @@ -701,7 +697,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']; @@ -847,7 +843,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); @@ -1133,7 +1129,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; |