Newer
Older
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
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/*
seminar_open.php - Initialises a Stud.IP sesssion
Copyright (C) 2000 Stefan Suchi <suchi@data-quest.de>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* @addtogroup notifications
*
* Logging in triggers a UserDidLogin notification. The user's ID is
* transmitted as subject of the notification.
*/
//redirect the user where he want to go today....
function startpage_redirect($page_code) {
switch ($page_code) {
case 1:
case 2:
$jump_page = "dispatch.php/my_courses";
break;
case 3:
$jump_page = "dispatch.php/calendar/schedule";
break;
case 4:
$jump_page = "dispatch.php/contact";
break;
case 5:
$jump_page = "dispatch.php/calendar/single";
break;
case 6:
// redirect to global blubberstream
// or no redirection if blubber isn't active
if (Config::get()->BLUBBER_GLOBAL_MESSENGER_ACTIVATE) {
$jump_page = "dispatch.php/blubber";
}
break;
case 7:
$jump_page = "dispatch.php/contents/overview";
break;
}
page_close();
header ('Location: ' . URLHelper::getURL($jump_page));
exit;
}
global $i_page,
$SessionSeminar,
$sess, $auth, $user, $perm, $_language_path;
//get the name of the current page in $i_page
$i_page = basename($_SERVER['PHP_SELF']);
//INITS
$seminar_open_redirected = false;
$user_did_login = false;
// session init starts here
if (empty($_SESSION['SessionStart']) || $_SESSION['SessionStart'] == 0) {
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
$_SESSION['SessionStart'] = time();
$_SESSION['object_cache'] = [];
// try to get accepted languages from browser
if (!isset($_SESSION['_language'])) {
$_SESSION['_language'] = get_accepted_languages();
}
if (!$_SESSION['_language']) {
$_SESSION['_language'] = Config::get()->DEFAULT_LANGUAGE;
}
}
// user init starts here
if ($auth->is_authenticated() && is_object($user) && $user->id != "nobody") {
if ($_SESSION['SessionStart'] > UserConfig::get($user->id)->CURRENT_LOGIN_TIMESTAMP) { // just logged in
// store old CURRENT_LOGIN in LAST_LOGIN and set CURRENT_LOGIN to start of session
UserConfig::get($user->id)->store('LAST_LOGIN_TIMESTAMP', UserConfig::get($user->id)->CURRENT_LOGIN_TIMESTAMP);
UserConfig::get($user->id)->store('CURRENT_LOGIN_TIMESTAMP', $_SESSION['SessionStart']);
//find current semester and store it in $_SESSION['_default_sem']
$current_sem = Semester::findByTimestamp(time() + Config::get()->SEMESTER_TIME_SWITCH * 7 * 24 * 60 * 60);
if (!$current_sem ) $current_sem = Semester::findCurrent();
$_SESSION['_default_sem'] = $current_sem->semester_id;
//redirect user to another page if he want to, redirect is deferred to allow plugins to catch the UserDidLogin notification
if (UserConfig::get($user->id)->PERSONAL_STARTPAGE > 0 && $i_page == "index.php" && !$perm->have_perm("root")) {
$seminar_open_redirected = TRUE;
}
$user_did_login = true;
}
TwoFactorAuth::get()->secureSession();
}
// init of output via I18N
$_language_path = init_i18n($_SESSION['_language']);
//force reload of config to get translated data
include 'config.inc.php';
// Try to select the course or institute given by the parameter 'cid'
// in the current request.
$course_id = (Request::int('cancel_login') && (!is_object($user) || $user->id === 'nobody'))
? null
: Request::option('cid');
// Select the current course or institute if we got one from 'cid' or session.
// This also binds Context::getId()
// to the URL parameter 'cid' for all generated links.
if (isset($course_id)) {
Context::set($course_id);
unset($course_id);
}
if (Request::int('disable_plugins') !== null && ($user->id === 'nobody' || $perm->have_perm('root'))) {
// deactivate non-core plugins
PluginManager::getInstance()->setPluginsDisabled(Request::int('disable_plugins'));
}
// load the default set of plugins
PluginEngine::loadPlugins();
// add navigation item: add modules
if (Context::isCourse() && $perm->have_studip_perm('tutor', Context::getId())) {
$plus_nav = new Navigation(_('Mehr …'), 'dispatch.php/course/plus/index');
$plus_nav->setDescription(_("Mehr Stud.IP-Funktionen für Ihre Veranstaltung"));
Navigation::addItem('/course/modules', $plus_nav);
}
// add navigation item: add modules (institute)
if (Context::isInstitute() && $perm->have_studip_perm('admin', Context::getId())) {
$plus_nav = new Navigation(_('Mehr …'), 'dispatch.php/course/plus/index');
$plus_nav->setDescription(_("Mehr Stud.IP-Funktionen für Ihre Einrichtung"));
Navigation::addItem('/course/modules', $plus_nav);
}
// add navigation item for profile: add modules
if (Navigation::hasItem('/profile/edit')) {
$plus_nav = new Navigation(_('Mehr …'), 'dispatch.php/profilemodules/index');
$plus_nav->setDescription(_("Mehr Stud.IP-Funktionen für Ihr Profil"));
Navigation::addItem('/profile/modules', $plus_nav);
}
if ($user_did_login) {
NotificationCenter::postNotification('UserDidLogin', $user->id);
}
if (!Request::isXhr() && $perm->have_perm('root')) {
if (!isset($_SESSION['migration-check']) || $_SESSION['migration-check']['timestamp'] < time() - 5 * 60) {
$migrator = new Migrator(
"{$GLOBALS['STUDIP_BASE_PATH']}/db/migrations",
new DBSchemaVersion('studip')
);
$migrations = $migrator->relevantMigrations(null);
$_SESSION['migration-check'] = [
'disabled' => false,
'timestamp' => time(),
'count' => count($migrations),
];
}
if (Request::option('stop-migration-nag')) {
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
&& $_SESSION['migration-check']['count'] > 0
) {
$info = sprintf(
_('Es gibt %u noch nicht ausgeführte Migration(en).'),
$_SESSION['migration-check']['count']
);
$message = MessageBox::info($info,[
sprintf(
_('Zur %sMigrationsseite%s'),
'<a class="link-intern" href="' . URLHelper::getLink('web_migrate.php') . '">',
'</a>'
),
sprintf(
'<small><a href="%s">%s</a></small>',
URLHelper::getLink('', ['stop-migration-nag' => true]),
_('Diese Nachricht bis zum nächsten Login nicht mehr anzeigen')
)
]
);
PageLayout::postMessage($message, 'migration-info');
}
}
if ($seminar_open_redirected) {
startpage_redirect(UserConfig::get($user->id)->PERSONAL_STARTPAGE);
}
// Show terms on first login
if (is_object($GLOBALS['user'])
&& $GLOBALS['user']->needsToAcceptTerms()
&& !match_route('dispatch.php/terms'))
{
if (!Request::isXhr()) {
header('Location: ' . URLHelper::getURL('dispatch.php/terms', ['return_to' => $_SERVER['REQUEST_URI'], 'redirect_token' => Token::create(600)], true));
} else {
throw new Trails_Exception(400);
}
page_close();
die;
}
if (Config::get()->USER_VISIBILITY_CHECK && is_object($GLOBALS['user']) && $GLOBALS['user']->id !== 'nobody') {
require_once('lib/user_visible.inc.php');
first_decision($GLOBALS['user']->id);
}