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
102 lines (88 loc) · 3.82 KB
/
init.php
File metadata and controls
102 lines (88 loc) · 3.82 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require_once BASEPATH . '/php/Settings.php';
include_once BASEPATH . "/php/_config.php";
include_once BASEPATH . "/php/DB.php";
// Database connection
global $DB;
$DB = new DB;
global $osiris;
$osiris = $DB->db;
// get installed OSIRIS version
$version = $osiris->system->findOne(['key' => 'version']);
if (str_ends_with($_SERVER['REQUEST_URI'], '/install')){
// just let the install script run
} elseif (empty($version)) { ?>
<!-- include css -->
<link rel="stylesheet" href="<?= ROOTPATH ?>/css/main.css">
<div class="align-items-center container d-flex h-full">
<div class="alert danger mb-20 w-full">
<h3 class="title">
<?= lang('
OSIRIS has not been installed yet.', '
OSIRIS wurde noch nicht installiert.') ?>
</h3>
<p>
<b><?= lang('Warning', 'Achtung') ?>:</b>
<?= lang(
'OSIRIS will be installed and set up automatically. This won\'t take long, but please make sure not to reload or close the page during the process.',
'OSIRIS wird automatisch installiert und eingerichtet. Dies wird nicht lange dauern, aber bitte stelle sicher, dass du die Seite während des Prozesses nicht neu lädst oder schließt.'
) ?>
</p>
<a href="<?= ROOTPATH ?>/install" class="btn danger">
<?= lang('Install OSIRIS', 'OSIRIS installieren') ?>
</a>
</div>
</div>
<?php
die;
} else if ($version['value'] != OSIRIS_VERSION && !str_ends_with($_SERVER['REQUEST_URI'], '/migrate')) { ?>
<!-- include css -->
<link rel="stylesheet" href="<?= ROOTPATH ?>/css/main.css">
<div class="align-items-center container d-flex h-full">
<div class="alert danger mb-20 w-full">
<h3 class="title"><?= lang('A new OSIRIS-Version has been found.', 'Eine neue OSIRIS-Version wurde gefunden.') ?></h3>
<p>
<?= lang(
'OSIRIS will be updated and set up automatically. Depending on the version, this might take some time, so please make sure not to reload or close the page during the process.',
'OSIRIS wird automatisch aktualisiert und eingerichtet. Abhängig von der Version kann dies eine ganze Weile dauern, stelle also bitte sicher, dass du die Seite während des Prozesses nicht neu lädst oder schließt.'
) ?>
</p>
<p class="text-muted">
<small>Installed: <?= $version['value'] ?></small> | <small>Latest: <?= OSIRIS_VERSION ?></small>
</p>
<a href="<?= ROOTPATH ?>/migrate" class="btn danger">
<?= lang('Update OSIRIS', 'OSIRIS aktualisieren') ?>
</a>
</div>
</div>
<?php
die;
}
// if (empty($version)) {
// $osiris->system->insertOne(['key' => 'version', 'value' => OSIRIS_VERSION]);
// $version = $osiris->system->findOne(['key' => 'version']);
// }
define('OSIRIS_DB_VERSION', $version['value'] ?? '0.0.0');
// Get organizational units (Groups)
include_once BASEPATH . "/php/Groups.php";
global $Groups;
$Groups = new Groups();
global $Departments;
if (!empty($Groups->tree)) {
// filter inactive groups
$Departments = array_filter($Groups->tree['children'], function ($group) {
return !($group['inactive'] ?? false);
});
// take only id => name
$Departments = array_column($Departments, '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);