1 | <?php |
||
2 | /* For license terms, see /license.txt */ |
||
3 | |||
4 | use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; |
||
5 | |||
6 | require_once __DIR__.'/../../main/inc/global.inc.php'; |
||
7 | |||
8 | api_protect_course_script(); |
||
9 | |||
10 | $em = Database::getManager(); |
||
11 | |||
12 | /** @var ImsLtiTool $tool */ |
||
13 | $tool = isset($_GET['id']) ? $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', intval($_GET['id'])) : null; |
||
14 | $user = api_get_user_entity( |
||
15 | api_get_user_id() |
||
16 | ); |
||
17 | |||
18 | if (!$tool) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
19 | api_not_allowed(true); |
||
20 | } |
||
21 | |||
22 | $imsLtiPlugin = ImsLtiPlugin::create(); |
||
23 | |||
24 | $pageTitle = Security::remove_XSS($tool->getName()); |
||
25 | $publicKey = ImsLtiPlugin::getToolPublicKey($tool); |
||
26 | |||
27 | $is1p3 = !empty($publicKey) && !empty($tool->getClientId()) && |
||
28 | !empty($tool->getLoginUrl()) && !empty($tool->getRedirectUrl()); |
||
29 | |||
30 | if ($is1p3) { |
||
31 | $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/login.php?id='.$tool->getId(); |
||
32 | } else { |
||
33 | $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/form.php?'.http_build_query(['id' => $tool->getId()]); |
||
34 | } |
||
35 | |||
36 | if ($tool->getDocumentTarget() == 'window') { |
||
37 | header("Location: $launchUrl"); |
||
38 | exit; |
||
39 | } |
||
40 | |||
41 | $template = new Template($pageTitle); |
||
42 | $template->assign('tool', $tool); |
||
43 | |||
44 | $template->assign('launch_url', $launchUrl); |
||
45 | |||
46 | $content = $template->fetch('ImsLti/view/start.tpl'); |
||
47 | |||
48 | $template->assign('header', $pageTitle); |
||
49 | $template->assign('content', $content); |
||
50 | $template->display_one_col_template(); |
||
51 |