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
135
136
137
138
139
140
141
142
143
|
<?php
/*
* Wizard for configuring login screen (lightdm greeter)
*/
const SCRN_SESSION_DATA = 'lgnscrndata';
const FIELDS = [
'clock-text-style' => ['default' => 'border:none; color:#fff; font-size:14pt; qproperty-alignment:AlignRight'],
'clock-background-style' => ['default' => 'border:none; background:#888687'],
'clock-shadow' => ['default' => '1 1 #555 1', 'regex' => '\s*([0-9-]+(\s+[0-9-]+(\s+[#0-9a-zA-Z]+(\s+[0-9-]+)?)?)?)?\s*'],
'username-placeholder' => ['default' => 'user id'],
'password-placeholder' => ['default' => 'password'],
'shib-session-button-text' => ['default' => 'Shibboleth-Login'],
'qr-session-button-text' => ['default' => 'QR-Code Login'],
'user-session-button-text' => ['default' => 'Campus-Login'],
'guest-session-button-text' => ['default' => 'Gastsitzung'],
'guest-session-start-text' => ['default' => 'Gast-Sitzungen sind möglicherweise auf einzelne' .
' (z.B. ausschließlich interne) Webseiten beschränkt.'],
'guest-session-start-button-text' => ['default' => 'Starten einer Gastsitzung'],
'reset-timeout' => ['default' => 30, 'regex' => '[0-9]*'],
];
/* For translation scanner
Dictionary::translate('ls_clock-text-style'),
Dictionary::translate('ls_clock-background-style'),
Dictionary::translate('ls_clock-shadow'),
Dictionary::translate('ls_username-placeholder'),
Dictionary::translate('ls_password-placeholder'),
Dictionary::translate('ls_shib-session-button-text'),
Dictionary::translate('ls_qr-session-button-text'),
Dictionary::translate('ls_user-session-button-text'),
Dictionary::translate('ls_guest-session-button-text'),
Dictionary::translate('ls_guest-session-start-text'),
Dictionary::translate('ls_guest-session-start-button-text'),
Dictionary::translate('ls_reset-timeout'),
*/
class LoginScreen_Start extends AddModule_Base
{
protected function renderInternal()
{
/* Load or initialise session data */
if (Request::get('back', 'false', 'string') !== 'false') {
/* If coming via the back button, load the session data */
$session_data = Session::get(SCRN_SESSION_DATA);
if (!is_array($session_data)) {
$session_data = [];
}
} elseif ($this->edit !== null) {
$session_data = $this->edit->getData(null);
Session::set(SCRN_SESSION_DATA, $session_data);
} else {
$session_data = [];
Session::set(SCRN_SESSION_DATA, false);
}
if (empty($session_data)) {
$session_data = [];
foreach (FIELDS as $key => $value) {
$session_data[$key] = $value['default'];
}
}
$data = [];
foreach (FIELDS as $key => $opts) {
$data[] = [
'field' => $key,
'value' => $session_data[$key] ?? '',
'caption' => Dictionary::translate('ls_' . $key),
'regex' => $opts['regex'] ?? null,
];
}
Render::addDialog(Dictionary::translateFile('config-module', 'loginscreen_title'),
false, 'loginscreen-start', [
'next' => 'LoginScreen_Finish',
'edit' => $this->edit !== null ? $this->edit->id() : 0,
'fields' => $data,
'title' => $this->edit !== null ? $this->edit->title() : '',
]);
}
}
class LoginScreen_Finish extends AddModule_Base
{
protected function preprocessInternal()
{
$title = trim(Request::post('title', '', 'string'));
if (empty($title)) {
Util::redirect('?do=sysconfig&action=addmodule&step=LoginScreen_Start&back=true');
}
$session_data = Session::get(SCRN_SESSION_DATA);
if (!is_array($session_data)) {
$session_data = [];
}
$session_data['title'] = $title;
/* Only create an instance if it's a new one */
if ($this->edit !== null) {
$module = $this->edit;
} else {
$module = ConfigModule::getInstance('LoginScreen');
}
$err = false;
foreach (FIELDS as $key => $field) {
$val = Request::post($key, '', 'string');
if (isset($field['regex']) && !preg_match("/{$field['regex']}/", $val)) {
Message::addError('regex-mismatch', $val, $field['regex']);
$err = true;
}
$session_data[$key] = $val;
$module->setData($key, $val);
}
if ($err) {
Session::set(SCRN_SESSION_DATA, $session_data);
Util::redirect('?do=sysconfig&action=addmodule&step=LoginScreen_Start&back=true');
}
/* Insert or update database entries */
if ($this->edit !== null) {
$module->update($session_data['title']);
} else {
$module->insert($session_data['title']);
}
$task = $module->generate($this->edit === null);
// Yay
Session::set(SCRN_SESSION_DATA, false);
if ($task !== false && $this->edit !== null) {
Message::addSuccess('module-edited');
} elseif ($task !== false) {
Message::addSuccess('module-added');
AddModule_Base::setStep('AddModule_Assign', $module->id());
return;
}
Util::redirect('?do=SysConfig');
}
}
|