diff --git a/modules/nux/assets/data/server_accounts_sample.csv b/modules/nux/assets/data/server_accounts_sample.csv index b2739367a5..2678167e56 100644 --- a/modules/nux/assets/data/server_accounts_sample.csv +++ b/modules/nux/assets/data/server_accounts_sample.csv @@ -1,2 +1,2 @@ -server_name;support_jmap;jmap_server;username;password;imap_port;imap_tls;imap_server;support_smtp;smtp_server;smtp_port;smtp_tls;sieve_host;sieve_port -Exemple;FALSE;;email@exemple.org;secret;993;TRUE;imap.exemple.org;TRUE;smtp.exemple.org;465;TRUE;tls://imap.exemple.org;4190 \ No newline at end of file +server_name;support_jmap;jmap_server;username;password;imap_port;imap_tls;imap_server;smtp_server;smtp_port;smtp_tls;sieve_host;sieve_port +Exemple;FALSE;;email@exemple.org;secret;993;TRUE;imap.exemple.org;smtp.exemple.org;465;TRUE;tls://imap.exemple.org;4190 \ No newline at end of file diff --git a/modules/nux/assets/data/server_accounts_sample.yaml b/modules/nux/assets/data/server_accounts_sample.yaml index 5ce2c406f1..0c81738064 100644 --- a/modules/nux/assets/data/server_accounts_sample.yaml +++ b/modules/nux/assets/data/server_accounts_sample.yaml @@ -9,7 +9,6 @@ Test1: tls: true imap_server: imap.example.org smtp: - support_smtp: true smtp_server: smtp.example.org smtp_port: 465 smtp_tls: true @@ -27,7 +26,6 @@ Test2: tls: true imap_server: mail.example.org smtp: - support_smtp: true smtp_server: mail.example.org smtp_port: 465 smtp_tls: true diff --git a/modules/nux/functions.php b/modules/nux/functions.php new file mode 100644 index 0000000000..ed9d747e8c --- /dev/null +++ b/modules/nux/functions.php @@ -0,0 +1,120 @@ +setFlags(SplFileObject::DROP_NEW_LINE); + + // Initialize an array to hold the rows + $rows = []; + $is_first_line = true; + $header = []; + // Loop through each line in the CSV file + while (!$file->eof()) { + // Get the line as a string + $line = $file->fgets(); + + // Skip empty lines (e.g., due to trailing newlines) + if ($line === [null] || $line === false) { + continue; + } + + // Split the line into an array using the specified delimiter + $fields = explode($delimiter, $line); + // Process the header line + if ($is_first_line) { + $header = $fields; + $is_first_line = false; + } else { + // Ensure that the number of fields matches the header count + if (count($fields) === count($header)) { + // Combine the header and fields into an associative array + $rows[] = array_combine($header, $fields); + } + } + } + return $rows; +}} + +/** + * @subpackage nux/functions + */ +if (!hm_exists('oauth2_form')) { + function oauth2_form($details, $mod) + { + $oauth2 = new Hm_Oauth2($details['client_id'], $details['client_secret'], $details['redirect_uri']); + $url = $oauth2->request_authorization_url($details['auth_uri'], $details['scope'], 'nux_authorization', $details['email']); + $res = ''; + $res .= '
' . $this->trans('Quickly add an account from popular E-mail providers. To manually configure an account, use the IMAP/SMTP sections below.') . '
' . - ''.$this->trans('Quickly add an account from popular E-mail providers. To manually configure an account, use the IMAP/SMTP sections below.').'
'. + '%s' . - ' | %s | %s | %s |
%s'. + ' | %s | %s | %s |