|
|
|
@@ -8,33 +8,29 @@ use AppBundle\Entity\Company;
|
|
|
|
|
use AppBundle\Entity\Message;
|
|
|
|
|
use AppBundle\Form\AnswerType;
|
|
|
|
|
use AppBundle\Form\ContactTalentType;
|
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Cookie;
|
|
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Session\Session;
|
|
|
|
|
|
|
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcher,
|
|
|
|
|
Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken,
|
|
|
|
|
Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
|
|
|
|
|
|
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
|
|
|
|
|
|
|
|
|
class AnswerController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* @Route("/anwser/edit/comment/{id}", name="anwser_edit_comment")
|
|
|
|
|
*/
|
|
|
|
|
public function anwserEditCommentAction(Request $request, Answer $answer)
|
|
|
|
|
{
|
|
|
|
|
if($answer) {
|
|
|
|
|
{
|
|
|
|
|
if ($answer) {
|
|
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
|
$answer->setComment($request->get('comment'));
|
|
|
|
|
$em->persist($answer);
|
|
|
|
|
$em->flush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new JsonResponse(array('success' => "true"));
|
|
|
|
|
}
|
|
|
|
@@ -57,15 +53,16 @@ class AnswerController extends Controller
|
|
|
|
|
return $this->finishAnswerAction($request, $company, $answer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function finishAnswerAction($request, $object, $answer) {
|
|
|
|
|
public function finishAnswerAction($request, $object, $answer)
|
|
|
|
|
{
|
|
|
|
|
$securityContext = $this->container->get('security.authorization_checker');
|
|
|
|
|
if($object instanceof Ad) {
|
|
|
|
|
if ($object instanceof Ad) {
|
|
|
|
|
$route = "ad_show";
|
|
|
|
|
$varReqAnswer = "ad";
|
|
|
|
|
$contact = $object->getCreator();
|
|
|
|
|
$title = $answer->getAd()->getTitle();
|
|
|
|
|
}
|
|
|
|
|
if($object instanceof Company) {
|
|
|
|
|
if ($object instanceof Company) {
|
|
|
|
|
$route = "company_show";
|
|
|
|
|
$varReqAnswer = "company";
|
|
|
|
|
$contact = $object->getMainUser();
|
|
|
|
@@ -74,7 +71,7 @@ class AnswerController extends Controller
|
|
|
|
|
if (!$securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
|
|
|
|
|
return $this->redirectToRoute($route, array('alias' => $object->getAlias()));
|
|
|
|
|
}
|
|
|
|
|
if($answer) {
|
|
|
|
|
if ($answer) {
|
|
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
|
$existAnswer = $em->getRepository('AppBundle:Answer')->findOneBy(array('user' => $this->getUser(), $varReqAnswer => $object));
|
|
|
|
|
if (!$this->getUser()->hasRole('ROLE_TALENT')) {
|
|
|
|
@@ -82,7 +79,7 @@ class AnswerController extends Controller
|
|
|
|
|
$session = new Session();
|
|
|
|
|
$session->getFlashBag()->add('popup_answer_not_allowed', true);
|
|
|
|
|
} else {
|
|
|
|
|
if($existAnswer && ($existAnswer->getId() !== $answer->getid())){
|
|
|
|
|
if ($existAnswer && ($existAnswer->getId() !== $answer->getid())) {
|
|
|
|
|
$em->remove($answer);
|
|
|
|
|
$session = new Session();
|
|
|
|
|
$session->getFlashBag()->add('popup_answer_already_send', true);
|
|
|
|
@@ -91,31 +88,31 @@ class AnswerController extends Controller
|
|
|
|
|
$session->getFlashBag()->add('popup_answer_already_send', false);
|
|
|
|
|
$answer->setStatus('SENDED');
|
|
|
|
|
$em->persist($answer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$mediaManager = $this->get('media_manager');
|
|
|
|
|
$mediaManager->getThumbnails($answer);
|
|
|
|
|
$thumbnailsArray = $answer->getVideo()->getThumbnails();
|
|
|
|
|
$img = $thumbnailsArray[0]['sizes'][3]['link'];
|
|
|
|
|
$mailManager = $this->get('app.mail_manager');
|
|
|
|
|
$link = $this->generateUrl('company_answer_show', array('id' => $answer->getId()),UrlGeneratorInterface::ABSOLUTE_URL);
|
|
|
|
|
$link = $this->generateUrl('company_answer_show', array('id' => $answer->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
|
|
|
|
|
$mailManager->sendMail(
|
|
|
|
|
'Candidature TalentsTube ',
|
|
|
|
|
'<div style="margin:0 auto;max-width:600px;background:#FFFFFF;"><table class="" cellpadding="0" cellspacing="0" style="width:100%;font-size:0px;background:#FFFFFF;" align="center"><tbody><tr><td style="text-align:center;vertical-align:top;font-size:0;padding:0px;"><!--[if mso]>
|
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:600px;">
|
|
|
|
|
<![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;width:100%;" class="mj-column-per-100" aria-labelledby="mj-column-per-100"><table width="100%"><tbody><tr><td style="font-size:0;padding:0px;" align="center"><table cellpadding="0" cellspacing="0" style="border-collapse:collapse;border-spacing:0px;" align="center"><tbody><tr><td><img alt="" src="'.$img.'" style="border:none;display:block;outline:none;text-decoration:none;width:100%;max-width:600px;height:auto;" width="600" height="auto"></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso]>
|
|
|
|
|
<![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;width:100%;" class="mj-column-per-100" aria-labelledby="mj-column-per-100"><table width="100%"><tbody><tr><td style="font-size:0;padding:0px;" align="center"><table cellpadding="0" cellspacing="0" style="border-collapse:collapse;border-spacing:0px;" align="center"><tbody><tr><td><img alt="" src="' . $img . '" style="border:none;display:block;outline:none;text-decoration:none;width:100%;max-width:600px;height:auto;" width="600" height="auto"></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso]>
|
|
|
|
|
</td></tr></table>
|
|
|
|
|
<![endif]--></td></tr></tbody></table></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div style="margin:0 auto;max-width:600px;background:#FFFFFF;"><table class="" cellpadding="0" cellspacing="0" style="width:100%;font-size:0px;background:#FFFFFF;" align="center"><tbody><tr><td style="text-align:center;vertical-align:top;font-size:0;padding:0px;"><!--[if mso]>
|
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:600px;">
|
|
|
|
|
<![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;width:100%;" class="mj-column-per-100" aria-labelledby="mj-column-per-100"><table width="100%"><tbody><tr><td style="font-size:0;padding:20px 35px 20px 35px;" align="left"><div class="mj-content" style="cursor:auto;color:#534F4F;font-family:Trebuchet,Helvetica,sans-serif;font-size:14px;line-height:22px;"><p>Bonjour '.$contact->getLastname().' '.$contact->getFirstname().',</p>
|
|
|
|
|
<p>Le talent '.$answer->getUser()->getFirstname().' '.$answer->getUser()->getLastname().' a répondu à votre annonce '.$title.'.</p></div></td></tr></tbody></table></div><!--[if mso]>
|
|
|
|
|
<![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;width:100%;" class="mj-column-per-100" aria-labelledby="mj-column-per-100"><table width="100%"><tbody><tr><td style="font-size:0;padding:20px 35px 20px 35px;" align="left"><div class="mj-content" style="cursor:auto;color:#534F4F;font-family:Trebuchet,Helvetica,sans-serif;font-size:14px;line-height:22px;"><p>Bonjour ' . $contact->getLastname() . ' ' . $contact->getFirstname() . ',</p>
|
|
|
|
|
<p>Le talent ' . $answer->getUser()->getFirstname() . ' ' . $answer->getUser()->getLastname() . ' a répondu à votre annonce ' . $title . '.</p></div></td></tr></tbody></table></div><!--[if mso]>
|
|
|
|
|
</td></tr></table>
|
|
|
|
|
<![endif]--></td></tr></tbody></table></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div style="margin:0 auto;max-width:600px;background:#FFFFFF;"><table class="" cellpadding="0" cellspacing="0" style="width:100%;font-size:0px;background:#FFFFFF;" align="center"><tbody><tr><td style="text-align:center;vertical-align:top;font-size:0;padding:0px 0px 40px 0px;"><!--[if mso]>
|
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0"><tr><td style="width:600px;">
|
|
|
|
|
<![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;width:100%;" class="mj-column-per-100" aria-labelledby="mj-column-per-100"><table width="100%"><tbody><tr><td style="font-size:0;padding:15px 30px;" align="center"><table cellpadding="0" cellspacing="0" style="border:none;border-radius:30px;" align="center"><tbody><tr><td style="background:#1689FB;border-radius:30px;color:#FFFFFF;cursor:auto;" align="center" valign="middle" bgcolor="#1689FB"><a class="mj-content" href="'.$link.'" style="display:inline-block;text-decoration:none;background:#1689FB;border:1px solid #1689FB;border-radius:30px;color:#FFFFFF;font-family:Trebuchet,Helvetica,sans-serif;font-size:14px;font-weight:normal;padding:15px 30px;" target="_blank">Découvrir le talent</a></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso]>
|
|
|
|
|
<![endif]--><div style="vertical-align:top;display:inline-block;font-size:13px;text-align:left;width:100%;" class="mj-column-per-100" aria-labelledby="mj-column-per-100"><table width="100%"><tbody><tr><td style="font-size:0;padding:15px 30px;" align="center"><table cellpadding="0" cellspacing="0" style="border:none;border-radius:30px;" align="center"><tbody><tr><td style="background:#1689FB;border-radius:30px;color:#FFFFFF;cursor:auto;" align="center" valign="middle" bgcolor="#1689FB"><a class="mj-content" href="' . $link . '" style="display:inline-block;text-decoration:none;background:#1689FB;border:1px solid #1689FB;border-radius:30px;color:#FFFFFF;font-family:Trebuchet,Helvetica,sans-serif;font-size:14px;font-weight:normal;padding:15px 30px;" target="_blank">Découvrir le talent</a></td></tr></tbody></table></td></tr></tbody></table></div><!--[if mso]>
|
|
|
|
|
</td></tr></table>
|
|
|
|
|
<![endif]--></td></tr></tbody></table></div>',
|
|
|
|
|
$contact,
|
|
|
|
@@ -123,9 +120,9 @@ class AnswerController extends Controller
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$session->getFlashBag()->add('popup_answer_send', true);
|
|
|
|
|
$em->flush();
|
|
|
|
|
|
|
|
|
|
$session->getFlashBag()->add('popup_answer_send', true);
|
|
|
|
|
$em->flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->redirect($this->generateUrl($route, array('alias' => $object->getAlias())));
|
|
|
|
@@ -147,22 +144,25 @@ class AnswerController extends Controller
|
|
|
|
|
return $this->generateStep2($request, $company, $type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function generateStep2(Request $request, $object, $type) {
|
|
|
|
|
if($object instanceof Ad) {
|
|
|
|
|
public function generateStep2(Request $request, $object, $type)
|
|
|
|
|
{
|
|
|
|
|
if ($object instanceof Ad) {
|
|
|
|
|
$route = "ad_show";
|
|
|
|
|
$routeStep2 = 'answer_create_ad_step2';
|
|
|
|
|
$routeStep3 = 'answer_create_ad_step3';
|
|
|
|
|
$varReqAnswer = "ad";
|
|
|
|
|
$typeObject = "Ad";
|
|
|
|
|
}
|
|
|
|
|
if($object instanceof Company) {
|
|
|
|
|
if ($object instanceof Company) {
|
|
|
|
|
$route = "company_show";
|
|
|
|
|
$routeStep2 = 'answer_create_company_step2';
|
|
|
|
|
$routeStep3 = 'answer_create_company_step3';
|
|
|
|
|
$varReqAnswer = "company";
|
|
|
|
|
$typeObject = "Company";
|
|
|
|
|
}
|
|
|
|
|
$securityContext = $this->container->get('security.authorization_checker');
|
|
|
|
|
if (!$securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
|
|
|
|
|
return $this->redirectToRoute($route, array('alias' => $object->getAlias()));
|
|
|
|
|
return $this->redirectToRoute($route, array('alias' => $object->getAlias()));
|
|
|
|
|
}
|
|
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
|
$user = $this->getUser();
|
|
|
|
@@ -182,18 +182,18 @@ class AnswerController extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
|
if(!$mustLogin){
|
|
|
|
|
return $this->redirect($this->generateUrl($routeStep3, array($varReqAnswer => $object->getId(), 'answer'=> $answer->getId())));
|
|
|
|
|
if (!$mustLogin) {
|
|
|
|
|
return $this->redirect($this->generateUrl($routeStep3, array($varReqAnswer => $object->getId(), 'answer' => $answer->getId())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*Definition des urls de destination pour ouath login et register*/
|
|
|
|
|
$destination_login = $this->generateUrl($routeStep3, array($varReqAnswer => $object->getId(), 'answer'=> $answer->getId()));
|
|
|
|
|
/*Definition des urls de destination pour oauth login et register*/
|
|
|
|
|
$destination_login = $this->generateUrl($routeStep3, array($varReqAnswer => $object->getId(), 'answer' => $answer->getId()));
|
|
|
|
|
$this->get('twig')->addGlobal('destination_login', $destination_login);
|
|
|
|
|
$session = new Session();
|
|
|
|
|
$session->set('registration_destination', $destination_login);
|
|
|
|
|
|
|
|
|
|
return $this->render('answer/answer_create_'.$type.'.twig', array(
|
|
|
|
|
$res = $this->render('answer/answer_create_' . $type . '.twig', array(
|
|
|
|
|
'routeObject' => $route,
|
|
|
|
|
'typeObject' => $typeObject,
|
|
|
|
|
'object' => $object,
|
|
|
|
@@ -202,23 +202,27 @@ class AnswerController extends Controller
|
|
|
|
|
'video' => $video,
|
|
|
|
|
'videos' => $videos,
|
|
|
|
|
$varReqAnswer => $object,
|
|
|
|
|
'mustLogin' => $mustLogin
|
|
|
|
|
'mustLogin' => $mustLogin,
|
|
|
|
|
));
|
|
|
|
|
$redirectReg = $this->generateUrl($routeStep2, array('id' => $object->getId(), 'type' => $type));
|
|
|
|
|
$res->headers->setCookie(new Cookie('redirect_register', $redirectReg));
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createAnonymousUser() {
|
|
|
|
|
private function createAnonymousUser()
|
|
|
|
|
{
|
|
|
|
|
$userManager = $this->get('fos_user.user_manager');
|
|
|
|
|
$user = $userManager->createUser();
|
|
|
|
|
$uniqId = uniqId();
|
|
|
|
|
$user->setUsername("anonym_".$uniqId);
|
|
|
|
|
$user->setUsername("anonym_" . $uniqId);
|
|
|
|
|
$user->setFirstname("anonym");
|
|
|
|
|
$user->setLastname("anonym");
|
|
|
|
|
$user->setEmail("anonym_".$uniqId."@talentstube.com");
|
|
|
|
|
$user->setEmail("anonym_" . $uniqId . "@talentstube.com");
|
|
|
|
|
$user->setPlainPassword($uniqId);
|
|
|
|
|
$user->setEnabled(false);
|
|
|
|
|
$user->setRoles(array('ROLE_TALENT_TMP'));
|
|
|
|
|
$company = new Company();
|
|
|
|
|
$company->setAlias("anonym_".$uniqId);
|
|
|
|
|
$company->setAlias("anonym_" . $uniqId);
|
|
|
|
|
$company->setType("TALENT_TMP");
|
|
|
|
|
$user->setCompany($company);
|
|
|
|
|
$userManager->updateUser($user);
|
|
|
|
@@ -267,7 +271,7 @@ class AnswerController extends Controller
|
|
|
|
|
'answer' => $answer,
|
|
|
|
|
'object' => $company,
|
|
|
|
|
'mustLogin' => $mustLogin,
|
|
|
|
|
'route_videotheque' => $route_videotheque
|
|
|
|
|
'route_videotheque' => $route_videotheque,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -306,7 +310,7 @@ class AnswerController extends Controller
|
|
|
|
|
'answer' => $answer,
|
|
|
|
|
'object' => $ad,
|
|
|
|
|
'mustLogin' => $mustLogin,
|
|
|
|
|
'route_videotheque' => $route_videotheque
|
|
|
|
|
'route_videotheque' => $route_videotheque,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -368,7 +372,7 @@ class AnswerController extends Controller
|
|
|
|
|
$answers = $em->getRepository('AppBundle:Answer')->getAnswerByCompany($user->getCompany()->getId());
|
|
|
|
|
return $this->render('company/answer_list.html.twig', [
|
|
|
|
|
'answers' => $answers,
|
|
|
|
|
'type' => 'answer'
|
|
|
|
|
'type' => 'answer',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -382,7 +386,7 @@ class AnswerController extends Controller
|
|
|
|
|
$answers = $em->getRepository('AppBundle:Answer')->findBy(array('company' => $user->getCompany()->getId(), 'status' => 'SENDED'));
|
|
|
|
|
return $this->render('company/answer_list.html.twig', [
|
|
|
|
|
'answers' => $answers,
|
|
|
|
|
'type' => 'spontaneous'
|
|
|
|
|
'type' => 'spontaneous',
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
@@ -423,7 +427,7 @@ class AnswerController extends Controller
|
|
|
|
|
{
|
|
|
|
|
$message = array('success' => 200,
|
|
|
|
|
'filename' => null,
|
|
|
|
|
'originalFilename' => null
|
|
|
|
|
'originalFilename' => null,
|
|
|
|
|
);
|
|
|
|
|
foreach ($request->files as $uploadedFile) {
|
|
|
|
|
$mediaManager = $this->get('media_manager');
|
|
|
|
@@ -447,5 +451,4 @@ class AnswerController extends Controller
|
|
|
|
|
return new JsonResponse(array('success' => "true"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|