forked from virtUOS/studip-unterrichtsplanung
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnterrichtsplanung.class.php
81 lines (64 loc) · 2.6 KB
/
Unterrichtsplanung.class.php
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
71
72
73
74
75
76
77
78
79
80
81
<?php
use Unterrichtsplanung\AppFactory;
use Unterrichtsplanung\RouteMap;
class Unterrichtsplanung extends \StudIPPlugin implements \SystemPlugin
{
const rolename = 'Unterrichtsplanung_Admin';
public function __construct()
{
parent::__construct();
if ($GLOBALS['perm']->have_perm('autor')) {
$main = new Navigation(_('Unterrichtsplanung'));
$main->setImage(Icon::create('topic'));
$main->setURL(PluginEngine::getURL('unterrichtsplanung/index'));
$overview = new Navigation(_('Unterrichtsplanung'));
$overview->setURL(PluginEngine::getURL('unterrichtsplanung/index'));
$start = clone $main;
$main->addSubNavigation('index', $overview);
if ($GLOBALS['perm']->have_perm('root')
|| \RolePersistence::isAssignedRole(
$GLOBALS['user']->user_id,
'Unterrichtsplanung_Admin'
)
) {
$admin = new Navigation(_('Administration'));
$admin->setURL(PluginEngine::getURL('unterrichtsplanung/admin'));
$main->addSubNavigation('admin', $admin);
Navigation::addItem('/start/unterrichtsplanung', $main);
} else {
Navigation::addItem('/start/unterrichtsplanung', $start);
}
Navigation::addItem('/unterrichtsplanung', $main);
PageLayout::setHelpKeyword('Basis/Unterrichtsplanung'); // Hilfeseite im Hilfewiki
}
}
public static function onEnable($plugin_id)
{
$stmt = DBManager::get()->prepare('SELECT * FROM roles WHERE rolename = ?');
$stmt->execute([self::rolename]);
$role_id = $stmt->fetchColumn();
RolePersistence::assignPluginRoles($plugin_id, [$role_id, 7]);
}
/**
* {@inheritdoc}
*
* @SuppressWarnings(UnusedFormalParameter)
*/
public function perform($unconsumedPath)
{
require __DIR__.'/composer_modules/autoload.php';
if (substr($unconsumedPath, 0, 3) == 'api') {
$appFactory = new AppFactory();
$app = $appFactory->makeApp($this);
$app->group('/unterrichtsplanung/api', new RouteMap($app));
$app->run();
} else {
$trails_root = $this->getPluginPath() . '/app';
$dispatcher = new Trails_Dispatcher($trails_root,
rtrim(PluginEngine::getURL($this, null, ''), '/'),
'index');
$dispatcher->current_plugin = $this;
$dispatcher->dispatch($unconsumedPath);
}
}
}