Merge branch 'master' of https://git.e-declic.net/talents-tube/website
This commit is contained in:
@@ -116,4 +116,21 @@ class AdController extends FOSRestController
|
||||
['Location' => $this->generateUrl('api_ad_show', ['id' => $ad->getId(), UrlGeneratorInterface::ABSOLUTE_URL])]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Rest\Get("/api/adAjaxRecStat/{id}", name="adAjaxRecStat")
|
||||
* @Rest\View(statusCode=200)
|
||||
*/
|
||||
public function adAjaxRecStatAction(Ad $ad)
|
||||
{
|
||||
$history = $this->get('edeclic.history.record');
|
||||
if ($this->getUser()) {
|
||||
$idUser = $this->getUser()->getId();
|
||||
$history->recordIt($idUser, "r", get_class($ad), $ad->getId(), serialize($ad));
|
||||
} else {
|
||||
$history->recordIt("Anonymous", "r", get_class($ad), $ad->getId(), serialize($ad));
|
||||
}
|
||||
|
||||
return new JsonResponse(array('code' => "ok"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class AnswerController extends FOSRestController
|
||||
public function showAction(Answer $answer)
|
||||
{
|
||||
$usr = $this->getUser();
|
||||
$userAnswer = $this->getDoctrine()->getRepository('AppBundle:Answer')->findOneBy(array('user' => $usr, 'id' => $answer->getId()));
|
||||
$userAnswer = $this->getDoctrine()->getRepository('AppBundle:Answer')->findOneByWithCorrespondences($usr, $answer->getId());
|
||||
if ($userAnswer) {
|
||||
$data = $this->get('jms_serializer')->serialize($answer, 'json', SerializationContext::create()->setGroups(array('answer_detail')));
|
||||
return new JsonResponse($data, 200, [], true);
|
||||
@@ -248,6 +248,7 @@ class AnswerController extends FOSRestController
|
||||
*/
|
||||
public function fetchMessageAction(Answer $answer)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$usr = $this->get('security.token_storage')->getToken()->getUser();
|
||||
|
||||
if ($answer->getUser()->getId() !== $usr->getId()) {
|
||||
@@ -256,7 +257,7 @@ class AnswerController extends FOSRestController
|
||||
throw new ResourceValidationException($message, $status);
|
||||
}
|
||||
|
||||
$messages = $answer->getMessages();
|
||||
$messages = $em->getRepository('AppBundle:Message')->searchCorrespondences($answer);
|
||||
//
|
||||
$status = array('status' => "success", "messages" => $messages);
|
||||
//
|
||||
|
||||
@@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use JMS\Serializer\SerializationContext;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
|
||||
class CompanyController extends FOSRestController
|
||||
{
|
||||
@@ -93,4 +94,23 @@ class CompanyController extends FOSRestController
|
||||
Response::HTTP_CREATED,
|
||||
['Location' => $this->generateUrl('api_company_show', ['id' => $company->getId(), UrlGeneratorInterface::ABSOLUTE_URL])]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Rest\Get(path="/api/companyAjaxRecStat/{id}", name="companyAjaxRecStat", requirements={"id"="\d+"})
|
||||
* @Rest\View(statusCode=200)
|
||||
*/
|
||||
public function companyAjaxRecStatAction(Company $company)
|
||||
{
|
||||
$history = $this->get('edeclic.history.record');
|
||||
if ($this->getUser() && $this->getUser()->getCompany() != null) {
|
||||
if ($this->getUser()->getCompany()->getId() !== $company->getId()) {
|
||||
$history->recordIt($this->getUser()->getId(), "r", get_class($company), $company->getId(), serialize($company));
|
||||
}
|
||||
} else {
|
||||
$history->recordIt("Anonymous", "r", 'AppBundle\Entity\Company', $company->getId(), serialize($company));
|
||||
}
|
||||
|
||||
return new JsonResponse(array('code' => "ok"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Controller\Api;
|
||||
|
||||
use AppBundle\Entity\User;
|
||||
use FOS\RestBundle\Controller\Annotations as Rest;
|
||||
use FOS\RestBundle\Controller\Annotations\Get;
|
||||
use FOS\RestBundle\Controller\Annotations\Post;
|
||||
use FOS\RestBundle\Controller\Annotations\View;
|
||||
use FOS\RestBundle\Controller\FOSRestController;
|
||||
use FOS\RestBundle\Request\ParamFetcherInterface;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use JMS\Serializer\SerializationContext;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class PushController extends FOSRestController
|
||||
{
|
||||
/**
|
||||
* @Rest\Get("/api/isUserSubscribedPush/{id}", name="isUserSubscribedPush")
|
||||
* @Rest\View(statusCode=200)
|
||||
*/
|
||||
public function isUserSubscribedPush(User $user)
|
||||
{
|
||||
$managerPush = $this->get('app.user_subscription_manager');
|
||||
$isUserSubscribed = ($managerPush->findByUser($user))? true : false;
|
||||
|
||||
return new JsonResponse(array('isUserSubscribed' => $isUserSubscribed));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class DefaultController extends Controller
|
||||
$ads = $em->getRepository('AppBundle:Ad')->findBy(array("status" => "PUBLISHED", "isPromoted" => false), array('id' => 'DESC'));
|
||||
}
|
||||
$talents = $em->getRepository('AppBundle:Company')->findBy(array("type" => "TALENT", "emphasis" => true), array('emphasisOrder' => 'DESC'));
|
||||
$companies = $em->getRepository('AppBundle:Company')->findBy(array("type" => "COMPANY", "emphasis" => true), array('emphasisOrder' => 'ASC'));
|
||||
$companies = $em->getRepository('AppBundle:Company')->findBy(array("type" => "COMPANY", "emphasis" => true), array('emphasisOrder' => 'DESC'));
|
||||
$territories = $em->getRepository('AppBundle:Company')->findBy(array("type" => "TERRITORY", "emphasis" => true), array('emphasisOrder' => 'ASC'));
|
||||
|
||||
$arrayTalents = array();
|
||||
|
||||
@@ -25,6 +25,27 @@ class AnswerRepository extends AbstractRepository
|
||||
return $this->paginate($qb, $limit, $offset);
|
||||
}
|
||||
|
||||
// Query to find messages excluding Draft message and talent video for chat
|
||||
public function findOneByWithCorrespondences($user, $answerId)
|
||||
{
|
||||
$qb = $this
|
||||
->createQueryBuilder('a')
|
||||
->select(['a','m','ad'])
|
||||
->where('a.user = :user')
|
||||
->andWhere('a.id = :id')
|
||||
->setParameter('user', $user)
|
||||
->setParameter('id', $answerId)
|
||||
->leftJoin('a.messages', 'm','WITH', 'm.status NOT IN(\'DRAFT\',\'CONTACT_TALENT\')')
|
||||
// ->setParameter(':status', array('DRAFT','CONTACT_TALENT'))
|
||||
->leftJoin('a.ad', 'ad')
|
||||
->leftJoin('a.company', 'company')
|
||||
|
||||
;
|
||||
return $qb
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getAnswerByCompany($id)
|
||||
{
|
||||
$qb = $this
|
||||
|
||||
@@ -10,4 +10,21 @@ namespace AppBundle\Repository;
|
||||
*/
|
||||
class MessageRepository extends \Doctrine\ORM\EntityRepository
|
||||
{
|
||||
public function searchCorrespondences($answer)
|
||||
{
|
||||
$qb = $this
|
||||
->createQueryBuilder('m')
|
||||
->select('m')
|
||||
->where('m.answer = :answer')
|
||||
->setParameter('answer', $answer)
|
||||
->andWhere('m.status <> :status')
|
||||
->setParameter(':status', 'DRAFT')
|
||||
|
||||
;
|
||||
return $qb
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
|
||||
// add status = SENDED;
|
||||
@@ -106,6 +106,7 @@ class RegistrationListener implements EventSubscriberInterface
|
||||
$company->setType("TALENT");
|
||||
} elseif ($user->hasRole('ROLE_COMPANY')) {
|
||||
$company->setType("COMPANY");
|
||||
$company->setIsPrivate(true);
|
||||
} elseif ($user->hasRole('ROLE_TERRITORY')) {
|
||||
$company->setType("TERRITORY");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user