aboutsummaryrefslogtreecommitdiff
path: root/public/plugins.php
blob: 368113dc9e33432e4aa3649f6e701dfb8d30eacc (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
# Lifter007: TEST

/*
 * Copyright (C) 2007 - Marcus Lunzenauer <mlunzena@uos.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

require '../lib/bootstrap.php';

// set base url for URLHelper class
URLHelper::setBaseUrl($GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP']);

// initialize Stud.IP-Session
page_open([
    'sess' => 'Seminar_Session',
    'auth' => 'Seminar_Default_Auth',
    'perm' => 'Seminar_Perm',
    'user' => 'Seminar_User',
]);

try {
    require_once 'lib/seminar_open.php';

    // get plugin class from request
    $dispatch_to = Request::path_info();
    list($plugin_class, $unconsumed) = PluginEngine::routeRequest($dispatch_to);

    // handle legacy forum plugin URLs
    if ($plugin_class === 'coreforum') {
        header('Location: ' . URLHelper::getURL('dispatch.php/course/forum/' . $unconsumed));
        die();
    }

    // retrieve corresponding plugin info
    $plugin_manager = PluginManager::getInstance();
    $plugin_info = $plugin_manager->getPluginInfo($plugin_class);

    // create an instance of the queried plugin
    $plugin = PluginEngine::getPlugin($plugin_class);

    // user is not permitted, show login screen
    if (is_null($plugin)) {
        // TODO (mlunzena) should not getPlugin throw this exception?
        throw new AccessDeniedException(_('Sie besitzen keine Rechte zum Aufruf dieses Plugins.'));
    }

    // set default page title
    PageLayout::setTitle($plugin->getPluginName());

    // deprecated, the plugin should override perform() instead
    if (is_callable([$plugin, 'initialize'])) {
        $plugin->initialize();
    }

    // let the show begin
    $plugin->perform($unconsumed);
} catch (AccessDeniedException $ade) {
    global $auth;

    $auth->login_if($auth->auth['uid'] == 'nobody');
    throw $ade;
}

// close the page
page_close();