Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php'; |
| 3 | if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == 'domainadmin') { |
| 4 | |
| 5 | /* |
| 6 | / DOMAIN ADMIN |
| 7 | */ |
| 8 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 9 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/header.inc.php'; |
| 10 | $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 11 | $tfa_data = get_tfa(); |
| 12 | $fido2_data = fido2(array("action" => "get_friendly_names")); |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 13 | $username = $_SESSION['mailcow_cc_username']; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 14 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 15 | $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 Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 24 | } |
| 25 | elseif (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 Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 53 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 54 | // 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 Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 63 | |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 64 | $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 Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 79 | 'tfa_id' => @$_SESSION['tfa_id'], |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 80 | '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 Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 92 | 'lang_datatables' => json_encode($lang['datatables']), |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 93 | ]; |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 94 | } |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 95 | else { |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 96 | header('Location: /'); |
| 97 | exit(); |
| 98 | } |
| 99 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 100 | $js_minifier->add('/web/js/site/user.js'); |
| 101 | $js_minifier->add('/web/js/site/pwgen.js'); |
Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame] | 102 | |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 103 | require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; |