view.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\PluginBundle\Entity\EmbedRegistry\Embed;
  4. require_once __DIR__.'/../../main/inc/global.inc.php';
  5. api_block_anonymous_users();
  6. api_protect_course_script(true);
  7. $plugin = EmbedRegistryPlugin::create();
  8. if ('false' === $plugin->get(EmbedRegistryPlugin::SETTING_ENABLED)) {
  9. api_not_allowed(true);
  10. }
  11. $isAllowedToEdit = api_is_allowed_to_edit(true);
  12. $em = Database::getManager();
  13. $embedRepo = $em->getRepository('ChamiloPluginBundle:EmbedRegistry\Embed');
  14. $course = api_get_course_entity(api_get_course_int_id());
  15. $session = api_get_session_entity(api_get_session_id());
  16. $embedId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
  17. if (!$embedId) {
  18. api_not_allowed(true);
  19. }
  20. /** @var Embed|null $embed */
  21. $embed = $embedRepo->find($embedId);
  22. if (!$embed) {
  23. api_not_allowed(
  24. true,
  25. Display::return_message($plugin->get_lang('ContentNotFound'), 'danger')
  26. );
  27. }
  28. if ($course->getId() !== $embed->getCourse()->getId()) {
  29. api_not_allowed(true);
  30. }
  31. if ($session && $embed->getSession()) {
  32. if ($session->getId() !== $embed->getSession()->getId()) {
  33. api_not_allowed(true);
  34. }
  35. }
  36. $plugin->saveEventAccessTool();
  37. $interbreadcrumb[] = [
  38. 'name' => $plugin->getToolTitle(),
  39. 'url' => api_get_path(WEB_PLUGIN_PATH).$plugin->get_name().'/start.php',
  40. ];
  41. $actions = Display::url(
  42. Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
  43. api_get_path(WEB_PLUGIN_PATH).$plugin->get_name().'/start.php?'.api_get_cidreq()
  44. );
  45. $view = new Template($embed->getTitle());
  46. $view->assign('header', $embed->getTitle());
  47. $view->assign('actions', Display::toolbarAction($plugin->get_name(), [$actions]));
  48. $view->assign(
  49. 'content',
  50. '<p>'.$plugin->formatDisplayDate($embed).'</p>'
  51. .PHP_EOL
  52. .Security::remove_XSS($embed->getHtmlCode(), COURSEMANAGERLOWSECURITY)
  53. );
  54. $view->display_one_col_template();