blob: b92e87a743836273805ec69cb4bc1834f79e03b4 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
3if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'domainadmin') {
4
5 /*
6 / DOMAIN ADMIN
7 */
8
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01009 require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
10 $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020011 $tfa_data = get_tfa();
12 $fido2_data = fido2(array("action" => "get_friendly_names"));
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010013 $username = $_SESSION['mailcow_cc_username'];
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020014
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010015 $template = 'domainadmin.twig';
16 $template_data = [
17 'acl' => $_SESSION['acl'],
18 'acl_json' => json_encode($_SESSION['acl']),
19 'user_spam_score' => mailbox('get', 'spam_score', $username),
20 'tfa_data' => $tfa_data,
21 'fido2_data' => $fido2_data,
22 'lang_user' => json_encode($lang['user']),
23 ];
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020024}
25elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'user') {
26
27 /*
28 / USER
29 */
30
31 require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
32 $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
33 $username = $_SESSION['mailcow_cc_username'];
34 $mailboxdata = mailbox('get', 'mailbox_details', $username);
35 $pushover_data = pushover('get', $username);
36 $tfa_data = get_tfa();
37 $fido2_data = fido2(array("action" => "get_friendly_names"));
38
39 $clientconfigstr = "host=" . urlencode($mailcow_hostname) . "&email=" . urlencode($username) . "&name=" . urlencode($mailboxdata['name']) . "&ui=" . urlencode(strtok($_SERVER['HTTP_HOST'], ':')) . "&port=" . urlencode($autodiscover_config['caldav']['port']);
40 if ($autodiscover_config['useEASforOutlook'] == 'yes')
41 $clientconfigstr .= "&outlookEAS=1";
42 if (file_exists('thunderbird-plugins/version.csv')) {
43 $fh = fopen('thunderbird-plugins/version.csv', 'r');
44 if ($fh) {
45 while (($row = fgetcsv($fh, 1000, ';')) !== FALSE) {
46 if ($row[0] == 'sogo-connector@inverse.ca') {
47 $clientconfigstr .= "&connector=" . urlencode($row[1]);
48 }
49 }
50 fclose($fh);
51 }
52 }
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020053
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010054 // Get user information about aliases
55 $user_get_alias_details = user_get_alias_details($username);
56 $user_get_alias_details['direct_aliases'] = array_filter($user_get_alias_details['direct_aliases']);
57 $user_get_alias_details['shared_aliases'] = array_filter($user_get_alias_details['shared_aliases']);
58 $user_domains[] = mailbox('get', 'mailbox_details', $username)['domain'];
59 $user_alias_domains = $user_get_alias_details['alias_domains'];
60 if (!empty($user_alias_domains)) {
61 $user_domains = array_merge($user_domains, $user_alias_domains);
62 }
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020063
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010064 $template = 'user.twig';
65 $number_of_app_passwords = 0;
66 foreach (app_passwd("get") as $app_password)
67 {
68 $app_password = app_passwd("details", $app_password['id']);
69 if ($app_password['active'])
70 {
71 ++$number_of_app_passwords;
72 }
73 }
74 $template_data = [
75 'acl' => $_SESSION['acl'],
76 'acl_json' => json_encode($_SESSION['acl']),
77 'user_spam_score' => mailbox('get', 'spam_score', $username),
78 'tfa_data' => $tfa_data,
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010079 'tfa_id' => @$_SESSION['tfa_id'],
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010080 'fido2_data' => $fido2_data,
81 'mailboxdata' => $mailboxdata,
82 'clientconfigstr' => $clientconfigstr,
83 'user_get_alias_details' => $user_get_alias_details,
84 'get_tagging_options' => mailbox('get', 'delimiter_action', $username),
85 'get_tls_policy' => mailbox('get', 'tls_policy', $username),
86 'quarantine_notification' => mailbox('get', 'quarantine_notification', $username),
87 'quarantine_category' => mailbox('get', 'quarantine_category', $username),
88 'user_domains' => $user_domains,
89 'pushover_data' => $pushover_data,
90 'lang_user' => json_encode($lang['user']),
91 'number_of_app_passwords' => $number_of_app_passwords,
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010092 'lang_datatables' => json_encode($lang['datatables']),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010093 ];
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020094}
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010095else {
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010096 header('Location: /');
97 exit();
98}
99
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200100$js_minifier->add('/web/js/site/user.js');
101$js_minifier->add('/web/js/site/pwgen.js');
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +0100102
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200103require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';