idNextcloud = $UserId; $this->myDb = $myDb; $this->urlGenerator = $urlGenerator; $this->mailer = $mailer; $this->config = $config; $this->navigationService = $navigationService; $this->configurationService = $configurationService; $this->logger = $logger; $this->providerService = $providerService; $this->providerStatisticService = $providerStatisticService; $this->gestionService = $gestionService; if ($userSession->isLoggedIn()) { $this->user = $userSession->getUser(); } if ($this->user != null) { $groups = $groupManager->getUserGroups($this->user); $this->groups = []; foreach ($groups as $group) { $this->groups[] = $group->getGID(); } } try { $this->storage = $rootFolder->getUserFolder($this->idNextcloud); } catch (\OC\User\NoUserException $e) { } } /** * @NoAdminRequired * @NoCSRFRequired */ public function provider() { return new TemplateResponse('gestion', 'provider', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); } /** * @NoAdminRequired * @NoCSRFRequired */ public function getProviders() { $providers = $this->providerService->getProvidersAsArray(); return json_encode($providers); } /** * @NoAdminRequired * @NoCSRFRequired */ public function createDefaultProvider() { try { $this->providerService->createDefaultProvider($this->idNextcloud); return true; } catch (Exception $e) { return null; } } /** * @NoAdminRequired * @NoCSRFRequired */ public function exportProvidersStatistic(array $providerIds, $year) { try { $filenames = $this->providerStatisticService->exportProvidersStatisticByYear($providerIds, $year, $this->idNextcloud); return $filenames; } catch (Exception $e) { return []; } } /** * @NoAdminRequired * @NoCSRFRequired */ public function moveAttachmentFile() { $tex = "BEGIN:VCALENDAR PRODID:-//IDN nextcloud.com//Calendar app 4.7.16//EN CALSCALE:GREGORIAN VERSION:2.0 BEGIN:VEVENT CREATED:20250319T070401Z DTSTAMP:20250319T070538Z LAST-MODIFIED:20250319T070538Z SEQUENCE:2 UID:dc3ebd49-74c6-490a-afd2-2b61ef47c6f3 DTSTART;TZID=Africa/Nairobi:20250319T110001 DTEND;TZID=Africa/Nairobi:20250319T120001 STATUS:CONFIRMED SUMMARY:test 5 LOCATION:2 DESCRIPTION:SOINS TRANSP:TRANSPARENT ATTACH;FMTTYPE=image/png;FILENAME=/sign.png;X-NC-FILE-ID=1426;X-NC-HAS-PREV IEW=true:/f/1426 CLIENT:1 EMBALMER: END:VEVENT BEGIN:VTIMEZONE TZID:Africa/Nairobi BEGIN:STANDARD TZOFFSETFROM:+0300 TZOFFSETTO:+0300 TZNAME:EAT DTSTART:19700101T000000 END:STANDARD END:VTIMEZONE END:VCALENDAR"; $this->gestionService->moveCalendarAttachmentFile($tex, '/f'); } /** * @NoAdminRequired * @NoCSRFRequired */ public function sendEmailAttachment() { $this->storage->getFullPath("/"); $attachments = [ ['file_id' => 1518, 'name' => 'Capture.JPG'] ]; $to = "jonathan.goulet@nextcloud.com"; $subject = "Piece jointe"; $body = "
Bonjour.
Vous trouverez en pièce jointe les fichiers votre défunt.
"; $message = $this->mailer->createMessage(); $message->setSubject($subject); $message->setTo(recipients: [$to]); foreach ($attachments as $attachment) { $path = Filesystem::getPath($attachment['file_id']); $content = $this->mailer->createAttachment(Filesystem::file_get_contents($path), $attachment['name'], 'image/png'); $message->attach($content); } $message->setHtmlBody($body); $this->mailer->send($message); return true; } }