Skip to content

Commit

Permalink
feature(): Add groups managers of a Groupfolder
Browse files Browse the repository at this point in the history
I added the groups/users managers of a groupfolder.
I updated the groupfolder to 9.2.0.

Signed-off-by: Baptiste Fotia <[email protected]>
  • Loading branch information
zak39 committed Dec 20, 2022
1 parent 4fd01f4 commit 399cff3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 9.2.0


### Add

- Add the groups/users that manage the groupfolder.

## 9.1.0

### Add
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Folders can be configured from *Group folders* in the admin settings.
After a folder is created, the admin can give access to the folder to one or more groups, control their write/sharing permissions and assign a quota for the folder.
Note: encrypting the contents of group folders is currently not supported.]]></description>
<version>9.1.1</version>
<version>9.2.0</version>
<licence>agpl</licence>
<author>Robin Appelman</author>
<namespace>GroupFolders</namespace>
Expand Down
21 changes: 19 additions & 2 deletions lib/Folder/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,22 @@ private function getAllFolderMappings(): array {
return $folderMap;
}

private function getManageAcl($mappings): array {
/**
* @return array[]
*
* @psalm-return array<int, list<mixed>>
* @throws Exception
*/
private function getFolderMappings(int $id): array {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('group_folders_manage')
->where($query->expr()->eq('folder_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));

return $query->executeQuery()->fetchAll();
}

private function getManageAcl(array $mappings): array {
return array_filter(array_map(function ($entry) {
if ($entry['mapping_type'] === 'user') {
$user = \OC::$server->getUserManager()->get($entry['mapping_id']);
Expand Down Expand Up @@ -211,13 +226,15 @@ public function getFolder($id, $rootStorageId) {
$row = $result->fetch();
$result->closeCursor();

$folderMappings = $this->getFolderMappings($id);
return $row ? [
'id' => (int)$id,
'mount_point' => $row['mount_point'],
'groups' => isset($applicableMap[$id]) ? $applicableMap[$id] : [],
'quota' => $row['quota'],
'size' => $row['size'] ? $row['size'] : 0,
'acl' => (bool)$row['acl']
'acl' => (bool)$row['acl'],
'manage' => $this->getManageAcl($folderMappings)
] : false;
}

Expand Down

0 comments on commit 399cff3

Please sign in to comment.