forked from OSIRIS-Solutions/osiris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
79 lines (66 loc) · 2.61 KB
/
init.php
File metadata and controls
79 lines (66 loc) · 2.61 KB
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
<?php
require_once BASEPATH . '/php/Settings.php';
include_once BASEPATH . "/php/_config.php";
include_once BASEPATH . "/php/DB.php";
// Language settings and cookies
if ($_SERVER['REQUEST_METHOD'] === 'GET' && array_key_exists('language', $_GET)) {
$_COOKIE['osiris-language'] = $_GET['language'] === 'en' ? 'en' : 'de';
$domain = ($_SERVER['HTTP_HOST'] != 'testserver') ? $_SERVER['HTTP_HOST'] : false;
setcookie('osiris-language', $_COOKIE['osiris-language'], [
'expires' => time() + 86400,
'path' => ROOTPATH . '/',
'domain' => $domain,
'httponly' => false,
'samesite' => 'Strict',
]);
}
// check if accessibility settings are given
if ($_SERVER['REQUEST_METHOD'] === 'GET' && array_key_exists('accessibility', $_GET)) {
// define base parameter
$domain = $_SERVER['HTTP_HOST'];
$cookie_settings = [
'expires' => time() + 86400,
'path' => ROOTPATH . '/',
'domain' => $domain,
'httponly' => false,
'samesite' => 'Strict',
];
// set cookies for current sessions
$_COOKIE['D3-accessibility-contrast'] = $_GET['accessibility']['contrast'] ?? '';
$_COOKIE['D3-accessibility-transitions'] = $_GET['accessibility']['transitions'] ?? '';
$_COOKIE['D3-accessibility-dyslexia'] = $_GET['accessibility']['dyslexia'] ?? '';
// save cookies for persistent use
setcookie('D3-accessibility-dyslexia', $_COOKIE['D3-accessibility-dyslexia'], $cookie_settings);
setcookie('D3-accessibility-contrast', $_COOKIE['D3-accessibility-contrast'], $cookie_settings);
setcookie('D3-accessibility-transitions', $_COOKIE['D3-accessibility-transitions'], $cookie_settings);
}
// Database connection
global $DB;
$DB = new DB;
global $osiris;
$osiris = $DB->db;
// get installed OSIRIS version
$version = $osiris->system->findOne(['key' => 'version']);
if (empty($version)){
die ('OSIRIS has not been installed yet. <a href="'.ROOTPATH.'/install">Click here to install it</a>.');
}
define('OSIRIS_DB_VERSION', $version['value']);
// Get organizational units (Groups)
include_once BASEPATH . "/php/Groups.php";
global $Groups;
$Groups = new Groups();
global $Departments;
if (!empty($Groups->tree)){
$Departments = array_column($Groups->tree['children'], 'name', 'id');
} else $Departments = [];
// Activity categories and types
include_once BASEPATH . "/php/Categories.php";
global $Categories;
$Categories = new Categories();
// initialize user
global $USER;
$USER = $DB->initUser();
// Get all Settings
global $Settings;
$Settings = new Settings($USER);
?>