/**
  * Retrieves system tag properties
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if (!$node instanceof SystemTagNode && !$node instanceof SystemTagMappingNode) {
         return;
     }
     $propFind->handle(self::ID_PROPERTYNAME, function () use($node) {
         return $node->getSystemTag()->getId();
     });
     $propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use($node) {
         return $node->getSystemTag()->getName();
     });
     $propFind->handle(self::USERVISIBLE_PROPERTYNAME, function () use($node) {
         return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
     });
     $propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function () use($node) {
         // this is the tag's inherent property "is user assignable"
         return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
     });
     $propFind->handle(self::CANASSIGN_PROPERTYNAME, function () use($node) {
         // this is the effective permission for the current user
         return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
     });
     $propFind->handle(self::GROUPS_PROPERTYNAME, function () use($node) {
         if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
             // property only available for admins
             throw new Forbidden();
         }
         $groups = [];
         // no need to retrieve groups for namespaces that don't qualify
         if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
             $groups = $this->tagManager->getTagGroups($node->getSystemTag());
         }
         return implode('|', $groups);
     });
 }
 public function testTagGroups()
 {
     $tag1 = $this->tagManager->createTag('tag1', true, false);
     $tag2 = $this->tagManager->createTag('tag2', true, false);
     $this->tagManager->setTagGroups($tag1, ['group1', 'group2']);
     $this->tagManager->setTagGroups($tag2, ['group2', 'group3']);
     $this->assertEquals(['group1', 'group2'], $this->tagManager->getTagGroups($tag1));
     $this->assertEquals(['group2', 'group3'], $this->tagManager->getTagGroups($tag2));
     // change groups
     $this->tagManager->setTagGroups($tag1, ['group3', 'group4']);
     $this->tagManager->setTagGroups($tag2, []);
     $this->assertEquals(['group3', 'group4'], $this->tagManager->getTagGroups($tag1));
     $this->assertEquals([], $this->tagManager->getTagGroups($tag2));
 }