aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/SystemTag
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/SystemTag')
-rw-r--r--apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php23
-rw-r--r--apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php10
2 files changed, 14 insertions, 19 deletions
diff --git a/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php b/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php
index ae4b9d51a1b..ba5b3e1185b 100644
--- a/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php
+++ b/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php
@@ -31,7 +31,6 @@ use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\IUserSession;
use OCP\IGroupManager;
-use OCP\Files\IRootFolder;
/**
* Collection containing object ids by object type
@@ -64,9 +63,9 @@ class SystemTagsObjectTypeCollection implements ICollection {
private $userSession;
/**
- * @var IRootFolder
+ * @var \Closure
**/
- protected $fileRoot;
+ protected $childExistsFunction;
/**
* Constructor
@@ -76,7 +75,7 @@ class SystemTagsObjectTypeCollection implements ICollection {
* @param ISystemTagObjectMapper $tagMapper
* @param IUserSession $userSession
* @param IGroupManager $groupManager
- * @param IRootFolder $fileRoot
+ * @param \Closure $childExistsFunction
*/
public function __construct(
$objectType,
@@ -84,14 +83,14 @@ class SystemTagsObjectTypeCollection implements ICollection {
ISystemTagObjectMapper $tagMapper,
IUserSession $userSession,
IGroupManager $groupManager,
- IRootFolder $fileRoot
+ \Closure $childExistsFunction
) {
$this->tagManager = $tagManager;
$this->tagMapper = $tagMapper;
$this->objectType = $objectType;
$this->userSession = $userSession;
$this->groupManager = $groupManager;
- $this->fileRoot = $fileRoot;
+ $this->childExistsFunction = $childExistsFunction;
}
/**
@@ -133,17 +132,13 @@ class SystemTagsObjectTypeCollection implements ICollection {
}
/**
+ * Checks if a child-node with the specified name exists
+ *
* @param string $name
+ * @return bool
*/
function childExists($name) {
- // TODO: make this more abstract
- if ($this->objectType === 'files') {
- // make sure the object is reachable for the current user
- $userId = $this->userSession->getUser()->getUID();
- $nodes = $this->fileRoot->getUserFolder($userId)->getById(intval($name));
- return !empty($nodes);
- }
- return true;
+ return call_user_func($this->childExistsFunction, $name);
}
function delete() {
diff --git a/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php b/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php
index 19db39d3f3a..b09f95ccd65 100644
--- a/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php
+++ b/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php
@@ -29,7 +29,6 @@ use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\SimpleCollection;
use OCP\IUserSession;
use OCP\IGroupManager;
-use OCP\Files\IRootFolder;
class SystemTagsRelationsCollection extends SimpleCollection {
@@ -40,14 +39,12 @@ class SystemTagsRelationsCollection extends SimpleCollection {
* @param ISystemTagObjectMapper $tagMapper
* @param IUserSession $userSession
* @param IGroupManager $groupManager
- * @param IRootFolder $fileRoot
*/
public function __construct(
ISystemTagManager $tagManager,
ISystemTagObjectMapper $tagMapper,
IUserSession $userSession,
- IGroupManager $groupManager,
- IRootFolder $fileRoot
+ IGroupManager $groupManager
) {
$children = [
new SystemTagsObjectTypeCollection(
@@ -56,7 +53,10 @@ class SystemTagsRelationsCollection extends SimpleCollection {
$tagMapper,
$userSession,
$groupManager,
- $fileRoot
+ function($name) {
+ $nodes = \OC::$server->getUserFolder()->getById(intval($name));
+ return !empty($nodes);
+ }
),
];