From 3dd41a07299ebee2f28122ae2bd29266b667dfef Mon Sep 17 00:00:00 2001 From: thisismeonmounteverest Date: Mon, 19 Aug 2024 20:38:47 +0200 Subject: [PATCH] Remove adding and editing of relations from the profile menu. --- build/members/pages/member.page.php | 11 +++--- src/Controller/ConversationController.php | 9 +++++ src/Controller/FeedbackController.php | 16 ++++----- src/Controller/GalleryController.php | 14 ++++---- src/Controller/HomeController.php | 7 ++-- src/Controller/LandingController.php | 14 ++++---- src/Controller/LocaleController.php | 41 ++++++++++++++++++----- src/Utilities/ProfileSubmenu.php | 5 +-- 8 files changed, 76 insertions(+), 41 deletions(-) diff --git a/build/members/pages/member.page.php b/build/members/pages/member.page.php index 8a526f0052..530bc6ad06 100644 --- a/build/members/pages/member.page.php +++ b/build/members/pages/member.page.php @@ -147,16 +147,17 @@ protected function getSubmenuItems() } if (isset($TCom[0])) { if ($TCom[0]->AllowEdit) { - $tt = array_merge($tt, array('commmentsadd', "members/$username/comment/edit", ' ' . $ww->EditComments, 'commentsadd')); + $tt = array_merge($tt, [ + [ 'commmentsadd', "members/$username/comment/edit", ' ' . $ww->EditComments, 'commentsadd'] + ]); } } else { - $tt = array_merge($tt, array('commmentsadd', "members/$username/comment/add", ' ' . $ww->AddComments, 'commentsadd')); + $tt = array_merge($tt, [['commmentsadd', "members/$username/comment/add", ' ' . $ww->AddComments, 'commentsadd']]); } $tt = array_merge($tt, [ - (null === $relation) +/* (null === $relation) ? array('relationsadd', "members/$username/relation/add", ' ' . $words->get('profile.relation.add'), 'relationsadd') - : array('relationsadd', "members/$username/relation/edit", ' ' . $words->get('profile.relation.edit'), 'relationsadd'), - array('notes', $mynotelinkname, ' ' . $mynotewordsname, 'mynotes'), + : array('relationsadd', "members/$username/relation/edit", ' ' . $words->get('profile.relation.edit'), 'relationsadd'), array('notes', $mynotelinkname, ' ' . $mynotewordsname, 'mynotes'), array('report', $feedbackUrl, ' ' . $words->getSilent('profile.report')), array('separator-1', '', '', 'space'), array('profile', "members/$username", ' ' . $ww->MemberPage), diff --git a/src/Controller/ConversationController.php b/src/Controller/ConversationController.php index e8e9b55678..af71bd9620 100644 --- a/src/Controller/ConversationController.php +++ b/src/Controller/ConversationController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Doctrine\MemberStatusType; use App\Doctrine\SpamInfoType; use App\Entity\HostingRequest; use App\Entity\Member; @@ -88,6 +89,14 @@ public function reply(Message $message): Response if ($member !== $message->getSender() && $member !== $message->getReceiver()) { return $this->redirectToRoute('conversations', ['conversationsType' => 'conversations']); } + + if (MemberStatusType::ACCOUNT_ACTIVATED === $member->getStatus()) { + $receiver = ($message->getReceiver() === $member) ? $message->getSender() : $message->getReceiver(); + $this->addTranslatedFlash('notice', 'flash.conversation.not.active'); + + return $this->redirectToRoute('members_profile', ['username' => $receiver->getUsername()]); + } + $controllerAndMethod = $this->getControllerAndMethod($message, 'reply'); return $this->forward($controllerAndMethod, [ diff --git a/src/Controller/FeedbackController.php b/src/Controller/FeedbackController.php index 99ed8e239f..40a52afd5f 100644 --- a/src/Controller/FeedbackController.php +++ b/src/Controller/FeedbackController.php @@ -4,6 +4,8 @@ use App\Form\FeedbackFormType; use App\Model\AboutModel; +use App\Utilities\TranslatedFlashTrait; +use App\Utilities\TranslatorTrait; use Carbon\Carbon; use Symfony\Component\Form\FormError; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -14,20 +16,14 @@ class FeedbackController extends AboutBaseController { + use TranslatorTrait; + use TranslatedFlashTrait; + /** * @Route("/about/feedback", name="contactus") * @Route("/contact") * @Route("/contactus") * @Route("/support") - * - * @return RedirectResponse - */ - public function showAboutFeedback() - { - return $this->redirectToRoute('feedback'); - } - - /** * @Route("/feedback", name="feedback") * * @return Response|RedirectResponse @@ -97,6 +93,8 @@ public function feedback(Request $request, AboutModel $aboutModel, TranslatorInt $aboutModel->sendFeedbackEmail($data); $aboutModel->addFeedback($data); + $this->addTranslatedFlash('notice', 'feedback.thank.you'); + return $this->redirectToRoute('feedback_received'); } } diff --git a/src/Controller/GalleryController.php b/src/Controller/GalleryController.php index 162348bda5..a76721d9ab 100644 --- a/src/Controller/GalleryController.php +++ b/src/Controller/GalleryController.php @@ -341,16 +341,16 @@ public function showUploadedImage(UploadedImage $image, string $fileInfo): Binar $uploadDirectory = $this->getParameter('upload_directory') . '/'; if (!$this->isGranted('IS_AUTHENTICATED_REMEMBERED') || $image->getFileInfo() !== $fileInfo) { $filepath = sprintf($uploadDirectory . 'placeholder_%d_%d.png', $image->getWidth(), $image->getHeight()); - if (!file_exists($filepath)) { - // create image! - $imageManager = new ImageManager(); - $imageManager - ->canvas($image->getWidth(), $image->getHeight(), '#ccc') - ->save($filepath); - } } else { $filepath = $this->getParameter('upload_directory') . '/' . $image->getFilename(); } + if (!file_exists($filepath)) { + // create image! + $imageManager = new ImageManager(); + $imageManager + ->canvas($image->getWidth(), $image->getHeight(), '#ccc') + ->save($filepath); + } // Uploaded images aren't updated; set expiry to 1 year $response = new BinaryFileResponse($filepath); diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index daa5134a50..f9a63c5b7f 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -8,6 +8,7 @@ use RoxPostHandler; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Validator\Constraints\NotBlank; @@ -19,7 +20,7 @@ class HomeController extends AbstractController * * @return Response */ - public function show(StatisticsModel $statisticsModel) + public function show(Request $request, StatisticsModel $statisticsModel, array $locales) { $member = $this->getUser(); if ($member) { @@ -42,7 +43,7 @@ public function show(StatisticsModel $statisticsModel) new NotBlank(), ], ]) - ->setAction('/signup/1') + ->setAction('/signup') ->setMethod('POST') ->getForm(); @@ -60,7 +61,7 @@ public function show(StatisticsModel $statisticsModel) 'search' => $searchForm->createView(), 'images' => $images, 'username' => $usernameForm->createView(), - 'locale' => $this->getParameter('locale'), + 'locale' => $request->getPreferredLanguage($locales), 'title' => 'BeWelcome', 'stats' => $statistics, ]); diff --git a/src/Controller/LandingController.php b/src/Controller/LandingController.php index 6d17e9384c..c32a83d619 100644 --- a/src/Controller/LandingController.php +++ b/src/Controller/LandingController.php @@ -307,12 +307,14 @@ private function getSearchHomeLocationRequest(Member $member): SearchFormRequest { $searchHomeRequest = new SearchFormRequest($this->getDoctrine()->getManager()); $geo = $member->getCity(); - $searchHomeRequest->location = $geo->getName(); - $searchHomeRequest->location_geoname_id = $geo->getGeonameId(); - $searchHomeRequest->location_latitude = $member->getLatitude(); - $searchHomeRequest->location_longitude = $member->getLongitude(); - $searchHomeRequest->accommodation_anytime = true; - $searchHomeRequest->accommodation_neverask = true; + if (null !== $geo) { + $searchHomeRequest->location = $geo->getName(); + $searchHomeRequest->location_geoname_id = $geo->getGeonameId(); + $searchHomeRequest->location_latitude = $member->getLatitude(); + $searchHomeRequest->location_longitude = $member->getLongitude(); + $searchHomeRequest->accommodation_anytime = true; + $searchHomeRequest->accommodation_neverask = true; + } return $searchHomeRequest; } diff --git a/src/Controller/LocaleController.php b/src/Controller/LocaleController.php index c8d80c02fe..cf4f136e74 100644 --- a/src/Controller/LocaleController.php +++ b/src/Controller/LocaleController.php @@ -4,6 +4,9 @@ use App\Entity\Language; use App\Entity\Member; +use App\Entity\MemberPreference; +use App\Entity\Preference; +use Doctrine\ORM\EntityManagerInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -15,15 +18,32 @@ class LocaleController extends AbstractController /** * @Route("/rox/in/{locale}", name="language", requirements={"locale" = "[a-z]{2}(-[A-Za-z]{2,})?"}) * @ParamConverter("language", class="App\Entity\Language", options={"mapping": {"locale": "shortCode"}}) - * - * @return RedirectResponse */ - public function selectLocaleAction(Request $request, Language $language) - { + public function selectLocaleAction( + Request $request, + Language $language, + EntityManagerInterface $entityManager + ): RedirectResponse { /** @var Member $member */ $member = $this->getUser(); if ($member) { - $member->setPreferredLanguage($language); + $preference = $entityManager->getRepository(Preference::class)->findOneBy([ + 'codename' => Preference::LOCALE + ]); + $memberPreference = $entityManager->getRepository(MemberPreference::class)->findOneBy([ + 'preference' => $preference, + 'member' => $member + ]); + if (null === $memberPreference) { + $memberPreference = new MemberPreference(); + $memberPreference + ->setMember($member) + ->setPreference($preference) + ; + } + $memberPreference->setValue($language->getShortCode()); + $entityManager->persist($memberPreference); + $entityManager->flush(); } $redirect = $request->headers->get('referer'); @@ -32,11 +52,14 @@ public function selectLocaleAction(Request $request, Language $language) $redirect = $this->redirectToRoute('homepage'); } - $locale = $request->attributes->get('locale'); + $locale = $language->getShortCode(); - $this->get('session')->set('lang', $locale); - $this->get('session')->set('locale', $locale); - $this->get('session')->set('_locale', $locale); + $request->setLocale($locale); + + $session = $request->getSession(); + $session->set('lang', $locale); + $session->set('locale', $locale); + $session->set('_locale', $locale); return new RedirectResponse($redirect); } diff --git a/src/Utilities/ProfileSubmenu.php b/src/Utilities/ProfileSubmenu.php index 3f5820faa2..2cf2543024 100644 --- a/src/Utilities/ProfileSubmenu.php +++ b/src/Utilities/ProfileSubmenu.php @@ -219,7 +219,8 @@ private function addSubmenuItemsProfile(Member $member, array $parameters) ]); } - if ($parameters['family_or_friend']) { +/* if ($parameters['family_or_friend']) { + $this->addSubmenuItem('family_or_friend', [ 'key' => 'profile.relation.edit', 'icon' => 'handshake', @@ -232,7 +233,7 @@ private function addSubmenuItemsProfile(Member $member, array $parameters) 'url' => $this->routing->generate('add_relation', ['username' => $username]), ]); } - +*/ if ($parameters['note']) { $this->addSubmenuItem('edit_note', [ 'key' => 'NoteEditMyNotesOfMember',