}
$qb = $this->dbConnection->getQueryBuilder();
- $qb->select('share_with', 'token', 'file_source', 'file_target')
+ $qb->select('share_with', 'token', 'file_source')
->from('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)))
->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)))
while ($row = $cursor->fetch()) {
$remote[$row['share_with']] = [
'node_id' => $row['file_source'],
- 'node_path' => $row['file_target'],
'token' => $row['token'],
];
}
/**
* @param Node $node
- * @return array [ users => [Mapping $uid => $path], remotes => [Mapping $cloudId => $path]]
+ * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
*/
public function getPathsForAccessList(Node $node) {
$result = [
$byId[$info['node_id']][$cloudId] = $info['token'];
}
- if (isset($byId[$node->getId()])) {
- foreach ($byId[$node->getId()] as $cloudId => $token) {
- $results[$cloudId] = [
- 'node_path' => '/' . $node->getName(),
- 'token' => $token,
- ];
- }
- unset($byId[$node->getId()]);
- }
-
- if (empty($byId)) {
- return $results;
- }
-
$item = $node;
- $path = '/' . $node->getName();
while (!empty($byId)) {
- $item = $item->getParent();
-
if (!empty($byId[$item->getId()])) {
+ $path = $this->getMountedPath($item);
foreach ($byId[$item->getId()] as $uid => $token) {
$results[$uid] = [
'node_path' => $path,
}
unset($byId[$item->getId()]);
}
-
- $path = '/' . $item->getName() . $path;
+ $item = $item->getParent();
}
return $results;
}
+
+ protected function getMountedPath(Node $node) {
+ $path = $node->getPath();
+ $sections = explode('/', $path, 4);
+ return '/' . $sections[3];
+ }
}
* Then the access list will to '/folder1/folder2/fileA' is:
* [
* users => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
- * remote => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
+ * remote => ['user1' => ['node_id' => 42, 'token' => 'ShareToken'], 'user2' => [...]],
* public => bool
* mail => bool
* ]
/**
* @param Node $node
- * @return array [ users => [Mapping $uid => $path], remotes => [Mapping $cloudId => $path]]
+ * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
* @since 12
*/
public function getPathsForAccessList(Node $node);
*
* [
* users => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
- * remote => ['user1' => ['node_id' => 42, 'node_path' => '/path'], 'user2' => [...]],
+ * remote => ['user1' => ['node_id' => 42, 'token' => 'ShareToken'], 'user2' => [...]],
* mail => bool
* public => bool
* ]