aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/SystemTag
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-05-24 15:23:50 +0200
committerJoas Schilling <coding@schilljs.com>2016-07-18 10:26:36 +0200
commit8e13ff2c8621efc2640ff1fcd2c2b58391b09f6c (patch)
tree770f5a144c33b6267d404a7149a18b92b3ee09fa /apps/dav/lib/SystemTag
parent5157c5a9c4b08518dc86e5755b991183f4323c43 (diff)
downloadnextcloud-server-8e13ff2c8621efc2640ff1fcd2c2b58391b09f6c.tar.gz
nextcloud-server-8e13ff2c8621efc2640ff1fcd2c2b58391b09f6c.zip
Fix TODO and bring in abstraction (similar to comments)
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);
+ }
),
];