コード例 #1
0
 /**
  * Adds tags and favorites properties to the response,
  * if requested.
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if (!$node instanceof File && !$node instanceof Directory) {
         return;
     }
     $propFind->handle(self::PROPERTY_NAME_COUNT, function () use($node) {
         return $this->commentsManager->getNumberOfCommentsForObject('files', strval($node->getId()));
     });
     $propFind->handle(self::PROPERTY_NAME_HREF, function () use($node) {
         return $this->getCommentsLink($node);
     });
     $propFind->handle(self::PROPERTY_NAME_UNREAD, function () use($node) {
         return $this->getUnreadCount($node);
     });
 }
コード例 #2
0
ファイル: tagsplugin.php プロジェクト: kenwi/core
 /**
  * Adds tags and favorites properties to the response,
  * if requested.
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if (!$node instanceof \OCA\DAV\Connector\Sabre\Node) {
         return;
     }
     // need prefetch ?
     if ($node instanceof \OCA\DAV\Connector\Sabre\Directory && $propFind->getDepth() !== 0 && (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME)) || !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME)))) {
         // note: pre-fetching only supported for depth <= 1
         $folderContent = $node->getChildren();
         $fileIds[] = (int) $node->getId();
         foreach ($folderContent as $info) {
             $fileIds[] = (int) $info->getId();
         }
         $tags = $this->getTagger()->getTagsForObjects($fileIds);
         if ($tags === false) {
             // the tags API returns false on error...
             $tags = array();
         }
         $this->cachedTags = $this->cachedTags + $tags;
         $emptyFileIds = array_diff($fileIds, array_keys($tags));
         // also cache the ones that were not found
         foreach ($emptyFileIds as $fileId) {
             $this->cachedTags[$fileId] = [];
         }
     }
     $tags = null;
     $isFav = null;
     $propFind->handle(self::TAGS_PROPERTYNAME, function () use($tags, &$isFav, $node) {
         list($tags, $isFav) = $this->getTagsAndFav($node->getId());
         return new TagList($tags);
     });
     $propFind->handle(self::FAVORITE_PROPERTYNAME, function () use($isFav, $node) {
         if (is_null($isFav)) {
             list(, $isFav) = $this->getTagsAndFav($node->getId());
         }
         return $isFav;
     });
 }
コード例 #3
0
 /**
  * Updates tags and favorites properties, if applicable.
  *
  * @param string $path
  * @param \Sabre\DAV\INode $node
  * @param array $requestedProperties
  * @param array $returnedProperties
  * @return bool success status
  */
 public function updateProperties(array &$properties, array &$result, \Sabre\DAV\INode $node)
 {
     if (!$node instanceof \OC_Connector_Sabre_Node) {
         return;
     }
     $fileId = $node->getId();
     if (isset($properties[self::TAGS_PROPERTYNAME])) {
         $tagsProp = $properties[self::TAGS_PROPERTYNAME];
         unset($properties[self::TAGS_PROPERTYNAME]);
         $this->updateTags($fileId, $tagsProp->getTags());
         $result[200][self::TAGS_PROPERTYNAME] = new TagList($tagsProp->getTags());
     }
     if (isset($properties[self::FAVORITE_PROPERTYNAME])) {
         $favState = $properties[self::FAVORITE_PROPERTYNAME];
         unset($properties[self::FAVORITE_PROPERTYNAME]);
         if ((int) $favState === 1 || $favState === 'true') {
             $favState = true;
             $this->getTagger()->tagAs($fileId, self::TAG_FAVORITE);
         } else {
             $favState = false;
             $this->getTagger()->unTag($fileId, self::TAG_FAVORITE);
         }
         $result[200][self::FAVORITE_PROPERTYNAME] = $favState;
     }
     return true;
 }
コード例 #4
0
ファイル: SharesPlugin.php プロジェクト: GitHubUser4234/core
 /**
  * Adds shares to propfind response
  *
  * @param PropFind $propFind propfind object
  * @param \Sabre\DAV\INode $sabreNode sabre node
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $sabreNode)
 {
     if (!$sabreNode instanceof \OCA\DAV\Connector\Sabre\Node) {
         return;
     }
     // need prefetch ?
     if ($sabreNode instanceof \OCA\DAV\Connector\Sabre\Directory && $propFind->getDepth() !== 0 && !is_null($propFind->getStatus(self::SHARETYPES_PROPERTYNAME))) {
         $folderNode = $this->userFolder->get($propFind->getPath());
         $children = $folderNode->getDirectoryListing();
         $this->cachedShareTypes[$folderNode->getId()] = $this->getShareTypes($folderNode);
         foreach ($children as $childNode) {
             $this->cachedShareTypes[$childNode->getId()] = $this->getShareTypes($childNode);
         }
     }
     $propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use($sabreNode) {
         if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
             $shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
         } else {
             $node = $this->userFolder->get($sabreNode->getPath());
             $shareTypes = $this->getShareTypes($node);
         }
         return new ShareTypeList($shareTypes);
     });
 }