diff --git a/lib/Service/RegistrationService.php b/lib/Service/RegistrationService.php index 1a14a09..c6de94e 100644 --- a/lib/Service/RegistrationService.php +++ b/lib/Service/RegistrationService.php @@ -57,6 +57,10 @@ use \OCP\IConfig; use \OCP\Security\ISecureRandom; use Psr\Log\LoggerInterface; +// DEFAULT GROUP DIRs with Permissions! +use OCP\IDBConnection; +use OCA\GroupFolders\Folder\FolderManager; + class RegistrationService { /** @var string */ @@ -91,6 +95,12 @@ class RegistrationService { private $tokenProvider; /** @var ICrypto */ private $crypto; + + /** @var IDBConnection */ + private $connection; + + + public function __construct( string $appName, @@ -104,11 +114,12 @@ class RegistrationService { IGroupManager $groupManager, ISecureRandom $random, IUserSession $userSession, - IRequest $request, LoggerInterface $logger, ISession $session, IProvider $tokenProvider, - ICrypto $crypto + ICrypto $crypto, + IRequest $request, + IDBConnection $connection ) { $this->appName = $appName; $this->mailService = $mailService; @@ -126,6 +137,7 @@ class RegistrationService { $this->session = $session; $this->tokenProvider = $tokenProvider; $this->crypto = $crypto; + $this->connection = $connection; } public function confirmEmail(Registration $registration): void { @@ -436,10 +448,21 @@ class RegistrationService { $groupidfree = true; } } - + $newgroup = $this->groupManager->createGroup($newgid.$newgid_counter); $newgroup->addUser($user); + // Create two new Directorys for that agency + $folderManager = new FolderManager($this->connection, $this->groupManager); + // Main-Dir for complete Agency + $newFolderId = $folderManager->createFolder('Agenturdaten'); + $folderManager->addApplicableGroup($newFolderId, $newgroup->getGId()); + $folderManager->setGroupPermissions($newFolderId, $newgroup->getGId(), '31'); + + // Upload-Standard-Directory + $newFolderId = $folderManager->createFolder('Standard Uploadbereich'); + $folderManager->addApplicableGroup($newFolderId, $newgroup->getGId()); + $folderManager->setGroupPermissions($newFolderId, $newgroup->getGId(), '31'); // disable user if this is requested by config $adminApprovalRequired = $this->config->getAppValue($this->appName, 'admin_approval_required', 'no');