Example #1
0
 public function getThreadAction($pole, Categorie $categorie, $slug, Post $post, Thread $thread, $nonVu = null, $moderer = false, User $user = null, $perm = null, $page = 1, $answer = 0)
 {
     if ($perm == null) {
         $permService = $this->container->get('ter_aelis_forum.permission');
         $perm = $permService->getPerm($user);
     }
     $voirCategorie = $perm['voirCategorie'][$categorie->getId()];
     $voirSujet = $perm['voirSujet'][$categorie->getId()];
     $repondreSujet = $perm['repondreSujet'][$categorie->getId()];
     if ($voirCategorie == 0 || $voirSujet == 0) {
         throw new AccessDeniedException("Interdiction de voir ce sujet (idCategorie = " . $categorie->getId() . ")");
     }
     list($pole_aff, $pole) = $this->getPoleAffichage($pole, $categorie->getRoot());
     $nbCommentPerPage = $this->container->getParameter('comment.nb_comment');
     $returnArray = array('user' => $user, 'answer' => $answer, 'slug' => $slug, 'thread' => $thread, 'repondreSujet' => $repondreSujet, 'pole' => $pole, 'pole_aff' => $pole_aff, 'nbCommentPerPage' => $nbCommentPerPage, 'moderer' => $moderer, 'sujet' => $post, 'page' => $page, 'nonVu' => $nonVu);
     $em = $this->getDoctrine()->getManager();
     $comments = null;
     if ($thread->getNumberComment() > 0) {
         $editerMessage = $perm['editerMessage'][$categorie->getId()];
         $supprimerMessage = $perm['supprimerMessage'][$categorie->getId()];
         $moderer = $perm['moderer'][$categorie->getId()];
         $repositoryComments = $em->getRepository('TerAelisCommentBundle:Comment');
         $comments = $repositoryComments->findByThread($thread, $nbCommentPerPage, $page, $answer);
         // Variables transmises au twig
         $returnArray['comments'] = $comments;
         $returnArray['editerMessage'] = $editerMessage;
         $returnArray['supprimerMessage'] = $supprimerMessage;
         $returnArray['postLastComment'] = $post->getLastComment();
         $returnArray['moderer'] = $moderer;
     }
     // Update des non lus
     if ($user != null) {
         $lastCommentShown = null;
         if ($comments != null) {
             foreach ($comments as $c) {
                 $lastCommentShown = $c;
             }
         }
         $nonVuService = $this->container->get('ter_aelis_forum.non_vu');
         $nonVuService->deleteNonVu($user, $post, $lastCommentShown);
     }
     return $this->render('TerAelisCommentBundle:Thread:view.html.twig', $returnArray);
 }