Beispiel #1
0
 /**
  * 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) {
         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 (int) $node->getSystemTag()->isUserVisible();
     });
     $propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function () use($node) {
         return (int) $node->getSystemTag()->isUserAssignable();
     });
 }
 /**
  * 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);
     });
 }