public function cacheNode(Node $node) { $this->cache[trim($node->getPath(), '/')] = $node; }
/** * Update properties * * @param Node $node node for which to update properties * @param array $properties array of properties to update * * @return bool */ private function updateProperties($node, $properties) { $path = $node->getPath(); $deleteStatement = 'DELETE FROM `*PREFIX*properties`' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; $insertStatement = 'INSERT INTO `*PREFIX*properties`' . ' (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)'; $updateStatement = 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?' . ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; // TODO: use "insert or update" strategy ? $existing = $this->getProperties($node, array()); $this->connection->beginTransaction(); foreach ($properties as $propertyName => $propertyValue) { // If it was null, we need to delete the property if (is_null($propertyValue)) { if (array_key_exists($propertyName, $existing)) { $this->connection->executeUpdate($deleteStatement, array($this->user, $path, $propertyName)); } } else { if (!array_key_exists($propertyName, $existing)) { $this->connection->executeUpdate($insertStatement, array($this->user, $path, $propertyName, $propertyValue)); } else { $this->connection->executeUpdate($updateStatement, array($propertyValue, $this->user, $path, $propertyName)); } } } $this->connection->commit(); unset($this->cache[$path]); return true; }
/** * Find Sabre nodes by file ids * * @param Node $rootNode root node for search * @param array $fileIds file ids * @return Node[] array of Sabre nodes */ public function findNodesByFileIds($rootNode, $fileIds) { $folder = $this->userFolder; if (trim($rootNode->getPath(), '/') !== '') { $folder = $folder->get($rootNode->getPath()); } $results = []; foreach ($fileIds as $fileId) { $entry = $folder->getById($fileId); if ($entry) { $entry = current($entry); if ($entry instanceof \OCP\Files\File) { $results[] = new File($this->fileView, $entry); } else { if ($entry instanceof \OCP\Files\Folder) { $results[] = new Directory($this->fileView, $entry); } } } } return $results; }
/** * returns the number of unread comments for the currently logged in user * on the given file or directory node * * @param Node $node * @return Int|null */ public function getUnreadCount(Node $node) { $user = $this->userSession->getUser(); if (is_null($user)) { return null; } $lastRead = $this->commentsManager->getReadMark('files', strval($node->getId()), $user); return $this->commentsManager->getNumberOfCommentsForObject('files', strval($node->getId()), $lastRead); }
/** * Sets up the node, expects a full path name * * @param \OC\Files\View $view * @param \OCP\Files\FileInfo $info * @param ObjectTree|null $tree * @param \OCP\Share\IManager $shareManager */ public function __construct($view, $info, $tree = null, $shareManager = null) { parent::__construct($view, $info, $shareManager); $this->tree = $tree; }
/** * Sets up the node, expects a full path name * * @param \OC\Files\View $view * @param \OCP\Files\FileInfo $info * @param ObjectTree|null $tree */ public function __construct($view, $info, $tree = null) { parent::__construct($view, $info); $this->tree = $tree; }