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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
<?php
use Lti\Deployment;
use Lti\Registration;
use Ramsey\Uuid\Uuid;
use Studip\Lti\Controller\AdminBaseController;
class Admin_Lti_DeploymentsController extends AdminBaseController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
if ($this->range_id) {
Navigation::activateItem('/course/lti/registrations');
} else {
Navigation::activateItem('/admin/config/lti');
}
PageLayout::setTitle(_('LTI-Deployments'));
$this->role = Request::get('role', 'tool');
$this->buildRegistrationsSidebar();
}
public function index_action(): void
{
$registration = Registration::find(Request::option('registration_id'));
if (!$registration) {
throw new Exception('Missing or invalid registration ID!');
}
PageLayout::setTitle(_(sprintf('LTI-Deployments „%s“', htmlReady($registration->name))));
$this->render_vue_app(
Studip\VueApp::create('lti/deployments/Index')
->withProps([
'registration' => $registration->transformData(),
'deployments' => $registration->deployments->transformData()
])
);
}
public function create_action(): void
{
PageLayout::setTitle(_('Neues Deployment anlegen'));
$this->render_vue_app(
Studip\VueApp::create('lti/deployments/Create')
->withProps([
'registration' => Registration::find(Request::option('registration_id'))->transformData()
])
);
}
public function store_action(): void
{
CSRFProtection::verifyUnsafeRequest();
$deployment = Deployment::create([
'name' => Request::get('name'),
'registration_id' => Request::get('registration_id'),
'deployment_key' => Request::get('deployment_key'),
'client_id' => Request::get('client_id', Uuid::uuid4()->toString())
]);
PageLayout::postSuccess(
sprintf(
_('Das LTI-Deployment „%s“ wurde gespeichert.'),
htmlReady($deployment->name)
)
);
$this->redirect('admin/lti/deployments', ['registration_id' => $deployment->registration_id]);
}
public function edit_action(Deployment $deployment): void
{
PageLayout::setTitle(_('LTI-Deployment bearbeiten'));
$this->render_vue_app(
Studip\VueApp::create('lti/deployments/Edit')
->withProps([
'deployment' => $deployment->transformData(),
'registration' => $deployment->registration->transformData()
])
);
}
public function update_action(Deployment $deployment): void
{
CSRFProtection::verifyUnsafeRequest();
$deployment->setData([
'name' => Request::get('name'),
'deployment_key' => Request::get('deployment_key'),
'client_id' => Request::get('client_id', $deployment->client_id)
]);
$deployment->store();
PageLayout::postSuccess(
sprintf(
_('Das LTI-Deployment „%s“ wurde gespeichert.'),
htmlReady($deployment->name)
)
);
$this->redirect('admin/lti/deployments', ['registration_id' => $deployment->registration_id]);
}
public function delete_action(Deployment $deployment): void
{
CSRFProtection::verifyUnsafeRequest();
$registrationId = $deployment->registration_id;
$deploymentName = $deployment->name;
if ($deployment->is_default) {
PageLayout::postError(_('Das Standard-Deployment konnte nicht gelöscht werden.'));
$this->redirect('admin/lti/deployments', ['registration_id' => $registrationId]);
return;
}
$deployment->delete();
PageLayout::postSuccess(
sprintf(
_('Die LTI-Registrierung „%s“ wurde gelöscht.'),
htmlReady($deploymentName)
)
);
$this->redirect('admin/lti/deployments', ['registration_id' => $registrationId]);
}
}
|