summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2013-07-10 12:41:53 +0200
committerGeorg Ehrke <developer@georgehrke.com>2013-07-10 12:41:53 +0200
commita357e5b284ed5b752864e4570cb179f3f2d88229 (patch)
treee811ea2288b5dfa069908f25f696f795a268cb53 /lib/public
parent832779804d36d27c47325d1dcce09e566c8cee60 (diff)
parent5387e5c354440b264040816ea7fcaf6783a2ebdc (diff)
downloadnextcloud-server-a357e5b284ed5b752864e4570cb179f3f2d88229.tar.gz
nextcloud-server-a357e5b284ed5b752864e4570cb179f3f2d88229.zip
merge conflicts ...
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/defaults.php108
-rw-r--r--lib/public/share.php70
-rw-r--r--lib/public/util.php14
3 files changed, 189 insertions, 3 deletions
diff --git a/lib/public/defaults.php b/lib/public/defaults.php
new file mode 100644
index 00000000000..147f23e341f
--- /dev/null
+++ b/lib/public/defaults.php
@@ -0,0 +1,108 @@
+<?php
+/**
+* ownCloud
+*
+* @author Björn Schießle
+* @copyright 2013 Björn Schießle schiessle@owncloud.com
+*
+* 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/>.
+*
+*/
+
+namespace OCP;
+
+/*
+ * public api to access default strings and urls for your templates
+ */
+
+class Defaults {
+
+ private $defaults;
+
+ function __construct() {
+ $this->defaults = new \OC_Defaults();
+ }
+
+ /**
+ * @breif get base URL for the organisation behind your ownCloud instance
+ * @return string
+ */
+ public function getBaseUrl() {
+ return $this->defaults->getBaseUrl();
+ }
+
+ /**
+ * @breif link to the desktop sync client
+ * @return string
+ */
+ public function getSyncClientUrl() {
+ return $this->defaults->getSyncClientUrl();
+ }
+
+ /**
+ * @breif base URL to the documentation of your ownCloud instance
+ * @return string
+ */
+ public function getDocBaseUrl() {
+ return $this->defaults->getDocBaseUrl();
+ }
+
+ /**
+ * @breif name of your ownCloud instance
+ * @return string
+ */
+ public function getName() {
+ return $this->defaults->getName();
+ }
+
+ /**
+ * @breif Entity behind your onwCloud instance
+ * @return string
+ */
+ public function getEntity() {
+ return $this->defaults->getEntity();
+ }
+
+ /**
+ * @breif ownCloud slogan
+ * @return string
+ */
+ public function getSlogan() {
+ return $this->defaults->getSlogan();
+ }
+
+ /**
+ * @breif logo claim
+ * @return string
+ */
+ public function getLogoClaim() {
+ return $this->defaults->getLogoClaim();
+ }
+
+ /**
+ * @breif footer, short version
+ * @return string
+ */
+ public function getShortFooter() {
+ return $this->defaults->getShortFooter();
+ }
+
+ /**
+ * @breif footer, long version
+ * @return string
+ */
+ public function getLongFooter() {
+ return $this->defaults->getLongFooter();
+ }
+}
diff --git a/lib/public/share.php b/lib/public/share.php
index 122ab3fa030..596a729a47d 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -292,6 +292,29 @@ class Share {
}
/**
+ * @brief resolves reshares down to the last real share
+ * @param $linkItem
+ * @return $fileOwner
+ */
+ public static function resolveReShare($linkItem)
+ {
+ if (isset($linkItem['parent'])) {
+ $parent = $linkItem['parent'];
+ while (isset($parent)) {
+ $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `id` = ?', 1);
+ $item = $query->execute(array($parent))->fetchRow();
+ if (isset($item['parent'])) {
+ $parent = $item['parent'];
+ } else {
+ return $item;
+ }
+ }
+ }
+ return $linkItem;
+ }
+
+
+ /**
* @brief Get the shared items of item type owned by the current user
* @param string Item type
* @param int Format (optional) Format type must be defined by the backend
@@ -312,7 +335,7 @@ class Share {
* @return Return depends on format
*/
public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE,
- $parameters = null, $includeCollections = false) {
+ $parameters = null, $includeCollections = false) {
return self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), $format,
$parameters, -1, $includeCollections);
}
@@ -634,6 +657,17 @@ class Share {
}
$query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?');
$query->execute(array($permissions, $item['id']));
+ if ($itemType === 'file' || $itemType === 'folder') {
+ \OC_Hook::emit('OCP\Share', 'post_update_permissions', array(
+ 'itemType' => $itemType,
+ 'itemSource' => $itemSource,
+ 'shareType' => $shareType,
+ 'shareWith' => $shareWith,
+ 'uidOwner' => \OC_User::getUser(),
+ 'permissions' => $permissions,
+ 'path' => $item['path'],
+ ));
+ }
// Check if permissions were removed
if ($item['permissions'] & ~$permissions) {
// If share permission is removed all reshares must be deleted
@@ -662,7 +696,13 @@ class Share {
// Remove the permissions for all reshares of this item
if (!empty($ids)) {
$ids = "'".implode("','", $ids)."'";
- $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = `permissions` & ?'
+ // TODO this should be done with Doctrine platform objects
+ if (\OC_Config::getValue( "dbtype") === 'oci') {
+ $andOp = 'BITAND(`permissions`, ?)';
+ } else {
+ $andOp = '`permissions` & ?';
+ }
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = '.$andOp
.' WHERE `id` IN ('.$ids.')');
$query->execute(array($permissions));
}
@@ -963,6 +1003,30 @@ class Share {
$switchedItems = array();
$mounts = array();
while ($row = $result->fetchRow()) {
+ if (isset($row['id'])) {
+ $row['id']=(int)$row['id'];
+ }
+ if (isset($row['share_type'])) {
+ $row['share_type']=(int)$row['share_type'];
+ }
+ if (isset($row['parent'])) {
+ $row['parent']=(int)$row['parent'];
+ }
+ if (isset($row['file_parent'])) {
+ $row['file_parent']=(int)$row['file_parent'];
+ }
+ if (isset($row['file_source'])) {
+ $row['file_source']=(int)$row['file_source'];
+ }
+ if (isset($row['permissions'])) {
+ $row['permissions']=(int)$row['permissions'];
+ }
+ if (isset($row['storage'])) {
+ $row['storage']=(int)$row['storage'];
+ }
+ if (isset($row['stime'])) {
+ $row['stime']=(int)$row['stime'];
+ }
// Filter out duplicate group shares for users with unique targets
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
$row['share_type'] = self::SHARE_TYPE_GROUP;
@@ -978,7 +1042,7 @@ class Share {
// Check if the same owner shared with the user twice
// through a group and user share - this is allowed
$id = $targets[$row[$column]];
- if ($items[$id]['uid_owner'] == $row['uid_owner']) {
+ if (isset($items[$id]) && $items[$id]['uid_owner'] == $row['uid_owner']) {
// Switch to group share type to ensure resharing conditions aren't bypassed
if ($items[$id]['share_type'] != self::SHARE_TYPE_GROUP) {
$items[$id]['share_type'] = self::SHARE_TYPE_GROUP;
diff --git a/lib/public/util.php b/lib/public/util.php
index 6744c2d37bd..d69602f4507 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -355,6 +355,20 @@ class Util {
public static function sanitizeHTML( $value ) {
return(\OC_Util::sanitizeHTML($value));
}
+
+ /**
+ * @brief Public function to encode url parameters
+ *
+ * This function is used to encode path to file before output.
+ * Encoding is done according to RFC 3986 with one exception:
+ * Character '/' is preserved as is.
+ *
+ * @param string $component part of URI to encode
+ * @return string
+ */
+ public static function encodePath($component) {
+ return(\OC_Util::encodePath($component));
+ }
/**
* @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.