diff --git a/appinfo/info.xml b/appinfo/info.xml index a379e3a..954540f 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,6 +27,7 @@ OCA\OrganizationFolders\Command\OrganizationFolder\FixACLsOfOrganizationFolder OCA\OrganizationFolders\Command\Resource\CreateResource OCA\OrganizationFolders\Command\Resource\ListResources + OCA\OrganizationFolders\Command\Resource\UpdateResource OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember OCA\OrganizationFolders\Command\ResourceMember\ListResourceMembers OCA\OrganizationFolders\Command\OrganizationProvider\ListOrganizationProviders diff --git a/lib/Command/Resource/UpdateResource.php b/lib/Command/Resource/UpdateResource.php new file mode 100644 index 0000000..21efa0e --- /dev/null +++ b/lib/Command/Resource/UpdateResource.php @@ -0,0 +1,55 @@ +setName('organization-folders:update-resource') + ->setDescription('Update a resource') + ->addArgument('id', InputArgument::REQUIRED, 'Id of the resource to update') + ->addOption('name', null, InputOption::VALUE_OPTIONAL, 'New name of resource'); + + // folder type options + $this + ->addOption('members-acl-permission', null, InputOption::VALUE_OPTIONAL, 'New acl permissions for members of resource') + ->addOption('managers-acl-permission', null, InputOption::VALUE_OPTIONAL, 'New acl permissions for managers of resource') + ->addOption('inherited-acl-permission', null, InputOption::VALUE_OPTIONAL, 'New acl permissions for users with access to the resource level above (or organization in case resource is top-level)'); + + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $id = $input->getArgument('id'); + $name = $input->getOption('name'); + + $membersAclPermission = $input->getOption('members-acl-permission'); + $managersAclPermission = $input->getOption('managers-acl-permission'); + $inheritedAclPermission = $input->getOption('inherited-acl-permission'); + + try { + $resource = $this->resourceService->update( + id: $id, + name: $name, + + membersAclPermission: $membersAclPermission, + managersAclPermission: $managersAclPermission, + inheritedAclPermission: $inheritedAclPermission, + ); + + $this->writeTableInOutputFormat($input, $output, [$this->formatTableSerializable($resource)]); + return 0; + } catch (Exception $e) { + $output->writeln("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}"); + return 1; + } + } +}