blob: 19aafdddce2fa663775f5d5f2c09302203e50ce4 [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']),
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +010023 'lang_datatables' => json_encode($lang['datatables']),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010024 ];
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020025}
26elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'user') {
27
28 /*
29 / USER
30 */
31
32 require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php';
33 $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
34 $username = $_SESSION['mailcow_cc_username'];
35 $mailboxdata = mailbox('get', 'mailbox_details', $username);
36 $pushover_data = pushover('get', $username);
37 $tfa_data = get_tfa();
38 $fido2_data = fido2(array("action" => "get_friendly_names"));
39
40 $clientconfigstr = "host=" . urlencode($mailcow_hostname) . "&email=" . urlencode($username) . "&name=" . urlencode($mailboxdata['name']) . "&ui=" . urlencode(strtok($_SERVER['HTTP_HOST'], ':')) . "&port=" . urlencode($autodiscover_config['caldav']['port']);
41 if ($autodiscover_config['useEASforOutlook'] == 'yes')
42 $clientconfigstr .= "&outlookEAS=1";
43 if (file_exists('thunderbird-plugins/version.csv')) {
44 $fh = fopen('thunderbird-plugins/version.csv', 'r');
45 if ($fh) {
46 while (($row = fgetcsv($fh, 1000, ';')) !== FALSE) {
47 if ($row[0] == 'sogo-connector@inverse.ca') {
48 $clientconfigstr .= "&connector=" . urlencode($row[1]);
49 }
50 }
51 fclose($fh);
52 }
53 }
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020054
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010055 // Get user information about aliases
56 $user_get_alias_details = user_get_alias_details($username);
57 $user_get_alias_details['direct_aliases'] = array_filter($user_get_alias_details['direct_aliases']);
58 $user_get_alias_details['shared_aliases'] = array_filter($user_get_alias_details['shared_aliases']);
59 $user_domains[] = mailbox('get', 'mailbox_details', $username)['domain'];
60 $user_alias_domains = $user_get_alias_details['alias_domains'];
61 if (!empty($user_alias_domains)) {
62 $user_domains = array_merge($user_domains, $user_alias_domains);
63 }
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020064
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +010065 // get number of app passwords
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010066 $number_of_app_passwords = 0;
67 foreach (app_passwd("get") as $app_password)
68 {
69 $app_password = app_passwd("details", $app_password['id']);
70 if ($app_password['active'])
71 {
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +010072 $number_of_app_passwords++;
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010073 }
74 }
Matthias Andreas Benkardd1f5b682023-11-18 13:18:30 +010075
76 $template = 'user.twig';
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010077 $template_data = [
78 'acl' => $_SESSION['acl'],
79 'acl_json' => json_encode($_SESSION['acl']),
80 'user_spam_score' => mailbox('get', 'spam_score', $username),
81 'tfa_data' => $tfa_data,
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010082 'tfa_id' => @$_SESSION['tfa_id'],
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010083 'fido2_data' => $fido2_data,
84 'mailboxdata' => $mailboxdata,
85 'clientconfigstr' => $clientconfigstr,
86 'user_get_alias_details' => $user_get_alias_details,
87 'get_tagging_options' => mailbox('get', 'delimiter_action', $username),
88 'get_tls_policy' => mailbox('get', 'tls_policy', $username),
89 'quarantine_notification' => mailbox('get', 'quarantine_notification', $username),
90 'quarantine_category' => mailbox('get', 'quarantine_category', $username),
91 'user_domains' => $user_domains,
92 'pushover_data' => $pushover_data,
93 'lang_user' => json_encode($lang['user']),
94 'number_of_app_passwords' => $number_of_app_passwords,
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010095 'lang_datatables' => json_encode($lang['datatables']),
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010096 ];
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020097}
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010098else {
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +010099 header('Location: /');
100 exit();
101}
102
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200103$js_minifier->add('/web/js/site/user.js');
104$js_minifier->add('/web/js/site/pwgen.js');
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +0100105
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200106require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';