summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-11-12 00:37:40 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-11-12 00:37:40 +0100
commit82e010c51ceeb54f35f1f842de664e6734b00382 (patch)
treefaf208b23ca2f96fd06d982946f785ee1e4ef49e /lib
parentfd709fc0217b2dc6b9b4a46aae4c9df721641084 (diff)
parent09d6d843f77d397dfc90931354d3860bd7098f3e (diff)
downloadnextcloud-server-82e010c51ceeb54f35f1f842de664e6734b00382.tar.gz
nextcloud-server-82e010c51ceeb54f35f1f842de664e6734b00382.zip
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php6
-rw-r--r--lib/files.php8
-rw-r--r--lib/public/constants.php38
-rw-r--r--lib/public/share.php14
4 files changed, 51 insertions, 15 deletions
diff --git a/lib/base.php b/lib/base.php
index bed50c904c7..50617081b1f 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -20,6 +20,8 @@
*
*/
+require_once 'public/constants.php';
+
/**
* Class that is a namespace for all global OC variables
* No, we can not put this class in its own file because it is used by
@@ -230,7 +232,7 @@ class OC{
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
}
}
- }
+ }
OC_Log::write('core', 'starting upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG);
$result=OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml');
if(!$result) {
@@ -288,7 +290,7 @@ class OC{
// (re)-initialize session
session_start();
-
+
// regenerate session id periodically to avoid session fixation
if (!isset($_SESSION['SID_CREATED'])) {
$_SESSION['SID_CREATED'] = time();
diff --git a/lib/files.php b/lib/files.php
index ac4aa36c01d..e5bf78d032f 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -91,16 +91,16 @@ class OC_Files {
foreach ($files as &$file) {
$file['directory'] = $directory;
$file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
- $permissions = OCP\Share::PERMISSION_READ;
+ $permissions = OCP\PERMISSION_READ;
// NOTE: Remove check when new encryption is merged
if (!$file['encrypted']) {
- $permissions |= OCP\Share::PERMISSION_SHARE;
+ $permissions |= OCP\PERMISSION_SHARE;
}
if ($file['type'] == 'dir' && $file['writable']) {
- $permissions |= OCP\Share::PERMISSION_CREATE;
+ $permissions |= OCP\PERMISSION_CREATE;
}
if ($file['writable']) {
- $permissions |= OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_DELETE;
+ $permissions |= OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE;
}
$file['permissions'] = $permissions;
}
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;