Ejemplo n.º 1
0
 public function onDelete(DeleteResourceEvent $event)
 {
     //transaction for when a workspace is removed.
     $em = $this->container->get('claroline.persistence.object_manager');
     $papers = $em->getRepository('UJMExoBundle:Paper')->findOneBy(array('exercise' => $event->getResource()->getId()));
     if (count($papers) == 0) {
         $eqs = $em->getRepository('UJMExoBundle:ExerciseQuestion')->findBy(array('exercise' => $event->getResource()->getId()));
         foreach ($eqs as $eq) {
             $em->remove($eq);
         }
         $subscriptions = $em->getRepository('UJMExoBundle:Subscription')->findBy(array('exercise' => $event->getResource()->getId()));
         foreach ($subscriptions as $subscription) {
             $em->remove($subscription);
         }
         $em->flush();
         $em->remove($event->getResource());
     } else {
         $exercise = $em->getRepository('UJMExoBundle:Exercise')->find($event->getResource()->getId());
         $resourceNode = $em->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->find($exercise->getResourceNode()->getId());
         $em->remove($resourceNode);
         $exercise->archiveExercise();
         $em->persist($exercise);
         $em->flush();
         exit;
     }
     $event->stopPropagation();
 }
Ejemplo n.º 2
0
 public function onDelete(DeleteResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $resource = $event->getResource();
     foreach ($resource->getDrops() as $drop) {
         $em->remove($drop);
     }
     $em->remove($event->getResource());
     $event->stopPropagation();
 }
Ejemplo n.º 3
0
 /**
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $blog = $event->getResource();
     $options = $blog->getOptions();
     @unlink($this->container->getParameter('icap.blog.banner_directory') . DIRECTORY_SEPARATOR . $options->getBannerBackgroundImage());
     $event->stopPropagation();
 }
Ejemplo n.º 4
0
 public function onDelete(DeleteResourceEvent $event)
 {
     $om = $this->container->get('claroline.persistence.object_manager');
     $lesson = $event->getResource();
     $om->remove($lesson);
     $om->flush();
     $event->stopPropagation();
 }
Ejemplo n.º 5
0
 public function onDelete(DeleteResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $lesson = $event->getResource();
     $lesson->setRoot(null);
     $em->flush();
     $em->remove($lesson);
     $em->flush();
     $event->stopPropagation();
 }
 /**
  * @DI\Observe("delete_innova_media_resource")
  **/
 public function onDelete(DeleteResourceEvent $event)
 {
     $mediaResource = $event->getResource();
     $manager = $this->container->get('innova_media_resource.manager.media_resource');
     $manager->delete($mediaResource);
     $event->stopPropagation();
 }
Ejemplo n.º 7
0
 /**
  * @DI\Observe("delete_claroline_survey")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $this->om->remove($event->getResource());
     $event->stopPropagation();
 }
Ejemplo n.º 8
0
 /**
  * @DI\Observe("delete_file")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $workspaceCode = $event->getResource()->getResourceNode()->getWorkspace()->getCode();
     $pathName = $this->container->getParameter('claroline.param.files_directory') . DIRECTORY_SEPARATOR . $event->getResource()->getHashName();
     if (file_exists($pathName)) {
         $event->setFiles(array($pathName));
     }
     $event->stopPropagation();
 }
Ejemplo n.º 9
0
 /**
  * @DI\Observe("delete_claroline_flashcard")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $this->manager->delete($event->getResource());
     $event->stopPropagation();
 }
Ejemplo n.º 10
0
 /**
  * @DI\Observe("delete_ujm_exercise")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $exercise = $event->getResource();
     $nbPapers = $em->getRepository('UJMExoBundle:Paper')->countExercisePapers($event->getResource());
     if (0 === $nbPapers) {
         $this->container->get('ujm.exo.subscription_manager')->deleteSubscriptions($exercise);
         $em->remove($exercise);
     } else {
         // If papers, the Exercise is not completely removed
         $event->enableSoftDelete();
         $em->remove($exercise->getResourceNode());
         $exercise->archiveExercise();
         $em->persist($exercise);
         $em->flush();
     }
     $event->stopPropagation();
 }
Ejemplo n.º 11
0
 /**
  * @DI\Observe("delete_claroline_web_resource")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $file = $this->filesPath . $event->getResource()->getHashName();
     $unzipFile = $this->zipPath . $event->getResource()->getHashName();
     if (file_exists($file)) {
         $event->setFiles([$file]);
     }
     if (file_exists($unzipFile)) {
         $this->unzipDelete($unzipFile);
     }
     $event->stopPropagation();
 }
Ejemplo n.º 12
0
 /**
  * @DI\Observe("delete_claroline_scorm_12")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $hashName = $event->getResource()->getHashName();
     $scormArchiveFile = $this->filePath . $hashName;
     $scormResourcesPath = $this->scormResourcesPath . $hashName;
     $nbScorm = (int) $this->scormResourceRepo->getNbScormWithHashName($hashName);
     if ($nbScorm === 1) {
         if (file_exists($scormArchiveFile)) {
             $event->setFiles(array($scormArchiveFile));
         }
         if (file_exists($scormResourcesPath)) {
             $this->deleteFiles($scormResourcesPath);
         }
     }
     $this->om->remove($event->getResource());
     $event->stopPropagation();
 }
Ejemplo n.º 13
0
 /**
  * @DI\Observe("delete_innova_collecticiel")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $em->remove($event->getResource());
     $event->stopPropagation();
 }
Ejemplo n.º 14
0
 /**
  * @DI\Observe("delete_icap_website")
  *
  * @param DeleteResourceEvent $event
  */
 public function onDelete(DeleteResourceEvent $event)
 {
     $this->container->get('icap.website.manager')->deleteWebsite($event->getResource());
     $event->stopPropagation();
 }