blob: 9784a1cd43599f1e0afa6b1c1d89425e11db0b96 (
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
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
|
<?php
/**
* show terms on first login and check if user accept them
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL2 or any later version
* @since Stud.IP 4.2
*/
class TermsController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
if ($GLOBALS['user']->cfg->TERMS_ACCEPTED) {
$this->redirectUser();
}
}
public function index_action()
{
PageLayout::setTitle(_('Nutzungsbedingungen'));
$this->return_to = Request::get('return_to');
$this->redirect_token = Request::get('redirect_token');
$this->compulsory = Config::get()->TERMS_CONFIG['compulsory'];
$this->denial_message = '';
$this->terms_of_use = $this->getTermsOfUse();
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();
if (Request::submitted('accept')) {
$GLOBALS['user']->cfg->store('TERMS_ACCEPTED', 1);
$this->redirectUser();
} else {
$_SESSION['logout_ticket'] = get_ticket();
$this->redirectUser('dispatch.php/logout');
}
} elseif (Request::get('action') === 'denied') {
if (trim(Config::get()->TERMS_CONFIG['denial_message'])) {
$this->denial_message = trim(Config::get()->TERMS_CONFIG['denial_message']);
} else {
$this->denial_message = sprintf(
_('Sie haben den Nutzungsbedingungen nicht zugestimmt und können '
. 'damit das System nicht nutzen. Bitte kontaktieren Sie Ihren '
. 'Support über folgende Adresse, um die nächsten Schritte '
. 'abzustimmen: %s'),
'<a href="mailto:' . $GLOBALS['UNI_CONTACT'] . '">' . $GLOBALS['UNI_CONTACT'] . '</a>'
);
}
}
}
private function redirectUser($target = null)
{
if (Token::isValid(Request::option('redirect_token')) && Request::get('return_to')) {
$target = Request::get('return_to') ;
} else {
$target = $target ?: 'dispatch.php/start';
}
$this->redirect(URLHelper::getURL($target));
}
/**
* @return array|null
*/
private function getTermsOfUse()
{
$url = Config::get()->TERMS_OF_USE_URL;
if ($url && is_internal_url($url)) {
$url_parts = explode('/', $url);
$detail_id = $url_parts[4];
$si = new Siteinfo();
$detail = $si->get_detail($detail_id);
if (empty($detail) || !empty($detail['draft_status']) || !empty($detail['page_disabled_nobody'])) {
return null;
}
return [
'type' => 'internal_url',
'content' => $si->get_detail_content_processed($detail_id)
];
}
return [
'type' => 'external_url',
'url' => $url
];
}
}
|