public function onOpen(OpenResourceEvent $event)
 {
     //Redirection to the controller.
     $route = $this->container->get('router')->generate('ujm_exercise_open', array('exerciseId' => $event->getResource()->getId()));
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_ujm_exercise")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $subRequest = $this->container->get('request_stack')->getCurrentRequest()->duplicate([], null, ['_controller' => 'UJMExoBundle:Exercise:open', 'id' => $event->getResource()->getId()]);
     $response = $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_innova_audio_recorder")
  * Fired when a ResourceNode of type AudioFile is opened
  *
  * @param \Claroline\CoreBundle\Event\OpenResourceEvent $event
  *
  * @throws \Exception
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $resource = $event->getResource();
     $route = $this->container->get('router')->generate('claro_resource_open', array('node' => $resource->getResourceNode()->getId(), 'resourceType' => 'file'));
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_innova_media_resource")
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $mediaResource = $event->getResource();
     $route = $this->container->get('router')->generate('innova_media_resource_open', ['id' => $mediaResource->getId(), 'workspaceId' => $mediaResource->getWorkspace()->getId()]);
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_icap_blog")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = [];
     $params['_controller'] = 'IcapBlogBundle:Blog:view';
     $params['blogId'] = $event->getResource()->getId();
     $subRequest = $this->request->duplicate([], null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 public function onOpen(OpenResourceEvent $event)
 {
     $requestStack = $this->container->get('request_stack');
     $httpKernel = $this->container->get('http_kernel');
     $request = $requestStack->getCurrentRequest();
     $params = array();
     $params['_controller'] = 'ClarolineForumBundle:Forum:open';
     $params['forum'] = $event->getResource()->getId();
     $subRequest = $request->duplicate(array(), null, $params);
     $response = $httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 /**
  * Fired when a ResourceNode of type Path is opened
  * @param  \Claroline\CoreBundle\Event\OpenResourceEvent $event
  * @throws \Exception
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $path = $event->getResource();
     if ($path->isPublished()) {
         // Path is published => display the Player
         $route = 'innova_path_player_wizard';
     } else {
         // Path is not published (so we can't play the Path) => display the Editor
         $route = 'innova_path_editor_wizard';
     }
     $url = $this->container->get('router')->generate($route, array('id' => $path->getId()));
     $event->setResponse(new RedirectResponse($url));
     $event->stopPropagation();
 }
 public function onOpen(OpenResourceEvent $event)
 {
     // Modification ERV (août 2015) InnovaERV
     // suite demande JJQ, voir son document de référence d'août 2015
     // il faut venir sur l'onglet "Mon espace collecticiel" et non plus sur "Drop"
     // Point 5 du document
     $collection = new ResourceCollection(array($event->getResource()->getResourceNode()));
     if (false === $this->container->get('security.authorization_checker')->isGranted('EDIT', $collection)) {
         $route = $this->container->get('router')->generate('innova_collecticiel_drop', array('resourceId' => $event->getResource()->getId()));
     } else {
         // Modification ERV (août 2015) InnovaERV
         // suite demande JJQ, voir son document de référence d'août 2015
         // il faut venir sur l'onglet "Demandes adressées" et non plus sur "Paramètres"
         // Point 3 du document
         $em = $this->container->get('doctrine.orm.entity_manager');
         $dropzone = $em->getRepository('InnovaCollecticielBundle:Dropzone')->find($event->getResource()->getId());
         // Pour savoir si le collecticiel est ouvert ou pas. InnovaERV
         $dropzoneManager = $this->container->get('innova.manager.dropzone_manager');
         if ($dropzoneManager->collecticielOpenOrNot($dropzone)) {
             $route = $this->container->get('router')->generate('innova_collecticiel_drops_awaiting', array('resourceId' => $event->getResource()->getId()));
         } else {
             $route = $this->container->get('router')->generate('innova_collecticiel_edit_common', array('resourceId' => $event->getResource()->getId()));
         }
     }
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_icap_dropzone")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = [];
     $collection = new ResourceCollection([$event->getResource()->getResourceNode()]);
     if (false === $this->container->get('security.authorization_checker')->isGranted('EDIT', $collection)) {
         $params['_controller'] = 'IcapDropzoneBundle:Dropzone:open';
     } else {
         $params['_controller'] = 'IcapDropzoneBundle:Dropzone:editCommon';
     }
     $params['resourceId'] = $event->getResource()->getId();
     $subRequest = $this->request->duplicate([], null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_innova_collecticiel")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = [];
     // Modification ERV (août 2015) InnovaERV
     // suite demande JJQ, voir son document de référence d'août 2015
     // il faut venir sur l'onglet "Mon espace collecticiel" et non plus sur "Drop"
     // Point 5 du document
     $collection = new ResourceCollection([$event->getResource()->getResourceNode()]);
     if (false === $this->container->get('security.authorization_checker')->isGranted('EDIT', $collection)) {
         $params['_controller'] = 'InnovaCollecticielBundle:Drop:drop';
     } else {
         // Modification ERV (août 2015) InnovaERV
         // suite demande JJQ, voir son document de référence d'août 2015
         // il faut venir sur l'onglet "Demandes adressées" et non plus sur "Paramètres"
         // Point 3 du document
         $em = $this->container->get('doctrine.orm.entity_manager');
         $dropzone = $em->getRepository('InnovaCollecticielBundle:Dropzone')->find($event->getResource()->getId());
         // Pour savoir si le collecticiel est ouvert ou pas. InnovaERV
         $dropzoneManager = $this->container->get('innova.manager.dropzone_manager');
         if ($dropzoneManager->collecticielOpenOrNot($dropzone)) {
             $params['_controller'] = 'InnovaCollecticielBundle:Drop:dropsAwaiting';
         } else {
             $params['_controller'] = 'InnovaCollecticielBundle:Dropzone:editCommon';
         }
     }
     $params['resourceId'] = $event->getResource()->getId();
     $subRequest = $this->request->duplicate([], null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
Beispiel #11
0
 /**
  * Fired when a ResourceNode of type Path is opened.
  *
  * @DI\Observe("open_innova_path")
  *
  * @param \Claroline\CoreBundle\Event\OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = [];
     $path = $event->getResource();
     if ($path->isPublished()) {
         // Path is published => display the Player
         $params['_controller'] = 'innova_path.controller.path_player:displayAction';
     } else {
         // Path is not published (so we can't play the Path) => display the Editor
         $params['_controller'] = 'innova_path.controller.path_editor:displayAction';
     }
     $params['id'] = $path->getId();
     $subRequest = $this->request->duplicate([], null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 public function onOpen(OpenResourceEvent $event)
 {
     $collection = new ResourceCollection(array($event->getResource()->getResourceNode()));
     if (false === $this->container->get('security.authorization_checker')->isGranted('EDIT', $collection)) {
         $route = $this->container->get('router')->generate('icap_dropzone_open', array('resourceId' => $event->getResource()->getId()));
     } else {
         $route = $this->container->get('router')->generate('icap_dropzone_edit', array('resourceId' => $event->getResource()->getId()));
     }
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
Beispiel #13
0
 /**
  * @DI\Observe("open_text")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $text = $event->getResource();
     $collection = new ResourceCollection(array($text->getResourceNode()));
     $isGranted = $this->container->get('security.authorization_checker')->isGranted('EDIT', $collection);
     $revisionRepo = $this->container->get('doctrine.orm.entity_manager')->getRepository('ClarolineCoreBundle:Resource\\Revision');
     $content = $this->container->get('templating')->render('ClarolineCoreBundle:Text:index.html.twig', array('text' => $revisionRepo->getLastRevision($text)->getContent(), '_resource' => $text, 'isEditGranted' => $isGranted));
     $response = new Response($content);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 public function onOpen(OpenResourceEvent $event)
 {
     $route = $this->container->get('router')->generate('cpasimusante_choose_item', array('id' => $event->getResource()->getId()));
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_claroline_announcement_aggregate")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = array();
     $params['_controller'] = 'ClarolineAnnouncementBundle:Announcement:announcementsList';
     $params['aggregateId'] = $event->getResource()->getId();
     $subRequest = $this->request->duplicate(array(), null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 public function onOpen(OpenResourceEvent $event)
 {
     $route = $this->container->get('router')->generate('icap_lesson', array('resourceId' => $event->getResource()->getId()));
     $event->setResponse(new RedirectResponse($route));
     $event->stopPropagation();
 }
Beispiel #17
0
 /**
  * @DI\Observe("open_claroline_survey")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = array();
     $params['_controller'] = 'ClarolineSurveyBundle:Survey:index';
     $params['survey'] = $event->getResource()->getId();
     $subRequest = $this->request->duplicate(array(), null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_claroline_scorm_12")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     if (!$this->request) {
         throw new NoHttpRequestException();
     }
     $scorm = $event->getResource();
     $params['_controller'] = 'ClarolineScormBundle:Scorm:renderScorm12Resource';
     $params['scormId'] = $scorm->getId();
     $subRequest = $this->request->duplicate(array(), null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
Beispiel #19
0
 /**
  * @DI\Observe("open_claroline_flashcard")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $subRequest = $this->request->duplicate([], null, ['_controller' => 'ClarolineFlashCardBundle:Deck:deck', 'id' => $event->getResource()->getId()]);
     $event->setResponse($this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST));
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_cpasimusante_simuresource")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     //Redirection to the controller.
     $route = $this->container->get('router')->generate('cpasimusante_simuresource_resource_open', array('simuresourceId' => $event->getResource()->getId()));
     $response = new RedirectResponse($route);
     $event->setResponse($response);
     $event->stopPropagation();
 }
Beispiel #21
0
 /**
  * @DI\Observe("open_hevinci_url")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     if (!$this->request) {
         throw new NoHttpRequestException();
     }
     $url = $event->getResource();
     $isIframe = $event->isIframe();
     if ($url->getInternalUrl()) {
         $event->setResponse(new RedirectResponse($this->request->getSchemeAndHttpHost() . $this->request->getScriptName() . $url->getUrl()));
         return;
     } else {
         if ($isIframe) {
             $headers = get_headers($url->getUrl(), 1);
             if (isset($headers['X-Frame-Options']) && $headers['X-Frame-Options'] === 'SAMEORIGIN') {
                 $href = "<a href='{$url->getUrl()}'>{$url->getUrl()}</a>";
                 $response = new Response($href);
                 $event->setResponse($response);
                 return;
             }
         }
     }
     $event->setResponse(new RedirectResponse($url->getUrl()));
 }
Beispiel #22
0
 /**
  * @DI\Observe("open_hevinci_url")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     if (!$this->request) {
         throw new NoHttpRequestException();
     }
     $url = $event->getResource();
     if ($url->getInternalUrl()) {
         $event->setResponse(new RedirectResponse($this->request->getSchemeAndHttpHost() . $this->request->getScriptName() . $url->getUrl()));
     } else {
         $event->setResponse(new RedirectResponse($url->getUrl()));
     }
 }
 /**
  * @DI\Observe("open_claroline_web_resource")
  *
  * @param \Claroline\CoreBundle\Event\CreateResourceEvent|\Claroline\CoreBundle\Event\OpenResourceEvent $event
  */
 public function onOpenWebResource(OpenResourceEvent $event)
 {
     $hash = $event->getResource()->getHashName();
     $content = $this->container->get('templating')->render('ClarolineWebResourceBundle::webResource.html.twig', ['workspace' => $event->getResource()->getResourceNode()->getWorkspace(), 'path' => $hash . '/' . $this->guessRootFileFromUnzipped($this->zipPath . $hash), '_resource' => $event->getResource()]);
     $event->setResponse(new Response($content));
     $event->stopPropagation();
 }
 /**
  * @Observe("open_activity")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $activity = $event->getResource();
     $params = $activity->getParameters();
     $user = $this->tokenStorage->getToken()->getUser();
     if ($user === 'anon.') {
         throw new AccessDeniedException();
     }
     $evaluation = $this->activityManager->getEvaluationByUserAndActivityParams($user, $params) ?: $this->activityManager->createBlankEvaluation($user, $params);
     $content = $this->templating->render('ClarolineCoreBundle:Activity:index.html.twig', array('_resource' => $activity, 'activityParams' => $params, 'evaluation' => $evaluation));
     $response = new Response($content);
     $event->setResponse($response);
     $event->stopPropagation();
 }
Beispiel #25
0
 /**
  * @DI\Observe("open_file")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $ds = DIRECTORY_SEPARATOR;
     $resource = $event->getResource();
     $mimeType = $resource->getResourceNode()->getMimeType();
     $eventName = strtolower(str_replace('/', '_', 'play_file_' . $mimeType));
     $eventName = str_replace('"', '', $eventName);
     $playEvent = $this->container->get('claroline.event.event_dispatcher')->dispatch($eventName, 'PlayFile', array($resource));
     if ($playEvent->getResponse() instanceof Response) {
         $response = $playEvent->getResponse();
     } else {
         $mimeElements = explode('/', $mimeType);
         $baseType = strtolower($mimeElements[0]);
         $fallBackPlayEventName = 'play_file_' . $baseType;
         $fallBackPlayEvent = $this->container->get('claroline.event.event_dispatcher')->dispatch($fallBackPlayEventName, 'PlayFile', array($resource));
         if ($fallBackPlayEvent->getResponse() instanceof Response) {
             $response = $fallBackPlayEvent->getResponse();
         } else {
             $item = $this->container->getParameter('claroline.param.files_directory') . $ds . $resource->getHashName();
             $file = file_get_contents($item);
             $response = new Response();
             $response->setContent($file);
             $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
             $response->headers->set('Content-Type', 'application/force-download');
             $response->headers->set('Content-Disposition', 'attachment; filename=' . urlencode($resource->getResourceNode()->getName()));
             $response->headers->set('Content-Type', 'application/' . pathinfo($item, PATHINFO_EXTENSION));
             $response->headers->set('Connection', 'close');
         }
     }
     $event->setResponse($response);
     $event->stopPropagation();
 }
Beispiel #26
0
 /**
  * @DI\Observe("open_directory")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $dir = $event->getResourceNode();
     $file = $this->resourceManager->download(array($dir));
     $response = new StreamedResponse();
     $response->setCallBack(function () use($file) {
         readfile($file);
     });
     $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
     $response->headers->set('Content-Type', 'application/force-download');
     $response->headers->set('Content-Disposition', 'attachment; filename=archive');
     $response->headers->set('Content-Type', 'application/zip');
     $response->headers->set('Connection', 'close');
     $event->setResponse($response);
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("open_claroline_chat_room")
  *
  * @param OpenResourceEvent $event
  */
 public function onOpen(OpenResourceEvent $event)
 {
     $params = [];
     $params['_controller'] = 'ClarolineChatBundle:Chat:chatRoomOpen';
     $params['chatRoom'] = $event->getResource()->getId();
     $subRequest = $this->request->duplicate([], null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }