|
@@ -529,15 +529,12 @@ class ElementController extends Controller
|
529
|
529
|
'search_tags' => $search_tags
|
530
|
530
|
));
|
531
|
531
|
|
532
|
|
- if ($this->getRequest()->isXmlHttpRequest())
|
533
|
|
- {
|
534
|
|
- return $this->jsonResponse(array(
|
535
|
|
- 'status' => 'success',
|
536
|
|
- 'form_name' => 'element_tag_proposition_'.$element->getId(),
|
537
|
|
- 'tags' => $search_tags,
|
538
|
|
- 'html' => $response->getContent()
|
539
|
|
- ));
|
540
|
|
- }
|
|
532
|
+ return $this->jsonResponse(array(
|
|
533
|
+ 'status' => 'success',
|
|
534
|
+ 'form_name' => 'element_tag_proposition_'.$element->getId(),
|
|
535
|
+ 'tags' => $search_tags,
|
|
536
|
+ 'html' => $response->getContent()
|
|
537
|
+ ));
|
541
|
538
|
}
|
542
|
539
|
|
543
|
540
|
public function proposeTagsProceedAction($element_id, $token)
|
|
@@ -608,4 +605,135 @@ class ElementController extends Controller
|
608
|
605
|
));
|
609
|
606
|
}
|
610
|
607
|
|
|
608
|
+ public function proposedTagsViewAction($element_id)
|
|
609
|
+ {
|
|
610
|
+ if (($response = $this->mustBeConnected(true)))
|
|
611
|
+ {
|
|
612
|
+ return $response;
|
|
613
|
+ }
|
|
614
|
+
|
|
615
|
+ if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
616
|
+ ->findOneById($element_id)))
|
|
617
|
+ {
|
|
618
|
+ return $this->jsonResponse(array(
|
|
619
|
+ 'status' => 'error',
|
|
620
|
+ 'errors' => array('NotFound')
|
|
621
|
+ ));
|
|
622
|
+ }
|
|
623
|
+
|
|
624
|
+ if ($element->getOwner()->getId() != $this->getUserId())
|
|
625
|
+ {
|
|
626
|
+ return $this->jsonResponse(array(
|
|
627
|
+ 'status' => 'error',
|
|
628
|
+ 'errors' => array('NotAllowed')
|
|
629
|
+ ));
|
|
630
|
+ }
|
|
631
|
+
|
|
632
|
+ // On récupére toute les propsotions pour cet élément
|
|
633
|
+ $propositions = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:ElementTagsProposition')
|
|
634
|
+ ->findByElement($element->getId())
|
|
635
|
+ ;
|
|
636
|
+
|
|
637
|
+ $response = $this->render('MuzichCoreBundle:Element:tag.propositions.html.twig', array(
|
|
638
|
+ 'propositions' => $propositions,
|
|
639
|
+ 'element_id' => $element->getId()
|
|
640
|
+ ));
|
|
641
|
+
|
|
642
|
+ return $this->jsonResponse(array(
|
|
643
|
+ 'status' => 'success',
|
|
644
|
+ 'html' => $response->getContent()
|
|
645
|
+ ));
|
|
646
|
+
|
|
647
|
+ }
|
|
648
|
+
|
|
649
|
+ public function proposedTagsAcceptAction($proposition_id, $token)
|
|
650
|
+ {
|
|
651
|
+ if (($response = $this->mustBeConnected(true)))
|
|
652
|
+ {
|
|
653
|
+ return $response;
|
|
654
|
+ }
|
|
655
|
+
|
|
656
|
+ if (!($proposition = $this->getDoctrine()->getRepository('MuzichCoreBundle:ElementTagsProposition')
|
|
657
|
+ ->findOneById($proposition_id)) || $token != $this->getUser()->getPersonalHash())
|
|
658
|
+ {
|
|
659
|
+ return $this->jsonResponse(array(
|
|
660
|
+ 'status' => 'error',
|
|
661
|
+ 'errors' => array('NotFound')
|
|
662
|
+ ));
|
|
663
|
+ }
|
|
664
|
+
|
|
665
|
+ // On commence par appliquer les nouveaux tags a l'élément
|
|
666
|
+ $element = $proposition->getElement();
|
|
667
|
+ $element->setTags(null);
|
|
668
|
+ foreach ($proposition->getTags() as $tag)
|
|
669
|
+ {
|
|
670
|
+ $element->addTag($tag);
|
|
671
|
+ }
|
|
672
|
+ $element->setHasTagProposition(false);
|
|
673
|
+ $this->getDoctrine()->getEntityManager()->persist($element);
|
|
674
|
+
|
|
675
|
+ $propositions = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:ElementTagsProposition')
|
|
676
|
+ ->findByElement($element->getId())
|
|
677
|
+ ;
|
|
678
|
+
|
|
679
|
+ /*
|
|
680
|
+ * TODO: ARCHIVAGE (c avant ou aprés event déjà ?) (cf doc), notifs (event)
|
|
681
|
+ */
|
|
682
|
+
|
|
683
|
+ // On supprime les proposition liés a cet élement
|
|
684
|
+ foreach ($propositions as $proposition)
|
|
685
|
+ {
|
|
686
|
+ $this->getDoctrine()->getEntityManager()->remove($proposition);
|
|
687
|
+ }
|
|
688
|
+
|
|
689
|
+ $this->getDoctrine()->getEntityManager()->flush();
|
|
690
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
691
|
+ ->findOneById($element->getId())
|
|
692
|
+ ;
|
|
693
|
+
|
|
694
|
+ // On récupère l'html de l'élément
|
|
695
|
+ $html = $this->render('MuzichCoreBundle:SearchElement:element.html.twig', array(
|
|
696
|
+ 'element' => $element
|
|
697
|
+ ))->getContent();
|
|
698
|
+
|
|
699
|
+ return $this->jsonResponse(array(
|
|
700
|
+ 'status' => 'success',
|
|
701
|
+ 'html' => $html
|
|
702
|
+ ));
|
|
703
|
+ }
|
|
704
|
+
|
|
705
|
+ public function proposedTagsRefuseAction($element_id, $token)
|
|
706
|
+ {
|
|
707
|
+ if (($response = $this->mustBeConnected(true)))
|
|
708
|
+ {
|
|
709
|
+ return $response;
|
|
710
|
+ }
|
|
711
|
+
|
|
712
|
+ if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
713
|
+ ->findOneById($element_id)) || $token != $this->getUser()->getPersonalHash())
|
|
714
|
+ {
|
|
715
|
+ return $this->jsonResponse(array(
|
|
716
|
+ 'status' => 'error',
|
|
717
|
+ 'errors' => array('NotFound')
|
|
718
|
+ ));
|
|
719
|
+ }
|
|
720
|
+
|
|
721
|
+ // On supprime les proposition liés a cet élement
|
|
722
|
+ $propositions = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:ElementTagsProposition')
|
|
723
|
+ ->findByElement($element->getId())
|
|
724
|
+ ;
|
|
725
|
+ foreach ($propositions as $proposition)
|
|
726
|
+ {
|
|
727
|
+ $this->getDoctrine()->getEntityManager()->remove($proposition);
|
|
728
|
+ }
|
|
729
|
+ // On spécifie qu'il n'y as plus de proposition
|
|
730
|
+ $element->setHasTagProposition(false);
|
|
731
|
+ $this->getDoctrine()->getEntityManager()->persist($element);
|
|
732
|
+ $this->getDoctrine()->getEntityManager()->flush();
|
|
733
|
+
|
|
734
|
+ return $this->jsonResponse(array(
|
|
735
|
+ 'status' => 'success'
|
|
736
|
+ ));
|
|
737
|
+ }
|
|
738
|
+
|
611
|
739
|
}
|