summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php1
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php4
-rw-r--r--lib/private/config.php2
-rw-r--r--lib/private/l10n/factory.php32
-rw-r--r--lib/private/log/owncloud.php23
-rw-r--r--lib/private/server.php6
-rw-r--r--lib/private/share20/defaultshareprovider.php68
-rw-r--r--lib/private/share20/ishare.php233
-rw-r--r--lib/private/share20/manager.php123
-rw-r--r--lib/private/share20/providerfactory.php1
-rw-r--r--lib/private/share20/share.php148
-rw-r--r--lib/public/files/cache/icache.php15
-rw-r--r--lib/public/iservercontainer.php8
-rw-r--r--lib/public/share/imanager.php212
-rw-r--r--lib/public/share/iproviderfactory.php (renamed from lib/private/share20/iproviderfactory.php)6
-rw-r--r--lib/public/share/ishare.php264
-rw-r--r--lib/public/share/ishareprovider.php (renamed from lib/private/share20/ishareprovider.php)63
17 files changed, 706 insertions, 503 deletions
diff --git a/lib/base.php b/lib/base.php
index 970eabce6af..56ff1cb8962 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -473,6 +473,7 @@ class OC {
*/
public static function setRequiredIniValues() {
@ini_set('default_charset', 'UTF-8');
+ @ini_set('gd.jpeg_ignore_warning', 1);
}
public static function init() {
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index 175d6c747e4..61a04482431 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -227,6 +227,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getSecureRandom();
});
+ $this->registerService('OCP\\Share\\IManager', function($c) {
+ return $this->getServer()->getShareManager();
+ });
+
$this->registerService('OCP\\SystemTag\\ISystemTagManager', function() {
return $this->getServer()->getSystemTagManager();
});
diff --git a/lib/private/config.php b/lib/private/config.php
index 30baa3fe0e6..368dafd0460 100644
--- a/lib/private/config.php
+++ b/lib/private/config.php
@@ -184,7 +184,7 @@ class Config {
// Include file and merge config
foreach ($configFiles as $file) {
- $filePointer = @fopen($file, 'r');
+ $filePointer = file_exists($file) ? fopen($file, 'r') : false;
if($file === $this->configFilePath &&
$filePointer === false &&
@!file_exists($this->configFilePath)) {
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php
index 09496cba410..f4f7d897061 100644
--- a/lib/private/l10n/factory.php
+++ b/lib/private/l10n/factory.php
@@ -27,6 +27,7 @@ namespace OC\L10N;
use OCP\IConfig;
use OCP\IRequest;
+use OCP\IUserSession;
use OCP\L10N\IFactory;
/**
@@ -59,13 +60,20 @@ class Factory implements IFactory {
/** @var IRequest */
protected $request;
+ /** @var IUserSession */
+ protected $userSession;
+
/**
* @param IConfig $config
* @param IRequest $request
+ * @param IUserSession $userSession
*/
- public function __construct(IConfig $config, IRequest $request) {
+ public function __construct(IConfig $config,
+ IRequest $request,
+ IUserSession $userSession) {
$this->config = $config;
$this->request = $request;
+ $this->userSession = $userSession;
}
/**
@@ -107,9 +115,25 @@ class Factory implements IFactory {
return $this->requestLanguage;
}
- $userId = \OC_User::getUser(); // FIXME not available in non-static?
+ /**
+ * At this point ownCloud might not yet be installed and thus the lookup
+ * in the preferences table might fail. For this reason we need to check
+ * whether the instance has already been installed
+ *
+ * @link https://github.com/owncloud/core/issues/21955
+ */
+ if($this->config->getSystemValue('installed', false)) {
+ $userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
+ if(!is_null($userId)) {
+ $userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
+ } else {
+ $userLang = null;
+ }
+ } else {
+ $userId = null;
+ $userLang = null;
+ }
- $userLang = $userId !== false ? $this->config->getUserValue($userId, 'core', 'lang') : null;
if ($userLang) {
$this->requestLanguage = $userLang;
if ($this->languageExists($app, $userLang)) {
@@ -124,7 +148,7 @@ class Factory implements IFactory {
}
$lang = $this->setLanguageFromRequest($app);
- if ($userId !== false && $app === null && !$userLang) {
+ if ($userId !== null && $app === null && !$userLang) {
$this->config->setUserValue($userId, 'core', 'lang', $lang);
}
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index f9ce671aa93..dabf95d7616 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -43,17 +43,18 @@ class OC_Log_Owncloud {
$defaultLogFile = $systemConfig->getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log';
self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile);
- /*
- * Fall back to default log file if specified logfile does not exist
- * and can not be created. Error suppression is required in order to
- * not end up in the error handler which will try to log the error.
- * A better solution (compared to error suppression) would be checking
- * !is_writable(dirname(self::$logFile)) before touch(), but
- * is_writable() on directories used to be pretty unreliable on Windows
- * for at least some time.
- */
- if (!file_exists(self::$logFile) && !@touch(self::$logFile)) {
- self::$logFile = $defaultLogFile;
+ /**
+ * Fall back to default log file if specified logfile does not exist
+ * and can not be created.
+ */
+ if (!file_exists(self::$logFile)) {
+ if(!is_writable(dirname(self::$logFile))) {
+ self::$logFile = $defaultLogFile;
+ } else {
+ if(!touch(self::$logFile)) {
+ self::$logFile = $defaultLogFile;
+ }
+ }
}
}
diff --git a/lib/private/server.php b/lib/private/server.php
index 81929d0c7b3..d453a42d3a0 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -265,7 +265,8 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService('L10NFactory', function (Server $c) {
return new \OC\L10N\Factory(
$c->getConfig(),
- $c->getRequest()
+ $c->getRequest(),
+ $c->getUserSession()
);
});
$this->registerService('URLGenerator', function (Server $c) {
@@ -1255,9 +1256,8 @@ class Server extends ServerContainer implements IServerContainer {
return \OC_Mount_Config::$app->getContainer()->query('OCA\\Files_External\\Service\\UserStoragesService');
}
-
/**
- * @return \OC\Share20\Manager
+ * @return \OCP\Share\IManager
*/
public function getShareManager() {
return $this->query('ShareManager');
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php
index fb2acb56a73..baa12d6c933 100644
--- a/lib/private/share20/defaultshareprovider.php
+++ b/lib/private/share20/defaultshareprovider.php
@@ -20,6 +20,7 @@
*/
namespace OC\Share20;
+use OCP\Share\IShareProvider;
use OC\Share20\Exception\InvalidShare;
use OC\Share20\Exception\ProviderException;
use OC\Share20\Exception\ShareNotFound;
@@ -87,12 +88,12 @@ class DefaultShareProvider implements IShareProvider {
/**
* Share a path
*
- * @param IShare $share
- * @return IShare The share object
+ * @param \OCP\Share\IShare $share
+ * @return \OCP\Share\IShare The share object
* @throws ShareNotFound
* @throws \Exception
*/
- public function create(IShare $share) {
+ public function create(\OCP\Share\IShare $share) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share');
@@ -127,15 +128,15 @@ class DefaultShareProvider implements IShareProvider {
// Set what is shares
$qb->setValue('item_type', $qb->createParameter('itemType'));
- if ($share->getPath() instanceof \OCP\Files\File) {
+ if ($share->getNode() instanceof \OCP\Files\File) {
$qb->setParameter('itemType', 'file');
} else {
$qb->setParameter('itemType', 'folder');
}
// Set the file id
- $qb->setValue('item_source', $qb->createNamedParameter($share->getPath()->getId()));
- $qb->setValue('file_source', $qb->createNamedParameter($share->getPath()->getId()));
+ $qb->setValue('item_source', $qb->createNamedParameter($share->getNode()->getId()));
+ $qb->setValue('file_source', $qb->createNamedParameter($share->getNode()->getId()));
// set the permissions
$qb->setValue('permissions', $qb->createNamedParameter($share->getPermissions()));
@@ -179,10 +180,10 @@ class DefaultShareProvider implements IShareProvider {
/**
* Update a share
*
- * @param IShare $share
- * @return IShare The share object
+ * @param \OCP\Share\IShare $share
+ * @return \OCP\Share\IShare The share object
*/
- public function update(IShare $share) {
+ public function update(\OCP\Share\IShare $share) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
/*
* We allow updating the recipient on user shares.
@@ -194,8 +195,8 @@ class DefaultShareProvider implements IShareProvider {
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
- ->set('item_source', $qb->createNamedParameter($share->getPath()->getId()))
- ->set('file_source', $qb->createNamedParameter($share->getPath()->getId()))
+ ->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
+ ->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->execute();
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$qb = $this->dbConn->getQueryBuilder();
@@ -204,8 +205,8 @@ class DefaultShareProvider implements IShareProvider {
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
- ->set('item_source', $qb->createNamedParameter($share->getPath()->getId()))
- ->set('file_source', $qb->createNamedParameter($share->getPath()->getId()))
+ ->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
+ ->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->execute();
/*
@@ -216,8 +217,8 @@ class DefaultShareProvider implements IShareProvider {
->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
- ->set('item_source', $qb->createNamedParameter($share->getPath()->getId()))
- ->set('file_source', $qb->createNamedParameter($share->getPath()->getId()))
+ ->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
+ ->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->execute();
/*
@@ -238,8 +239,8 @@ class DefaultShareProvider implements IShareProvider {
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
- ->set('item_source', $qb->createNamedParameter($share->getPath()->getId()))
- ->set('file_source', $qb->createNamedParameter($share->getPath()->getId()))
+ ->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
+ ->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('token', $qb->createNamedParameter($share->getToken()))
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE))
->execute();
@@ -251,10 +252,10 @@ class DefaultShareProvider implements IShareProvider {
/**
* Get all children of this share
*
- * @param IShare $parent
+ * @param \OCP\Share\IShare $parent
* @return IShare[]
*/
- public function getChildren(IShare $parent) {
+ public function getChildren(\OCP\Share\IShare $parent) {
$children = [];
$qb = $this->dbConn->getQueryBuilder();
@@ -286,10 +287,10 @@ class DefaultShareProvider implements IShareProvider {
/**
* Delete a share
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @throws BackendError
*/
- public function delete(IShare $share) {
+ public function delete(\OCP\Share\IShare $share) {
// Fetch share to make sure it exists
$share = $this->getShareById($share->getId());
@@ -308,12 +309,12 @@ class DefaultShareProvider implements IShareProvider {
* Unshare a share from the recipient. If this is a group share
* this means we need a special entry in the share db.
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @param IUser $recipient
* @throws BackendError
* @throws ProviderException
*/
- public function deleteFromSelf(IShare $share, IUser $recipient) {
+ public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
/** @var IGroup $group */
@@ -341,7 +342,7 @@ class DefaultShareProvider implements IShareProvider {
if ($data === false) {
$qb = $this->dbConn->getQueryBuilder();
- $type = $share->getPath() instanceof \OCP\Files\File ? 'file' : 'folder';
+ $type = $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder';
//Insert new share
$qb->insert('share')
@@ -352,11 +353,11 @@ class DefaultShareProvider implements IShareProvider {
'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()->getUID()),
'parent' => $qb->createNamedParameter($share->getId()),
'item_type' => $qb->createNamedParameter($type),
- 'item_source' => $qb->createNamedParameter($share->getPath()->getId()),
- 'file_source' => $qb->createNamedParameter($share->getPath()->getId()),
+ 'item_source' => $qb->createNamedParameter($share->getNode()->getId()),
+ 'file_source' => $qb->createNamedParameter($share->getNode()->getId()),
'file_target' => $qb->createNamedParameter($share->getTarget()),
'permissions' => $qb->createNamedParameter(0),
- 'stime' => $qb->createNamedParameter($share->getSharetime()),
+ 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()),
])->execute();
} else if ($data['permissions'] !== 0) {
@@ -450,7 +451,7 @@ class DefaultShareProvider implements IShareProvider {
* Get share by id
*
* @param int $id
- * @return IShare
+ * @return \OCP\Share\IShare
* @throws ShareNotFound
*/
public function getShareById($id) {
@@ -649,7 +650,7 @@ class DefaultShareProvider implements IShareProvider {
* Create a share object from an database row
*
* @param mixed[] $data
- * @return Share
+ * @return \OCP\Share\IShare
* @throws InvalidShare
*/
private function createShare($data) {
@@ -658,9 +659,12 @@ class DefaultShareProvider implements IShareProvider {
->setShareType((int)$data['share_type'])
->setPermissions((int)$data['permissions'])
->setTarget($data['file_target'])
- ->setShareTime((int)$data['stime'])
->setMailSend((bool)$data['mail_send']);
+ $shareTime = new \DateTime();
+ $shareTime->setTimestamp((int)$data['stime']);
+ $share->setShareTime($shareTime);
+
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$sharedWith = $this->userManager->get($data['share_with']);
if ($sharedWith === null) {
@@ -701,7 +705,7 @@ class DefaultShareProvider implements IShareProvider {
}
$path = $this->getNode($share->getShareOwner(), (int)$data['file_source']);
- $share->setPath($path);
+ $share->setNode($path);
if ($data['expiration'] !== null) {
$expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']);
@@ -760,7 +764,7 @@ class DefaultShareProvider implements IShareProvider {
$stmt->closeCursor();
if ($data !== false) {
- $share->setPermissions($data['permissions']);
+ $share->setPermissions((int)$data['permissions']);
$share->setTarget($data['file_target']);
}
diff --git a/lib/private/share20/ishare.php b/lib/private/share20/ishare.php
deleted file mode 100644
index 34d1dfa4d3d..00000000000
--- a/lib/private/share20/ishare.php
+++ /dev/null
@@ -1,233 +0,0 @@
-<?php
-/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OC\Share20;
-
-use OCP\Files\File;
-use OCP\Files\Folder;
-use OCP\Files\Node;
-use OCP\IUser;
-use OCP\IGroup;
-
-interface IShare {
-
- /**
- * Get the id of the share
- *
- * @return string
- */
- public function getId();
-
- /**
- * Set the id of the share
- *
- * @param string $id
- * @return IShare The modified share object
- */
- public function setId($id);
-
- /**
- * Get the full share id
- *
- * @return string
- */
- public function getFullId();
-
- /**
- * Set the provider id
- *
- * @param string $id
- * @return IShare The modified share object
- */
- public function setProviderId($id);
-
- /**
- * Set the path of this share
- *
- * @param Node $path
- * @return IShare The modified object
- */
- public function setPath(Node $path);
-
- /**
- * Get the path of this share for the current user
- *
- * @return File|Folder
- */
- public function getPath();
-
- /**
- * Set the shareType
- *
- * @param int $shareType
- * @return IShare The modified object
- */
- public function setShareType($shareType);
-
- /**
- * Get the shareType
- *
- * @return int
- */
- public function getShareType();
-
- /**
- * Set the receiver of this share
- *
- * @param IUser|IGroup|string
- * @return IShare The modified object
- */
- public function setSharedWith($sharedWith);
-
- /**
- * Get the receiver of this share
- *
- * @return IUser|IGroup|string
- */
- public function getSharedWith();
-
- /**
- * Set the permissions
- *
- * @param int $permissions
- * @return IShare The modified object
- */
- public function setPermissions($permissions);
-
- /**
- * Get the share permissions
- *
- * @return int
- */
- public function getPermissions();
-
- /**
- * Set the expiration date
- *
- * @param \DateTime $expireDate
- * @return IShare The modified object
- */
- public function setExpirationDate($expireDate);
-
- /**
- * Get the share expiration date
- *
- * @return \DateTime
- */
- public function getExpirationDate();
-
- /**
- * Set the sharer of the path
- *
- * @param IUser|string $sharedBy
- * @return IShare The modified object
- */
- public function setSharedBy($sharedBy);
-
- /**
- * Get share sharer
- *
- * @return IUser|string
- */
- public function getSharedBy();
-
- /**
- * Set the original share owner (who owns the path)
- *
- * @param IUser|string
- *
- * @return IShare The modified object
- */
- public function setShareOwner($shareOwner);
-
- /**
- * Get the original share owner (who owns the path)
- *
- * @return IUser|string
- */
- public function getShareOwner();
-
- /**
- * Set the password
- *
- * @param string $password
- *
- * @return IShare The modified object
- */
- public function setPassword($password);
-
- /**
- * Is a password set for this share
- *
- * @return string
- */
- public function getPassword();
-
- /**
- * Set the token
- *
- * @param string $token
- * @return IShare The modified object
- */
- public function setToken($token);
-
- /**
- * Get the token
- *
- * @return string
- */
- public function getToken();
-
- /**
- * Get the parent it
- *
- * @return int
- */
- public function getParent();
-
- /**
- * Set the target of this share
- *
- * @param string $target
- * @return IShare The modified object
- */
- public function setTarget($target);
-
- /**
- * Get the target of this share
- *
- * @return string
- */
- public function getTarget();
-
- /**
- * Get the timestamp this share was created
- *
- * @return int
- */
- public function getSharetime();
-
- /**
- * Get mailSend
- *
- * @return bool
- */
- public function getMailSend();
-}
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 673cea9b946..d6245f4beac 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -18,11 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-namespace OC\Share20;
+namespace OC\Share20;
+use OCP\Share\IManager;
+use OCP\Share\IProviderFactory;
use OC\Share20\Exception\BackendError;
-use OC\Share20\Exception\ProviderException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
@@ -40,14 +41,11 @@ use OC\HintException;
/**
* This class is the communication hub for all sharing related operations.
*/
-class Manager {
+class Manager implements IManager {
/** @var IProviderFactory */
private $factory;
- /** @var array */
- private $type2provider;
-
/** @var ILogger */
private $logger;
@@ -91,9 +89,6 @@ class Manager {
IL10N $l,
IProviderFactory $factory
) {
- $this->providers = [];
- $this->type2provider = [];
-
$this->logger = $logger;
$this->config = $config;
$this->secureRandom = $secureRandom;
@@ -147,10 +142,10 @@ class Manager {
/**
* Check for generic requirements before creating a share
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @throws \Exception
*/
- protected function generalCreateChecks(IShare $share) {
+ protected function generalCreateChecks(\OCP\Share\IShare $share) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
// We expect a valid user as sharedWith for user shares
if (!($share->getSharedWith() instanceof \OCP\IUser)) {
@@ -181,19 +176,19 @@ class Manager {
}
// The path should be set
- if ($share->getPath() === null) {
+ if ($share->getNode() === null) {
throw new \InvalidArgumentException('Path should be set');
}
// And it should be a file or a folder
- if (!($share->getPath() instanceof \OCP\Files\File) &&
- !($share->getPath() instanceof \OCP\Files\Folder)) {
+ if (!($share->getNode() instanceof \OCP\Files\File) &&
+ !($share->getNode() instanceof \OCP\Files\Folder)) {
throw new \InvalidArgumentException('Path should be either a file or a folder');
}
// Check if we actually have share permissions
- if (!$share->getPath()->isShareable()) {
- $message_t = $this->l->t('You are not allowed to share %s', [$share->getPath()->getPath()]);
+ if (!$share->getNode()->isShareable()) {
+ $message_t = $this->l->t('You are not allowed to share %s', [$share->getNode()->getPath()]);
throw new HintException($message_t, $message_t, 404);
}
@@ -203,8 +198,8 @@ class Manager {
}
// Check that we do not share with more permissions than we have
- if ($share->getPermissions() & ~$share->getPath()->getPermissions()) {
- $message_t = $this->l->t('Cannot increase permissions of %s', [$share->getPath()->getPath()]);
+ if ($share->getPermissions() & ~$share->getNode()->getPermissions()) {
+ $message_t = $this->l->t('Cannot increase permissions of %s', [$share->getNode()->getPath()]);
throw new HintException($message_t, $message_t, 404);
}
@@ -266,10 +261,10 @@ class Manager {
/**
* Check for pre share requirements for user shares
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @throws \Exception
*/
- protected function userCreateChecks(IShare $share) {
+ protected function userCreateChecks(\OCP\Share\IShare $share) {
// Check if we can share with group members only
if ($this->shareWithGroupMembersOnly()) {
// Verify we can share with this user
@@ -288,7 +283,7 @@ class Manager {
* Also this is not what we want in the future.. then we want to squash identical shares.
*/
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER);
- $existingShares = $provider->getSharesByPath($share->getPath());
+ $existingShares = $provider->getSharesByPath($share->getNode());
foreach($existingShares as $existingShare) {
// Ignore if it is the same share
if ($existingShare->getFullId() === $share->getFullId()) {
@@ -312,10 +307,10 @@ class Manager {
/**
* Check for pre share requirements for group shares
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @throws \Exception
*/
- protected function groupCreateChecks(IShare $share) {
+ protected function groupCreateChecks(\OCP\Share\IShare $share) {
// Verify if the user can share with this group
if ($this->shareWithGroupMembersOnly()) {
if (!$share->getSharedWith()->inGroup($share->getSharedBy())) {
@@ -329,7 +324,7 @@ class Manager {
* Also this is not what we want in the future.. then we want to squash identical shares.
*/
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
- $existingShares = $provider->getSharesByPath($share->getPath());
+ $existingShares = $provider->getSharesByPath($share->getNode());
foreach($existingShares as $existingShare) {
if ($existingShare->getFullId() === $share->getFullId()) {
continue;
@@ -344,10 +339,10 @@ class Manager {
/**
* Check for pre share requirements for link shares
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @throws \Exception
*/
- protected function linkCreateChecks(IShare $share) {
+ protected function linkCreateChecks(\OCP\Share\IShare $share) {
// Are link shares allowed?
if (!$this->shareApiAllowLinks()) {
throw new \Exception('Link sharing not allowed');
@@ -388,15 +383,15 @@ class Manager {
/**
* Check if the user that is sharing can actually share
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @return bool
*/
- protected function canShare(IShare $share) {
+ protected function canShare(\OCP\Share\IShare $share) {
if (!$this->shareApiEnabled()) {
return false;
}
- if ($this->isSharingDisabledForUser($share->getSharedBy())) {
+ if ($this->sharingDisabledForUser($share->getSharedBy())) {
return false;
}
@@ -406,13 +401,13 @@ class Manager {
/**
* Share a path
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @return Share The share object
* @throws \Exception
*
* TODO: handle link share permissions or check them
*/
- public function createShare(IShare $share) {
+ public function createShare(\OCP\Share\IShare $share) {
if (!$this->canShare($share)) {
throw new \Exception('The Share API is disabled');
}
@@ -452,10 +447,10 @@ class Manager {
}
// Verify if there are any issues with the path
- $this->pathCreateChecks($share->getPath());
+ $this->pathCreateChecks($share->getNode());
// On creation of a share the owner is always the owner of the path
- $share->setShareOwner($share->getPath()->getOwner());
+ $share->setShareOwner($share->getNode()->getOwner());
// Cannot share with the owner
if ($share->getSharedWith() === $share->getShareOwner()) {
@@ -463,7 +458,7 @@ class Manager {
}
// Generate the target
- $target = $this->config->getSystemValue('share_folder', '/') .'/'. $share->getPath()->getName();
+ $target = $this->config->getSystemValue('share_folder', '/') .'/'. $share->getNode()->getName();
$target = \OC\Files\Filesystem::normalizePath($target);
$share->setTarget($target);
@@ -481,12 +476,12 @@ class Manager {
$run = true;
$error = '';
$preHookData = [
- 'itemType' => $share->getPath() instanceof \OCP\Files\File ? 'file' : 'folder',
- 'itemSource' => $share->getPath()->getId(),
+ 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
+ 'itemSource' => $share->getNode()->getId(),
'shareType' => $share->getShareType(),
'uidOwner' => $share->getSharedBy()->getUID(),
'permissions' => $share->getPermissions(),
- 'fileSource' => $share->getPath()->getId(),
+ 'fileSource' => $share->getNode()->getId(),
'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(),
'itemTarget' => $share->getTarget(),
@@ -502,16 +497,15 @@ class Manager {
$provider = $this->factory->getProviderForType($share->getShareType());
$share = $provider->create($share);
- $share->setProviderId($provider->identifier());
// Post share hook
$postHookData = [
- 'itemType' => $share->getPath() instanceof \OCP\Files\File ? 'file' : 'folder',
- 'itemSource' => $share->getPath()->getId(),
+ 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
+ 'itemSource' => $share->getNode()->getId(),
'shareType' => $share->getShareType(),
'uidOwner' => $share->getSharedBy()->getUID(),
'permissions' => $share->getPermissions(),
- 'fileSource' => $share->getPath()->getId(),
+ 'fileSource' => $share->getNode()->getId(),
'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(),
'id' => $share->getId(),
@@ -528,10 +522,10 @@ class Manager {
/**
* Update a share
*
- * @param IShare $share
- * @return IShare The share object
+ * @param \OCP\Share\IShare $share
+ * @return \OCP\Share\IShare The share object
*/
- public function updateShare(IShare $share) {
+ public function updateShare(\OCP\Share\IShare $share) {
$expirationDateUpdated = false;
if (!$this->canShare($share)) {
@@ -583,7 +577,7 @@ class Manager {
}
}
- $this->pathCreateChecks($share->getPath());
+ $this->pathCreateChecks($share->getNode());
// Now update the share!
$provider = $this->factory->getProviderForType($share->getShareType());
@@ -591,8 +585,8 @@ class Manager {
if ($expirationDateUpdated === true) {
\OC_Hook::emit('OCP\Share', 'post_set_expiration_date', [
- 'itemType' => $share->getPath() instanceof \OCP\Files\File ? 'file' : 'folder',
- 'itemSource' => $share->getPath()->getId(),
+ 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
+ 'itemSource' => $share->getNode()->getId(),
'date' => $share->getExpirationDate(),
'uidOwner' => $share->getSharedBy()->getUID(),
]);
@@ -604,10 +598,10 @@ class Manager {
/**
* Delete all the children of this share
*
- * @param IShare $share
- * @return IShare[] List of deleted shares
+ * @param \OCP\Share\IShare $share
+ * @return \OCP\Share\IShare[] List of deleted shares
*/
- protected function deleteChildren(IShare $share) {
+ protected function deleteChildren(\OCP\Share\IShare $share) {
$deletedShares = [];
$provider = $this->factory->getProviderForType($share->getShareType());
@@ -626,16 +620,16 @@ class Manager {
/**
* Delete a share
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @throws ShareNotFound
* @throws BackendError
* @throws ShareNotFound
*/
- public function deleteShare(IShare $share) {
+ public function deleteShare(\OCP\Share\IShare $share) {
// Just to make sure we have all the info
$share = $this->getShareById($share->getFullId());
- $formatHookParams = function(IShare $share) {
+ $formatHookParams = function(\OCP\Share\IShare $share) {
// Prepare hook
$shareType = $share->getShareType();
$sharedWith = '';
@@ -649,13 +643,13 @@ class Manager {
$hookParams = [
'id' => $share->getId(),
- 'itemType' => $share->getPath() instanceof \OCP\Files\File ? 'file' : 'folder',
- 'itemSource' => $share->getPath()->getId(),
+ 'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
+ 'itemSource' => $share->getNode()->getId(),
'shareType' => $shareType,
'shareWith' => $sharedWith,
'itemparent' => $share->getParent(),
'uidOwner' => $share->getSharedBy()->getUID(),
- 'fileSource' => $share->getPath()->getId(),
+ 'fileSource' => $share->getNode()->getId(),
'fileTarget' => $share->getTarget()
];
return $hookParams;
@@ -694,10 +688,10 @@ class Manager {
* the users in a groups deletes that share. But the provider should
* handle this.
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @param IUser $recipient
*/
- public function deleteFromSelf(IShare $share, IUser $recipient) {
+ public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
list($providerId, $id) = $this->splitFullId($share->getId());
$provider = $this->factory->getProvider($providerId);
@@ -713,7 +707,7 @@ class Manager {
* @param bool $reshares
* @param int $limit The maximum number of returned results, -1 for all results
* @param int $offset
- * @return IShare[]
+ * @return \OCP\Share\IShare[]
*/
public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) {
if ($path !== null &&
@@ -734,7 +728,7 @@ class Manager {
* @param int $shareType
* @param int $limit The maximum number of shares returned, -1 for all
* @param int $offset
- * @return IShare[]
+ * @return \OCP\Share\IShare[]
*/
public function getSharedWith(IUser $user, $shareType, $limit = 50, $offset = 0) {
$provider = $this->factory->getProviderForType($shareType);
@@ -759,7 +753,6 @@ class Manager {
$provider = $this->factory->getProvider($providerId);
$share = $provider->getShareById($id);
- $share->setProviderId($provider->identifier());
return $share;
}
@@ -797,11 +790,11 @@ class Manager {
/**
* Verify the password of a public share
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @param string $password
* @return bool
*/
- public function checkPassword(IShare $share, $password) {
+ public function checkPassword(\OCP\Share\IShare $share, $password) {
if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK) {
//TODO maybe exception?
return false;
@@ -852,7 +845,7 @@ class Manager {
/**
* Create a new share
- * @return IShare;
+ * @return \OCP\Share\IShare;
*/
public function newShare() {
return new \OC\Share20\Share();
@@ -938,7 +931,7 @@ class Manager {
* @param IUser $user
* @return bool
*/
- public function isSharingDisabledForUser($user) {
+ public function sharingDisabledForUser(IUser $user) {
if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
$groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroups = json_decode($groupsList);
diff --git a/lib/private/share20/providerfactory.php b/lib/private/share20/providerfactory.php
index 2e5282c1eb4..64147355596 100644
--- a/lib/private/share20/providerfactory.php
+++ b/lib/private/share20/providerfactory.php
@@ -20,6 +20,7 @@
*/
namespace OC\Share20;
+use OCP\Share\IProviderFactory;
use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer;
diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php
index ee43725d9bc..f9cba10a07a 100644
--- a/lib/private/share20/share.php
+++ b/lib/private/share20/share.php
@@ -24,7 +24,7 @@ use OCP\Files\Node;
use OCP\IUser;
use OCP\IGroup;
-class Share implements IShare {
+class Share implements \OCP\Share\IShare {
/** @var string */
private $id;
@@ -34,11 +34,11 @@ class Share implements IShare {
private $path;
/** @var int */
private $shareType;
- /** @var IUser|IGroup|string */
+ /** @var IUser|IGroup */
private $sharedWith;
- /** @var IUser|string */
+ /** @var IUser */
private $sharedBy;
- /** @var IUser|string */
+ /** @var IUser */
private $shareOwner;
/** @var int */
private $permissions;
@@ -52,16 +52,13 @@ class Share implements IShare {
private $parent;
/** @var string */
private $target;
- /** @var int */
+ /** @var \DateTime */
private $shareTime;
/** @var bool */
private $mailSend;
/**
- * Set the id of the share
- *
- * @param string $id
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setId($id) {
$this->id = $id;
@@ -69,9 +66,7 @@ class Share implements IShare {
}
/**
- * Get the id of the share
- *
- * @return string
+ * @inheritdoc
*/
public function getId() {
return $this->id;
@@ -93,30 +88,22 @@ class Share implements IShare {
}
/**
- * Set the path of this share
- *
- * @param Node $path
- * @return IShare The modified object
+ * @inheritdoc
*/
- public function setPath(Node $path) {
+ public function setNode(Node $path) {
$this->path = $path;
return $this;
}
/**
- * Get the path of this share for the current user
- *
- * @return Node
+ * @inheritdoc
*/
- public function getPath() {
+ public function getNode() {
return $this->path;
}
/**
- * Set the shareType
- *
- * @param int $shareType
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setShareType($shareType) {
$this->shareType = $shareType;
@@ -124,19 +111,14 @@ class Share implements IShare {
}
/**
- * Get the shareType
- *
- * @return int
+ * @inheritdoc
*/
public function getShareType() {
return $this->shareType;
}
/**
- * Set the receiver of this share
- *
- * @param IUser|IGroup|string
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setSharedWith($sharedWith) {
$this->sharedWith = $sharedWith;
@@ -144,19 +126,14 @@ class Share implements IShare {
}
/**
- * Get the receiver of this share
- *
- * @return IUser|IGroup|string
+ * @inheritdoc
*/
public function getSharedWith() {
return $this->sharedWith;
}
/**
- * Set the permissions
- *
- * @param int $permissions
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setPermissions($permissions) {
//TODO checkes
@@ -166,19 +143,14 @@ class Share implements IShare {
}
/**
- * Get the share permissions
- *
- * @return int
+ * @inheritdoc
*/
public function getPermissions() {
return $this->permissions;
}
/**
- * Set the expiration date
- *
- * @param \DateTime $expireDate
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setExpirationDate($expireDate) {
//TODO checks
@@ -188,19 +160,14 @@ class Share implements IShare {
}
/**
- * Get the share expiration date
- *
- * @return \DateTime
+ * @inheritdoc
*/
public function getExpirationDate() {
return $this->expireDate;
}
/**
- * Set the sharer of the path
- *
- * @param IUser|string $sharedBy
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setSharedBy($sharedBy) {
//TODO checks
@@ -210,9 +177,7 @@ class Share implements IShare {
}
/**
- * Get share sharer
- *
- * @return IUser|string
+ * @inheritdoc
*/
public function getSharedBy() {
//TODO check if set
@@ -220,11 +185,7 @@ class Share implements IShare {
}
/**
- * Set the original share owner (who owns the path)
- *
- * @param IUser|string
- *
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setShareOwner($shareOwner) {
//TODO checks
@@ -234,9 +195,7 @@ class Share implements IShare {
}
/**
- * Get the original share owner (who owns the path)
- *
- * @return IUser|string
+ * @inheritdoc
*/
public function getShareOwner() {
//TODO check if set
@@ -244,33 +203,22 @@ class Share implements IShare {
}
/**
- * Set the password
- *
- * @param string $password
- *
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setPassword($password) {
- //TODO verify
-
$this->password = $password;
return $this;
}
/**
- * Get the password
- *
- * @return string
+ * @inheritdoc
*/
public function getPassword() {
return $this->password;
}
/**
- * Set the token
- *
- * @param string $token
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setToken($token) {
$this->token = $token;
@@ -278,19 +226,14 @@ class Share implements IShare {
}
/**
- * Get the token
- *
- * @return string
+ * @inheritdoc
*/
public function getToken() {
return $this->token;
}
/**
- * Set the parent id of this share
- *
- * @param int $parent
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setParent($parent) {
$this->parent = $parent;
@@ -298,19 +241,14 @@ class Share implements IShare {
}
/**
- * Get the parent id of this share
- *
- * @return int
+ * @inheritdoc
*/
public function getParent() {
return $this->parent;
}
/**
- * Set the target of this share
- *
- * @param string $target
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setTarget($target) {
$this->target = $target;
@@ -318,39 +256,29 @@ class Share implements IShare {
}
/**
- * Get the target of this share
- *
- * @return string
+ * @inheritdoc
*/
public function getTarget() {
return $this->target;
}
/**
- * Set the time this share was created
- *
- * @param int $shareTime
- * @return IShare The modified object
+ * @inheritdoc
*/
- public function setShareTime($shareTime) {
+ public function setShareTime(\DateTime $shareTime) {
$this->shareTime = $shareTime;
return $this;
}
/**
- * Get the timestamp this share was created
- *
- * @return int
+ * @inheritdoc
*/
- public function getSharetime() {
+ public function getShareTime() {
return $this->shareTime;
}
/**
- * Set mailSend
- *
- * @param bool $mailSend
- * @return IShare The modified object
+ * @inheritdoc
*/
public function setMailSend($mailSend) {
$this->mailSend = $mailSend;
@@ -358,9 +286,7 @@ class Share implements IShare {
}
/**
- * Get mailSend
- *
- * @return bool
+ * @inheritdoc
*/
public function getMailSend() {
return $this->mailSend;
diff --git a/lib/public/files/cache/icache.php b/lib/public/files/cache/icache.php
index 07396db4588..3fbf310148d 100644
--- a/lib/public/files/cache/icache.php
+++ b/lib/public/files/cache/icache.php
@@ -157,13 +157,6 @@ interface ICache {
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath);
/**
- * remove all entries for files that are stored on the storage from the cache
- *
- * @since 9.0.0
- */
- public function clear();
-
- /**
* Get the scan status of a file
*
* - ICache::NOT_FOUND: File is not in the cache
@@ -210,14 +203,6 @@ interface ICache {
public function searchByTag($tag, $userId);
/**
- * get all file ids on the files on the storage
- *
- * @return int[]
- * @since 9.0.0
- */
- public function getAll();
-
- /**
* find a folder in the cache which has not been fully scanned
*
* If multiple incomplete folders are in the cache, the one with the highest id will be returned,
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index e21c9fb8e4b..ce1364cc4ea 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -504,4 +504,12 @@ interface IServerContainer {
* @since 9.0.0
*/
public function getSystemTagObjectMapper();
+
+ /**
+ * Returns the share manager
+ *
+ * @return \OCP\Share\IManager
+ * @since 9.0.0
+ */
+ public function getShareManager();
}
diff --git a/lib/public/share/imanager.php b/lib/public/share/imanager.php
new file mode 100644
index 00000000000..6531c14a857
--- /dev/null
+++ b/lib/public/share/imanager.php
@@ -0,0 +1,212 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Share;
+
+use OCP\IUser;
+
+use OC\Share20\Exception\ShareNotFound;
+
+/**
+ * Interface IManager
+ *
+ * @package OCP\Share
+ * @since 9.0.0
+ */
+interface IManager {
+
+ /**
+ * Create a Share
+ *
+ * @param IShare $share
+ * @return Share The share object
+ * @since 9.0.0
+ */
+ public function createShare(IShare $share);
+
+ /**
+ * Update a share
+ *
+ * @param IShare $share
+ * @return IShare The share object
+ * @since 9.0.0
+ */
+ public function updateShare(IShare $share);
+
+ /**
+ * Delete a share
+ *
+ * @param IShare $share
+ * @throws ShareNotFound
+ * @since 9.0.0
+ */
+ public function deleteShare(IShare $share);
+
+ /**
+ * Unshare a file as the recipient.
+ * This can be different from a regular delete for example when one of
+ * the users in a groups deletes that share. But the provider should
+ * handle this.
+ *
+ * @param IShare $share
+ * @param IUser $recipient
+ * @since 9.0.0
+ */
+ public function deleteFromSelf(IShare $share, IUser $recipient);
+
+ /**
+ * Get shares shared by (initiated) by the provided user.
+ *
+ * @param IUser $user
+ * @param int $shareType
+ * @param \OCP\Files\File|\OCP\Files\Folder $path
+ * @param bool $reshares
+ * @param int $limit The maximum number of returned results, -1 for all results
+ * @param int $offset
+ * @return IShare[]
+ * @since 9.0.0
+ */
+ public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
+
+ /**
+ * Get shares shared with $user.
+ *
+ * @param IUser $user
+ * @param int $shareType
+ * @param int $limit The maximum number of shares returned, -1 for all
+ * @param int $offset
+ * @return IShare[]
+ * @since 9.0.0
+ */
+ public function getSharedWith(IUser $user, $shareType, $limit = 50, $offset = 0);
+
+ /**
+ * Retrieve a share by the share id
+ *
+ * @param string $id
+ * @return Share
+ * @throws ShareNotFound
+ * @since 9.0.0
+ */
+ public function getShareById($id);
+
+ /**
+ * Get the share by token possible with password
+ *
+ * @param string $token
+ * @return Share
+ * @throws ShareNotFound
+ * @since 9.0.0
+ */
+ public function getShareByToken($token);
+
+ /**
+ * Verify the password of a public share
+ *
+ * @param IShare $share
+ * @param string $password
+ * @return bool
+ * @since 9.0.0
+ */
+ public function checkPassword(IShare $share, $password);
+
+ /**
+ * Instantiates a new share object. This is to be passed to
+ * createShare.
+ *
+ * @return IShare
+ * @since 9.0.0
+ */
+ public function newShare();
+
+ /**
+ * Is the share API enabled
+ *
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareApiEnabled();
+
+ /**
+ * Is public link sharing enabled
+ *
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareApiAllowLinks();
+
+ /**
+ * Is password on public link requires
+ *
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareApiLinkEnforcePassword();
+
+ /**
+ * Is default expire date enabled
+ *
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareApiLinkDefaultExpireDate();
+
+ /**
+ * Is default expire date enforced
+ *`
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareApiLinkDefaultExpireDateEnforced();
+
+ /**
+ * Number of default expire days
+ *
+ * @return int
+ * @since 9.0.0
+ */
+ public function shareApiLinkDefaultExpireDays();
+
+ /**
+ * Allow public upload on link shares
+ *
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareApiLinkAllowPublicUpload();
+
+ /**
+ * check if user can only share with group members
+ * @return bool
+ * @since 9.0.0
+ */
+ public function shareWithGroupMembersOnly();
+
+ /**
+ * Check if sharing is disabled for the given user
+ *
+ * @param IUser $user
+ * @return bool
+ * @since 9.0.0
+ */
+ public function sharingDisabledForUser(IUser $user);
+
+}
diff --git a/lib/private/share20/iproviderfactory.php b/lib/public/share/iproviderfactory.php
index b38666978db..3a8baccf33b 100644
--- a/lib/private/share20/iproviderfactory.php
+++ b/lib/public/share/iproviderfactory.php
@@ -18,7 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-namespace OC\Share20;
+
+namespace OCP\Share;
use OC\Share20\Exception\ProviderException;
use OCP\IServerContainer;
@@ -34,6 +35,7 @@ interface IProviderFactory {
/**
* IProviderFactory constructor.
* @param IServerContainer $serverContainer
+ * @since 9.0.0
*/
public function __construct(IServerContainer $serverContainer);
@@ -41,6 +43,7 @@ interface IProviderFactory {
* @param string $id
* @return IShareProvider
* @throws ProviderException
+ * @since 9.0.0
*/
public function getProvider($id);
@@ -48,6 +51,7 @@ interface IProviderFactory {
* @param int $shareType
* @return IShareProvider
* @throws ProviderException
+ * @since 9.0.0
*/
public function getProviderForType($shareType);
}
diff --git a/lib/public/share/ishare.php b/lib/public/share/ishare.php
new file mode 100644
index 00000000000..80e7f7f56ef
--- /dev/null
+++ b/lib/public/share/ishare.php
@@ -0,0 +1,264 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCP\Share;
+
+use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\Files\Node;
+use OCP\IUser;
+use OCP\IGroup;
+
+/**
+ * Interface IShare
+ *
+ * @package OCP\Share
+ * @since 9.0.0
+ */
+interface IShare {
+
+ /**
+ * Get the internal id of the share.
+ *
+ * @return string
+ * @since 9.0.0
+ */
+ public function getId();
+
+ /**
+ * Get the full share id. This is the <providerid>:<internalid>.
+ * The full id is unique in the system.
+ *
+ * @return string
+ * @since 9.0.0
+ */
+ public function getFullId();
+
+ /**
+ * Set the node of the file/folder that is shared
+ *
+ * @param File|Folder $path
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setNode(Node $path);
+
+ /**
+ * Get the node of the file/folder that is shared
+ *
+ * @return File|Folder
+ * @since 9.0.0
+ */
+ public function getNode();
+
+ /**
+ * Set the shareType
+ *
+ * @param int $shareType
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setShareType($shareType);
+
+ /**
+ * Get the shareType
+ *
+ * @return int
+ * @since 9.0.0
+ */
+ public function getShareType();
+
+ /**
+ * Set the receiver of this share.
+ *
+ * @param IUser|IGroup
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setSharedWith($sharedWith);
+
+ /**
+ * Get the receiver of this share.
+ *
+ * @return IUser|IGroup
+ * @since 9.0.0
+ */
+ public function getSharedWith();
+
+ /**
+ * Set the permissions.
+ * See \OCP\Constants::PERMISSION_*
+ *
+ * @param int $permissions
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setPermissions($permissions);
+
+ /**
+ * Get the share permissions
+ * See \OCP\Constants::PERMISSION_*
+ *
+ * @return int
+ * @since 9.0.0
+ */
+ public function getPermissions();
+
+ /**
+ * Set the expiration date
+ *
+ * @param \DateTime $expireDate
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setExpirationDate($expireDate);
+
+ /**
+ * Get the expiration date
+ *
+ * @return \DateTime
+ * @since 9.0.0
+ */
+ public function getExpirationDate();
+
+ /**
+ * Set the sharer of the path.
+ *
+ * @param IUser $sharedBy
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setSharedBy($sharedBy);
+
+ /**
+ * Get share sharer
+ *
+ * @return IUser
+ * @since 9.0.0
+ */
+ public function getSharedBy();
+
+ /**
+ * Set the original share owner (who owns the path that is shared)
+ *
+ * @param IUser
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setShareOwner($shareOwner);
+
+ /**
+ * Get the original share owner (who owns the path that is shared)
+ *
+ * @return IUser
+ * @since 9.0.0
+ */
+ public function getShareOwner();
+
+ /**
+ * Set the password for this share.
+ * When the share is passed to the share manager to be created
+ * or updated the password will be hashed.
+ *
+ * @param string $password
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setPassword($password);
+
+ /**
+ * Get the password of this share.
+ * If this share is obtained via a shareprovider the password is
+ * hashed.
+ *
+ * @return string
+ * @since 9.0.0
+ */
+ public function getPassword();
+
+ /**
+ * Set the public link token.
+ *
+ * @param string $token
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setToken($token);
+
+ /**
+ * Get the public link token.
+ *
+ * @return string
+ * @since 9.0.0
+ */
+ public function getToken();
+
+ /**
+ * Set the target path of this share relative to the recipients user folder.
+ *
+ * @param string $target
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setTarget($target);
+
+ /**
+ * Get the target path of this share relative to the recipients user folder.
+ *
+ * @return string
+ * @since 9.0.0
+ */
+ public function getTarget();
+
+ /**
+ * Set the time this share was created
+ *
+ * @param \DateTime $shareTime
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setShareTime(\DateTime $shareTime);
+
+ /**
+ * Get the timestamp this share was created
+ *
+ * @return \DateTime
+ * @since 9.0.0
+ */
+ public function getShareTime();
+
+ /**
+ * Set if the recipient is informed by mail about the share.
+ *
+ * @param bool $mailSend
+ * @return \OCP\Share\IShare The modified object
+ * @since 9.0.0
+ */
+ public function setMailSend($mailSend);
+
+ /**
+ * Get if the recipient informed by mail about the share.
+ *
+ * @return bool
+ * @since 9.0.0
+ */
+ public function getMailSend();
+}
diff --git a/lib/private/share20/ishareprovider.php b/lib/public/share/ishareprovider.php
index 17ee4abb9a8..50964c88dd6 100644
--- a/lib/private/share20/ishareprovider.php
+++ b/lib/public/share/ishareprovider.php
@@ -18,53 +18,65 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-namespace OC\Share20;
+
+namespace OCP\Share;
use OC\Share20\Exception\ShareNotFound;
use OC\Share20\Exception\BackendError;
use OCP\IUser;
+/**
+ * Interface IShareProvider
+ *
+ * @package OCP\Share
+ * @since 9.0.0
+ */
interface IShareProvider {
/**
* Return the identifier of this provider.
*
* @return string Containing only [a-zA-Z0-9]
+ * @since 9.0.0
*/
public function identifier();
/**
- * Share a path
+ * Create a share
*
- * @param IShare $share
- * @return IShare The share object
+ * @param \OCP\Share\IShare $share
+ * @return \OCP\Share\IShare The share object
+ * @since 9.0.0
*/
- public function create(IShare $share);
+ public function create(\OCP\Share\IShare $share);
/**
* Update a share
*
- * @param IShare $share
- * @return IShare The share object
+ * @param \OCP\Share\IShare $share
+ * @return \OCP\Share\IShare The share object
+ * @since 9.0.0
*/
- public function update(IShare $share);
+ public function update(\OCP\Share\IShare $share);
/**
* Delete a share
*
- * @param IShare $share
- * @throws BackendError
+ * @param \OCP\Share\IShare $share
+ * @since 9.0.0
*/
- public function delete(IShare $share);
+ public function delete(\OCP\Share\IShare $share);
/**
* Unshare a file from self as recipient.
- * This may require special handling.
+ * This may require special handling. If a user unshares a group
+ * share from their self then the original group share should still exist.
*
- * @param IShare $share
+ * @param \OCP\Share\IShare $share
* @param IUser $recipient
+ * @since 9.0.0
*/
- public function deleteFromSelf(IShare $share, IUser $recipient);
+ public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient);
/**
* Get all shares by the given user
@@ -75,7 +87,8 @@ interface IShareProvider {
* @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
* @param int $limit The maximum number of shares to be returned, -1 for all shares
* @param int $offset
- * @return Share[]
+ * @return \OCP\Share\I Share[]
+ * @since 9.0.0
*/
public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset);
@@ -83,24 +96,18 @@ interface IShareProvider {
* Get share by id
*
* @param int $id
- * @return IShare
+ * @return \OCP\Share\IShare
* @throws ShareNotFound
+ * @since 9.0.0
*/
public function getShareById($id);
/**
- * Get children
- *
- * @param IShare $parent
- * @return IShare[]
- */
- public function getChildren(IShare $parent);
-
- /**
* Get shares for a given path
*
* @param \OCP\Files\Node $path
- * @return IShare[]
+ * @return \OCP\Share\IShare[]
+ * @since 9.0.0
*/
public function getSharesByPath(\OCP\Files\Node $path);
@@ -111,7 +118,8 @@ interface IShareProvider {
* @param int $shareType
* @param int $limit The max number of entries returned, -1 for all
* @param int $offset
- * @param Share
+ * @return \OCP\Share\IShare[]
+ * @since 9.0.0
*/
public function getSharedWith(IUser $user, $shareType, $limit, $offset);
@@ -119,8 +127,9 @@ interface IShareProvider {
* Get a share by token
*
* @param string $token
- * @return IShare
+ * @return \OCP\Share\IShare
* @throws ShareNotFound
+ * @since 9.0.0
*/
public function getShareByToken($token);
}