1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | |||
4 | use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; |
||
5 | use Symfony\Component\HttpFoundation\Request; |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | $cidReset = true; |
||
8 | |||
9 | require_once __DIR__.'/../../main/inc/global.inc.php'; |
||
10 | |||
11 | api_protect_admin_script(); |
||
12 | |||
13 | $plugin = ImsLtiPlugin::create(); |
||
14 | $webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ims_lti/'; |
||
15 | |||
16 | $request = Request::createFromGlobals(); |
||
17 | $ltiToolId = $request->query->getInt('id'); |
||
18 | |||
19 | $em = Database::getManager(); |
||
20 | |||
21 | try { |
||
22 | if ($plugin->get('enabled') !== 'true') { |
||
23 | throw new Exception(get_lang('NotAllowed')); |
||
24 | } |
||
25 | |||
26 | /** @var ImsLtiTool $tool */ |
||
27 | $tool = $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $ltiToolId); |
||
28 | |||
29 | if (!$tool) { |
||
30 | throw new Exception($plugin->get_lang('NoTool')); |
||
31 | } |
||
32 | |||
33 | if ($tool->getParent()) { |
||
34 | throw new Exception($plugin->get_lang('NoAllowed')); |
||
35 | } |
||
36 | |||
37 | $content = ''; |
||
38 | |||
39 | $form = new FormValidator('frm_multiply', 'post', api_get_self().'?id='.$tool->getId()); |
||
40 | $form->addLabel($plugin->get_lang('Tool'), $tool->getName()); |
||
41 | $form->addSelectAjax( |
||
42 | 'sessions', |
||
43 | get_lang('Sessions'), |
||
44 | [], |
||
45 | [ |
||
46 | 'url' => api_get_path(WEB_AJAX_PATH).'session.ajax.php?'.http_build_query( |
||
47 | [ |
||
48 | 'a' => 'search_session', |
||
49 | ] |
||
50 | ), |
||
51 | ] |
||
52 | ); |
||
53 | $form->addHidden('tool_id', $tool->getId()); |
||
54 | $form->addButtonExport(get_lang('Next')); |
||
55 | |||
56 | if ($form->validate()) { |
||
57 | $em = Database::getManager(); |
||
58 | $formValues = $form->exportValues(); |
||
59 | $formValues['sessions'] = empty($formValues['sessions']) ? [] : $formValues['sessions']; |
||
60 | |||
61 | if (!$formValues['sessions']) { |
||
62 | Display::addFlash( |
||
63 | Display::return_message($plugin->get_lang('NeedToSelectASession'), 'error', false) |
||
64 | ); |
||
65 | header('Location:'.api_get_self()); |
||
66 | exit; |
||
67 | } |
||
68 | |||
69 | header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/multiply_session.php?id='.$formValues['tool_id'].'&session_id='.$formValues['sessions']); |
||
70 | |||
71 | exit; |
||
72 | } |
||
73 | |||
74 | $form->protect(); |
||
75 | |||
76 | $content = $form->returnForm(); |
||
77 | |||
78 | $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; |
||
79 | $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; |
||
80 | |||
81 | $template = new Template($plugin->get_lang('AddInSessions')); |
||
82 | $template->assign('header', $plugin->get_lang('AddInSessions')); |
||
83 | $template->assign('content', $content); |
||
84 | $template->display_one_col_template(); |
||
85 | } catch (Exception $exception) { |
||
86 | Display::addFlash( |
||
87 | Display::return_message($exception->getMessage(), 'error') |
||
88 | ); |
||
89 | |||
90 | header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); |
||
91 | } |
||
92 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: