Skip to content

Commit

Permalink
Remove adding and editing of relations from the profile menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismeonmounteverest committed Aug 19, 2024
1 parent 6dfa9ad commit 3dd41a0
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 41 deletions.
11 changes: 6 additions & 5 deletions build/members/pages/member.page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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", '<i class="fa fa-fw fa-comment"></i> ' . $ww->EditComments, 'commentsadd'));
$tt = array_merge($tt, [
[ 'commmentsadd', "members/$username/comment/edit", '<i class="fa fa-fw fa-comment"></i> ' . $ww->EditComments, 'commentsadd']
]);
}
} else {
$tt = array_merge($tt, array('commmentsadd', "members/$username/comment/add", '<i class="fa fa-fw fa-comment"></i> ' . $ww->AddComments, 'commentsadd'));
$tt = array_merge($tt, [['commmentsadd', "members/$username/comment/add", '<i class="fa fa-fw fa-comment"></i> ' . $ww->AddComments, 'commentsadd']]);
}
$tt = array_merge($tt, [
(null === $relation)
/* (null === $relation)
? array('relationsadd', "members/$username/relation/add", '<i class="fa fa-fw fa-handshake"></i> ' . $words->get('profile.relation.add'), 'relationsadd')
: array('relationsadd', "members/$username/relation/edit", '<i class="fa fa-fw fa-handshake"></i> ' . $words->get('profile.relation.edit'), 'relationsadd'),
array('notes', $mynotelinkname, '<i class="fa fa-fw fa-pencil-alt"></i> ' . $mynotewordsname, 'mynotes'),
: array('relationsadd', "members/$username/relation/edit", '<i class="fa fa-fw fa-handshake"></i> ' . $words->get('profile.relation.edit'), 'relationsadd'), array('notes', $mynotelinkname, '<i class="fa fa-fw fa-pencil-alt"></i> ' . $mynotewordsname, 'mynotes'),
array('report', $feedbackUrl, '<i class="fas fa-fw fa-flag"></i> ' . $words->getSilent('profile.report')),
array('separator-1', '', '', 'space'),
array('profile', "members/$username", '<i class="fa fa-fw fa-user"></i> ' . $ww->MemberPage),
Expand Down
9 changes: 9 additions & 0 deletions src/Controller/ConversationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Controller;

use App\Doctrine\MemberStatusType;
use App\Doctrine\SpamInfoType;
use App\Entity\HostingRequest;
use App\Entity\Member;
Expand Down Expand Up @@ -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, [
Expand Down
16 changes: 7 additions & 9 deletions src/Controller/FeedbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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');
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Controller/GalleryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -42,7 +43,7 @@ public function show(StatisticsModel $statisticsModel)
new NotBlank(),
],
])
->setAction('/signup/1')
->setAction('/signup')
->setMethod('POST')
->getForm();

Expand All @@ -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,
]);
Expand Down
14 changes: 8 additions & 6 deletions src/Controller/LandingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
41 changes: 32 additions & 9 deletions src/Controller/LocaleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand All @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Utilities/ProfileSubmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 3dd41a0

Please sign in to comment.