Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] mail null / delete notif... #2427

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/Controller/Back/ExportSignalementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,27 @@ public function exportCsv(
/** @var User $user */
$user = $this->getUser();
if ($this->isCsrfTokenValid('export_token_'.$user->getId(), $request->get('_token'))) {
set_error_handler(function ($err_severity, $err_msg, $err_file, $err_line) {
throw new \ErrorException($err_msg, 0, $err_severity, $err_file, $err_line);
}, \E_WARNING);
$filters = $request->getSession()->get('filters');
$response = new StreamedResponse();
$response->setCallback(function () use ($signalementExportLoader, $filters, $user) {
$signalementExportLoader->load($user, $filters);
});
try {
$response = new StreamedResponse();
$response->setCallback(function () use ($signalementExportLoader, $filters, $user) {
$signalementExportLoader->load($user, $filters);
});

$disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
'export-histologe-'.date('dmY').'.csv'
);
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', $disposition);
$disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
'export-histologe-'.date('dmY').'.csv'
);
$response->headers->set('Content-Type', 'text/csv');
$response->headers->set('Content-Disposition', $disposition);

return $response->send();
return $response->send();
} catch (\Exception $e) {
throw new \Exception('Erreur lors de l\'export du fichier par l\'user "'.$user->getId().'" : '.$e->getMessage().' - '.print_r($filters, true));
}
}
$this->addFlash('error', 'Problème d\'identification de votre demande. Merci de réessayer.');

Expand Down
7 changes: 6 additions & 1 deletion src/Controller/Back/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ private function deleteAllNotifications($em)

#[Route('/notifications/{id}/supprimer', name: 'back_notifications_delete_notification')]
public function deleteNotification(
Notification $notification,
NotificationRepository $notificationRepository,
EntityManagerInterface $em,
Request $request
): Response {
$notification = $notificationRepository->find($request->get('id'));
if (!$notification) {
return $this->redirectToRoute('back_notifications_list');
}

$this->denyAccessUnlessGranted('NOTIF_DELETE', $notification);
if ($this->isCsrfTokenValid('back_delete_notification_'.$notification->getId(), $request->get('_token'))) {
$em->remove($notification);
Expand Down
7 changes: 3 additions & 4 deletions src/Controller/Security/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ public function showUploadedFile(
} elseif ('resize' == $variant && $fileStorage->fileExists($variantNames[ImageManipulationHandler::SUFFIX_RESIZE])) {
$filename = $variantNames[ImageManipulationHandler::SUFFIX_RESIZE];
}
if (!$fileStorage->fileExists($filename)) {
throw new \Exception('File "'.$filename.'" not found');
}
$tmpFilepath = $this->getParameter('uploads_tmp_dir').$filename;
$bucketFilepath = $this->getParameter('url_bucket').'/'.$filename;

$content = file_get_contents($bucketFilepath);
if (false === $content) {
throw new \Exception('File "'.$bucketFilepath.'" not found');
}
file_put_contents($tmpFilepath, $content);
$file = new File($tmpFilepath);

Expand Down
18 changes: 12 additions & 6 deletions src/Repository/SignalementRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,12 @@ public function findUsersPartnerEmailAffectedToSignalement(int $signalementId, ?
->setParameter('partner', $partnerToExclude);
}

$usersEmail = array_map(function ($value) {
return $value['email'];
}, $queryBuilder->getQuery()->getArrayResult());
$usersEmail = [];
foreach ($queryBuilder->getQuery()->getArrayResult() as $value) {
if ($value['email'] && !\in_array($value['email'], $usersEmail)) {
$usersEmail[] = $value['email'];
}
}

return $usersEmail;
}
Expand All @@ -580,9 +583,12 @@ public function findPartnersEmailAffectedToSignalement(int $signalementId): arra
->where('s.id = :signalement_id')
->setParameter('signalement_id', $signalementId);

$partnersEmail = array_map(function ($value) {
return $value['email'];
}, $queryBuilder->getQuery()->getArrayResult());
$partnersEmail = [];
foreach ($queryBuilder->getQuery()->getArrayResult() as $value) {
if ($value['email'] && !\in_array($value['email'], $partnersEmail)) {
$partnersEmail[] = $value['email'];
}
}

return $partnersEmail;
}
Expand Down
Loading