/** * @Route("/{tool}/create") * @Template("ChamiloCourseBundle:CToolIntro:create.html.twig") * @return array */ public function createAction(Request $request, $tool) { // Breadcrumb $breadCrumb = $this->get('chamilo_core.block.breadcrumb'); $breadCrumb->addChild($this->trans('Introduction'), ['route' => 'chamilo_course_ctoolintro_index', 'routeParameters' => ['course' => $this->getCourse()->getCode()]]); $breadCrumb->addChild($this->trans('Create')); $course = $this->getCourse(); $session = $this->getSession(); $toolIntro = new CToolIntro(); $toolIntro->setSessionId(0)->setTool($tool)->setCId($course->getId()); if ($session) { $toolIntro->setSessionId($session->getId()); } $formService = $this->get('chamilo_course.form.type.c_tool_intro'); $form = $this->createForm($formService, $toolIntro); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($toolIntro); $em->flush(); $this->addFlash('success', $this->trans('Saved')); return $this->redirectToRoute('chamilo_course_ctoolintro_update', ['course' => $course->getCode(), 'iid' => $toolIntro->getId()]); } return ['form' => $form->createView(), 'tool' => $tool]; }
/* INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED) */ $course_id = api_get_course_int_id(); if ($intro_editAllowed) { /* Replace command */ if ($intro_cmdUpdate) { if ($form->validate()) { $form_values = $form->exportValues(); $intro_content = Security::remove_XSS(stripslashes(api_html_entity_decode($form_values['intro_content'])), COURSEMANAGERLOWSECURITY); $criteria = ['cId' => $course_id, 'id' => $moduleId, 'sessionId' => $session_id]; if (!empty($intro_content)) { /** @var CToolIntro $toolIntro */ $toolIntro = Database::getManager()->getRepository('ChamiloCourseBundle:CToolIntro')->findOneBy($criteria); if ($toolIntro) { $toolIntro->setIntroText($intro_content); } else { $toolIntro = new CToolIntro(); $toolIntro->setSessionId($session_id)->setCId($course_id)->setIntroText($intro_content)->setId($moduleId); } Database::getManager()->persist($toolIntro); Database::getManager()->flush(); $introduction_section .= Display::return_message(get_lang('IntroductionTextUpdated'), 'confirmation', false); } else { // got to the delete command $intro_cmdDel = true; } } else { $intro_cmdEdit = true; } } /* Delete Command */ if ($intro_cmdDel) {