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
144
145
146
147
148
149
150
151
152
153
154
|
<?php
# Lifter010: TODO
/*
* Copyright (C) 2014 - Arne Schröder <schroeder@data-quest.de>
*
* formerly institut_main.php - Die Eingangsseite fuer ein Institut
*
* 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.
*/
class Institute_OverviewController extends AuthenticatedController
{
protected $allow_nobody = true;
public function __construct(\Trails\Dispatcher $dispatcher)
{
if (Request::option('auswahl')) {
Request::set('cid', Request::option('auswahl'));
}
//Check if anonymous access is really allowed:
$config = Config::get();
if (($config->ENABLE_FREE_ACCESS && ($config->ENABLE_FREE_ACCESS == 'courses_only'))) {
$this->allow_nobody = false;
}
parent::__construct($dispatcher);
}
public function before_filter(&$action, &$args) {
parent::before_filter($action, $args);
checkObject();
$this->institute = Institute::findCurrent();
if (!$this->institute) {
throw new CheckObjectException(_('Sie haben kein Objekt gewählt.'));
}
$this->institute_id = $this->institute->id;
//set visitdate for institute, when coming from meine_seminare
if (Request::option('auswahl')) {
object_set_visit($this->institute_id, 0);
}
PageLayout::setHelpKeyword("Basis.Einrichtungen");
PageLayout::setTitle($this->institute->getFullName() . " - " ._("Kurzinfo"));
Navigation::activateItem('/course/main/info');
}
/**
* show institute overview page
*
* @return void
*/
function index_action()
{
//gibt es eine Anweisung zur Umleitung?
$redirect_to = Request::get('redirect_to');
if (
$redirect_to
&& !(
str_starts_with($redirect_to, '#')
|| str_starts_with($redirect_to, '?')
)
) {
if (!is_internal_url($redirect_to)) {
throw new Exception('Invalid redirection');
}
$this->redirect(URLHelper::getURL($redirect_to, ['cid' => $this->institute_id]));
return;
}
$this->sidebar = Sidebar::get();
if (Config::get()->NEWS_RSS_EXPORT_ENABLE && $this->institute_id){
$rss_id = StudipNews::GetRssIdFromRangeId($this->institute_id);
if ($rss_id) {
PageLayout::addHeadElement('link', ['rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => 'RSS',
'href' => 'rss.php?id='.$rss_id]);
}
}
URLHelper::bindLinkParam("inst_data", $this->institut_main_data);
// (un)subscribe to institute
if (Config::get()->ALLOW_SELFASSIGN_INSTITUTE && $GLOBALS['user']->id !== 'nobody' && !$GLOBALS['perm']->have_perm('admin')) {
$widget = new ActionsWidget();
if (! $GLOBALS['perm']->have_studip_perm('user', $this->institute_id)) {
$url = URLHelper::getURL('dispatch.php/institute/overview', [
'follow_inst' => 'on'
]);
$widget->addLink(_('Einrichtung abonnieren'), $url);
} elseif (! $GLOBALS['perm']->have_studip_perm('autor', $this->institute_id)) {
$url = URLHelper::getURL('dispatch.php/institute/overview', [
'follow_inst' => 'off'
]);
$widget->addLink(_('Austragen aus der Einrichtung'), $url);
}
$this->sidebar->addWidget($widget);
if (! $GLOBALS['perm']->have_studip_perm('user', $this->institute_id) AND (Request::option('follow_inst') == 'on')) {
$query = "INSERT IGNORE INTO user_inst
(user_id, Institut_id, inst_perms)
VALUES (?, ?, 'user')";
$statement = DBManager::get()->prepare($query);
$statement->execute([
$GLOBALS['user']->user_id,
$this->institute_id
]);
if ($statement->rowCount() > 0) {
StudipLog::log('INST_USER_ADD', $this->institute_id, $GLOBALS['user']->user_id, 'user');
NotificationCenter::postNotification('UserInstitutionDidCreate', $this->institute_id, $GLOBALS['user']->user_id);
PageLayout::postMessage(MessageBox::success(_("Sie haben die Einrichtung abonniert.")));
header('Location: '.URLHelper::getURL('', ['cid' => $this->institute_id]));
die;
}
} elseif (! $GLOBALS['perm']->have_studip_perm('autor', $this->institute_id) AND (Request::option('follow_inst') == 'off')) {
$query = "DELETE FROM user_inst
WHERE user_id = ? AND Institut_id = ?";
$statement = DBManager::get()->prepare($query);
$statement->execute([
$GLOBALS['user']->user_id,
$this->institute_id
]);
if ($statement->rowCount() > 0) {
StudipLog::log('INST_USER_DEL', $this->institute_id, $GLOBALS['user']->user_id, 'user');
NotificationCenter::postNotification('UserInstitutionDidDelete', $this->institute_id, $GLOBALS['user']->user_id);
PageLayout::postMessage(MessageBox::success(_("Sie haben sich aus der Einrichtung ausgetragen.")));
header('Location: '.URLHelper::getURL('', ['cid' => $this->institute_id]));
die;
}
}
}
// Fetch news
$response = $this->relayWithRedirect('news/display/' . $this->institute_id . '/true');
$this->news = $response->body;
// Fetch votes
if (Config::get()->VOTE_ENABLE) {
$response = $this->relay('questionnaire/widget/' . $this->institute_id . '/institute');
$this->questionnaires = $response->body;
}
}
}
|