aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/loncapa.php
blob: dd7ea4085b7a1d72583f5df4799e602e353e1735 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
class LoncapaController extends AuthenticatedController
{
    public function enter_action()
    {
        checkObject();
        checkObjectModule("elearning_interface");

        $cms_type = Request::get('cms_type');
        $module = Request::get('module');
        $course_id = Context::getId();

        if ($GLOBALS['perm']->have_studip_perm('user', $course_id)
            && isset($GLOBALS['ELEARNING_INTERFACE_MODULES'][$cms_type]))
        {
            require_once 'lib/elearning/ELearningUtils.php';
            require_once 'lib/elearning/ObjectConnections.php';

            $object_connections = new ObjectConnections($course_id);
            $connected_modules = $object_connections->getConnections();
            $reference = "{$cms_type}_loncapa_{$module}";

            if (isset($connected_modules[$reference])
                && ELearningUtils::isCMSActive($cms_type))
            {
                ELearningUtils::loadClass($cms_type);
                $lclink = new LonCapaConnectedLink($cms_type);
                $this->redirect($lclink->getRedirectUrl($module, $course_id));
                return;
            }
        }
        throw new AccessDeniedException(_('LonCapa Zugang nicht erlaubt'));
    }
}