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

Fix blacklist email #22

Merged
merged 2 commits into from
Jul 12, 2016
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
15 changes: 14 additions & 1 deletion Controller/BlacklistConfirmationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Sulu\Bundle\CommunityBundle\Controller;

use Sulu\Bundle\CommunityBundle\DependencyInjection\Configuration;
use Sulu\Bundle\CommunityBundle\Entity\BlacklistItem;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand Down Expand Up @@ -62,13 +63,16 @@ public function denyAction(Request $request)
{
$entityManager = $this->get('doctrine.orm.entity_manager');
$repository = $this->get('sulu_community.blacklisting.user_repository');
$itemRepository = $this->get('sulu_community.blacklisting.item_repository');
$itemManager = $this->get('sulu_community.blacklisting.item_manager');

$blacklistUser = $repository->findByToken($request->get('token'));

if (null === $blacklistUser) {
throw new NotFoundHttpException();
}

$user = $blacklistUser->getUser();
$blacklistUser->deny();

$communityManager = $this->getCommunityManager($blacklistUser->getWebspaceKey());
Expand All @@ -77,10 +81,19 @@ public function denyAction(Request $request)
Configuration::DELETE_USER
)
) {
$entityManager->remove($blacklistUser->getUser());
$entityManager->remove($user);
$entityManager->remove($blacklistUser);
}

$item = $itemRepository->findOneByPattern($user->getEmail());

if (!$item) {
$item = $itemManager->create();
}

$item->setType(BlacklistItem::TYPE_BLOCK)
->setPattern($user->getEmail());

$entityManager->flush();

$communityManager->sendEmails(Configuration::TYPE_BLACKLIST_DENIED, $blacklistUser->getUser());
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function getConfigTreeBuilder()
->children()
->scalarNode(self::EMAIL_SUBJECT)->defaultValue('Registration')->end()
->scalarNode(self::EMAIL_ADMIN_TEMPLATE)->defaultValue(null)->end()
->scalarNode(self::EMAIL_USER_TEMPLATE)->defaultValue('SuluCommunityBundle:Password:blacklist-email.html.twig')->end()
->scalarNode(self::EMAIL_USER_TEMPLATE)->defaultValue('SuluCommunityBundle:Registration:registration-email.html.twig')->end()
->end()
->end()
->end()
Expand Down