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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
<?php
/**
* admin/lti.php - LTI consumer API for Stud.IP
*
* 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.
*
* @author Elmar Ludwig
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
*/
class Admin_LtiController extends AuthenticatedController
{
/**
* Callback function being called before an action is executed.
*/
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
$GLOBALS['perm']->check('root');
Navigation::activateItem('/admin/config/lti');
PageLayout::setTitle(_('Konfiguration der LTI-Tools'));
$widget = Sidebar::get()->addWidget(new ActionsWidget());
$widget->addLink(
_('Neues LTI-Tool registrieren'),
$this->url_for('admin/lti/edit'),
Icon::create('add')
)->asDialog();
Helpbar::get()->addPlainText('', _('Hier können Sie Verknüpfungen mit externen Tools konfigurieren, sofern diese den LTI-Standard (Version 1.x) unterstützen.'));
}
/**
* Display the list of registered LTI tools.
*/
public function index_action()
{
$this->tools = LtiTool::findAll();
}
/**
* Display dialog for editing an LTI tool.
*
* @param int $id tool id
*/
public function edit_action($id = null)
{
$this->tool = new LtiTool($id);
}
/**
* Save changes for an LTI tool.
*
* @param int $id tool id
*/
public function save_action($id)
{
CSRFProtection::verifyUnsafeRequest();
$tool = new LtiTool($id ?: null);
$tool->name = trim(Request::get('name'));
$tool->launch_url = trim(Request::get('launch_url'));
$tool->consumer_key = trim(Request::get('consumer_key'));
$tool->consumer_secret = trim(Request::get('consumer_secret'));
$tool->custom_parameters = trim(Request::get('custom_parameters'));
$tool->allow_custom_url = Request::int('allow_custom_url', 0);
$tool->deep_linking = Request::int('deep_linking', 0);
$tool->send_lis_person = Request::int('send_lis_person', 0);
$tool->oauth_signature_method = Request::get('oauth_signature_method', 'sha1');
if ($tool->store()) {
PageLayout::postSuccess(sprintf(
_('Einstellungen für "%s" wurden gespeichert.'),
htmlReady($tool->name)
));
}
$this->redirect('admin/lti');
}
/**
* Delete an LTI tool.
*
* @param int $id tool id
*/
public function delete_action($id)
{
CSRFProtection::verifyUnsafeRequest();
$tool = LtiTool::find($id);
$tool_name = $tool->name;
if ($tool && $tool->delete()) {
PageLayout::postSuccess(sprintf(
_('Das LTI-Tool "%s" wurde gelöscht.'),
htmlReady($tool_name)
));
}
$this->redirect('admin/lti');
}
}
|