1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | |||
4 | use Chamilo\CoreBundle\Entity\Course; |
||
0 ignored issues
–
show
|
|||
5 | use Chamilo\CoreBundle\Entity\Session; |
||
6 | use Chamilo\CourseBundle\Entity\CSurvey; |
||
7 | use Chamilo\CourseBundle\Entity\CSurveyInvitation; |
||
8 | |||
9 | $cidReset = true; |
||
10 | |||
11 | require_once __DIR__.'/../inc/global.inc.php'; |
||
12 | |||
13 | api_block_anonymous_users(); |
||
14 | |||
15 | $em = Database::getManager(); |
||
16 | |||
17 | $currentUser = api_get_user_entity(api_get_user_id()); |
||
18 | $avatarPath = UserManager::getUserPicture($currentUser->getId()); |
||
19 | $pending = SurveyUtil::getUserPendingInvitations($currentUser->getId()); |
||
20 | |||
21 | $surveysData = []; |
||
22 | |||
23 | foreach ($pending as $i => $item) { |
||
24 | if (is_a($item, 'Chamilo\CourseBundle\Entity\CSurveyInvitation')) { |
||
25 | continue; |
||
26 | } |
||
27 | |||
28 | /** @var CSurvey $survey */ |
||
29 | $survey = $item; |
||
30 | /** @var CSurveyInvitation invitation */ |
||
31 | $invitation = $pending[$i + 1]; |
||
32 | /** @var Course $course */ |
||
33 | $course = $em->find('ChamiloCoreBundle:Course', $survey->getCId()); |
||
34 | /** @var Session $session */ |
||
35 | $session = $em->find('ChamiloCoreBundle:Session', $survey->getSessionId()); |
||
36 | |||
37 | $course = $course ? ['id' => $course->getId(), 'title' => $course->getTitle(), 'code' => $course->getCode()] : null; |
||
38 | $session = $session ? ['id' => $session->getId(), 'name' => $session->getName()] : null; |
||
39 | |||
40 | $surveysData[$survey->getSurveyId()] = [ |
||
41 | 'title' => $survey->getTitle(), |
||
42 | 'avail_from' => $survey->getAvailFrom(), |
||
43 | 'avail_till' => $survey->getAvailTill(), |
||
44 | 'course' => $course, |
||
45 | 'session' => $session, |
||
46 | 'link' => SurveyUtil::generateFillSurveyLink( |
||
47 | $invitation->getInvitationCode(), |
||
48 | api_get_course_info_by_id($course['id']), |
||
49 | $survey->getSessionId() |
||
50 | ), |
||
51 | ]; |
||
52 | } |
||
53 | |||
54 | $toolName = get_lang('PendingSurveys'); |
||
55 | |||
56 | $template = new Template($toolName); |
||
57 | $template->assign('user', $currentUser); |
||
58 | $template->assign('user_avatar', $avatarPath); |
||
59 | $template->assign('surveys', $surveysData); |
||
60 | $layout = $template->get_template('survey/pending.tpl'); |
||
61 | $content = $template->fetch($layout); |
||
62 | $template->assign('header', $toolName); |
||
63 | $template->assign('content', $content); |
||
64 | $template->display_one_col_template(); |
||
65 |
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: