diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-25 15:25:50 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-25 15:25:50 +0100 |
commit | 9ec2f8886e129d87f58baacfbb625d8ef9d4e58c (patch) | |
tree | c57c58e881e913bc0e37c2436594b46ddf613344 /lib | |
parent | afe76840f8806e5fbbdf785cfa8b8857c57c702e (diff) | |
parent | 8d309767d7a48a7fe1dd23fd79bc827c29f94931 (diff) | |
download | nextcloud-server-9ec2f8886e129d87f58baacfbb625d8ef9d4e58c.tar.gz nextcloud-server-9ec2f8886e129d87f58baacfbb625d8ef9d4e58c.zip |
Merge pull request #20691 from owncloud/share2.0_di_fixes
[Sharing 2.0] di fixes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/share20/defaultshareprovider.php | 71 | ||||
-rw-r--r-- | lib/private/share20/ishare.php | 2 | ||||
-rw-r--r-- | lib/private/share20/ishareprovider.php | 12 | ||||
-rw-r--r-- | lib/private/share20/manager.php | 60 | ||||
-rw-r--r-- | lib/private/share20/share.php | 4 |
5 files changed, 64 insertions, 85 deletions
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php index 5805e41d411..bc3bc0ce9ed 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/share20/defaultshareprovider.php @@ -23,49 +23,61 @@ namespace OC\Share20; use OC\Share20\Exception\ShareNotFound; use OC\Share20\Exception\BackendError; use OCP\IUser; +use OCP\IGroupManager; +use OCP\IUserManager; +use OCP\Files\IRootFolder; +use OCP\IDBConnection; +use OCP\Files\Node; class DefaultShareProvider implements IShareProvider { - /** @var \OCP\IDBConnection */ + /** @var IDBConnection */ private $dbConn; - /** @var \OCP\IUserManager */ + /** @var IUserManager */ private $userManager; - /** @var \OCP\IGroupManager */ + /** @var IGroupManager */ private $groupManager; - /** @var \OCP\Files\Folder */ - private $userFolder; + /** @var IRootFolder */ + private $rootFolder; - public function __construct(\OCP\IDBConnection $connection, - \OCP\IUserManager $userManager, - \OCP\IGroupManager $groupManager, - \OCP\Files\Folder $userFolder) { + /** + * DefaultShareProvider constructor. + * + * @param IDBConnection $connection + * @param IUserManager $userManager + * @param IGroupManager $groupManager + * @param IRootFolder $rootFolder + */ + public function __construct( + IDBConnection $connection, + IUserManager $userManager, + IGroupManager $groupManager, + IRootFolder $rootFolder) { $this->dbConn = $connection; $this->userManager = $userManager; $this->groupManager = $groupManager; - $this->userFolder = $userFolder; + $this->rootFolder = $rootFolder; } /** * Share a path * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function create(Share $share) { - throw new \Exception(); + public function create(IShare $share) { } /** * Update a share * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function update(Share $share) { - throw new \Exception(); + public function update(IShare $share) { } /** @@ -125,7 +137,6 @@ class DefaultShareProvider implements IShareProvider { * @return Share[] */ public function getShares(IUser $user, $shareType, $offset, $limit) { - throw new \Exception(); } /** @@ -163,8 +174,7 @@ class DefaultShareProvider implements IShareProvider { * @param \OCP\Files\Node $path * @return IShare[] */ - public function getSharesByPath(\OCP\IUser $user, \OCP\Files\Node $path) { - throw new \Exception(); + public function getSharesByPath(IUser $user, Node $path) { } /** @@ -175,7 +185,6 @@ class DefaultShareProvider implements IShareProvider { * @param Share */ public function getSharedWithMe(IUser $user, $shareType = null) { - throw new \Exception(); } /** @@ -186,7 +195,6 @@ class DefaultShareProvider implements IShareProvider { * @param Share */ public function getShareByToken($token, $password = null) { - throw new \Exception(); } /** @@ -218,14 +226,14 @@ class DefaultShareProvider implements IShareProvider { $share->setSharedBy($this->userManager->get($data['uid_owner'])); // TODO: getById can return an array. How to handle this properly?? - $path = $this->userFolder->getById((int)$data['file_source']); - $path = $path[0]; - $share->setPath($path); + $folder = $this->rootFolder->getUserFolder($share->getSharedBy()->getUID()); + $path = $folder->getById((int)$data['file_source'])[0]; - $owner = $path->getStorage()->getOwner('.'); - if ($owner !== false) { - $share->setShareOwner($this->userManager->get($owner)); - } + $owner = $path->getOwner(); + $share->setShareOwner($owner); + + $path = $this->rootFolder->getUserFolder($owner->getUID())->getById((int)$data['file_source'])[0]; + $share->setPath($path); if ($data['expiration'] !== null) { $expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']); @@ -235,5 +243,4 @@ class DefaultShareProvider implements IShareProvider { return $share; } - -} +}
\ No newline at end of file diff --git a/lib/private/share20/ishare.php b/lib/private/share20/ishare.php index a80abebd71c..2e54da7a029 100644 --- a/lib/private/share20/ishare.php +++ b/lib/private/share20/ishare.php @@ -38,7 +38,7 @@ interface IShare { /** * Set the path of this share * - * @param File|Folder $path + * @param Node $path * @return Share The modified object */ public function setPath(Node $path); diff --git a/lib/private/share20/ishareprovider.php b/lib/private/share20/ishareprovider.php index 833de1b58f6..56a550acf71 100644 --- a/lib/private/share20/ishareprovider.php +++ b/lib/private/share20/ishareprovider.php @@ -29,18 +29,18 @@ interface IShareProvider { /** * Share a path * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function create(Share $share); + public function create(IShare $share); /** * Update a share * - * @param Share $share - * @return Share The share object + * @param IShare $share + * @return IShare The share object */ - public function update(Share $share); + public function update(IShare $share); /** * Delete a share diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 57d84967977..882b281c490 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -22,11 +22,7 @@ namespace OC\Share20; use OCP\IAppConfig; -use OCP\IUserManager; -use OCP\IGroupManager; -use OCP\IUser; use OCP\ILogger; -use OCP\Files\Folder; use OC\Share20\Exception\ShareNotFound; @@ -40,37 +36,26 @@ class Manager { */ private $defaultProvider; - /** @var IUser */ - private $currentUser; - - /** @var IUserManager */ - private $userManager; - - /** @var IGroupManager */ - private $groupManager; - /** @var ILogger */ private $logger; /** @var IAppConfig */ private $appConfig; - /** @var IFolder */ - private $userFolder; - - public function __construct(IUser $user, - IUserManager $userManager, - IGroupManager $groupManager, - ILogger $logger, - IAppConfig $appConfig, - Folder $userFolder, - IShareProvider $defaultProvider) { - $this->currentUser = $user; - $this->userManager = $userManager; - $this->groupManager = $groupManager; + /** + * Manager constructor. + * + * @param ILogger $logger + * @param IAppConfig $appConfig + * @param IShareProvider $defaultProvider + */ + public function __construct( + ILogger $logger, + IAppConfig $appConfig, + IShareProvider $defaultProvider + ) { $this->logger = $logger; $this->appConfig = $appConfig; - $this->userFolder = $userFolder; // TEMP SOLUTION JUST TO GET STARTED $this->defaultProvider = $defaultProvider; @@ -78,12 +63,11 @@ class Manager { /** * Share a path - * + * * @param Share $share * @return Share The share object */ public function createShare(Share $share) { - throw new \Exception(); } /** @@ -93,7 +77,6 @@ class Manager { * @return Share The share object */ public function updateShare(Share $share) { - throw new \Exception(); } /** @@ -118,7 +101,7 @@ class Manager { /** * Delete a share * - * @param Share $share + * @param IShare $share * @throws ShareNotFound * @throws \OC\Share20\Exception\BackendError */ @@ -126,7 +109,7 @@ class Manager { // Just to make sure we have all the info $share = $this->getShareById($share->getId()); - $formatHookParams = function($share) { + $formatHookParams = function(IShare $share) { // Prepare hook $shareType = $share->getShareType(); $sharedWith = ''; @@ -185,7 +168,6 @@ class Manager { * @return Share[] */ public function getShares($page=0, $perPage=50) { - throw new \Exception(); } /** @@ -203,12 +185,6 @@ class Manager { $share = $this->defaultProvider->getShareById($id); - if ($share->getSharedWith() !== $this->currentUser && - $share->getSharedBy() !== $this->currentUser && - $share->getShareOwner() !== $this->currentUser) { - throw new ShareNotFound(); - } - return $share; } @@ -222,7 +198,6 @@ class Manager { * @return Share[] */ public function getSharesByPath(\OCP\Files\Node $path, $page=0, $perPage=50) { - throw new \Exception(); } /** @@ -235,7 +210,6 @@ class Manager { * @return Share[] */ public function getSharedWithMe($shareType = null, $page=0, $perPage=50) { - throw new \Exception(); } /** @@ -246,10 +220,9 @@ class Manager { * * @return Share * - * @throws ShareNotFoundException + * @throws ShareNotFound */ public function getShareByToken($token, $password=null) { - throw new \Exception(); } /** @@ -277,6 +250,5 @@ class Manager { * @param \OCP\Files\Node $path */ public function getAccessList(\OCP\Files\Node $path) { - throw new \Exception(); } } diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php index 4200816799e..b7ce38ac61d 100644 --- a/lib/private/share20/share.php +++ b/lib/private/share20/share.php @@ -58,7 +58,7 @@ class Share implements IShare { /** * Set the id of the share * - * @param int id + * @param string $id * @return Share The modified object */ public function setId($id) { @@ -292,7 +292,7 @@ class Share implements IShare { /** * Set the target of this share * - * @param string target + * @param string $target * @return Share The modified object */ public function setTarget($target) { |