Skip to content

Commit

Permalink
Add profile_add
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow243 authored and josaphatim committed Aug 30, 2024
1 parent 98b997a commit 286814b
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 199 deletions.
14 changes: 14 additions & 0 deletions modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,17 @@ function get_special_folders($mod, $id) {
}
return array();
}

/**
* @subpackage core/functions
*/
if (!hm_exists('check_file_upload')) {
function check_file_upload($request, $key) {
if (!is_array($request->files) || !array_key_exists($key, $request->files)) {
return false;
}
if (!is_array($request->files[$key]) || !array_key_exists('tmp_name', $request->files[$key])) {
return false;
}
return true;
}}
17 changes: 12 additions & 5 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ function parse_sieve_config_host($host) {
}}

if (!hm_exists('connect_to_imap_server')) {
function connect_to_imap_server($address, $name, $port, $user, $pass, $tls, $imap_sieve_host, $enableSieve, $type, $context, $hidden = false, $server_id = false) {
function connect_to_imap_server($address, $name, $port, $user, $pass, $tls, $imap_sieve_host, $enableSieve, $type, $context, $hidden = false, $server_id = false, $show_errors = true) {
$imap_list = array(
'name' => $name,
'server' => $address,
Expand Down Expand Up @@ -1567,11 +1567,16 @@ function connect_to_imap_server($address, $name, $port, $user, $pass, $tls, $ima
$sieveClientFactory = new Hm_Sieve_Client_Factory();
$client = $sieveClientFactory->init(null, $server);

if (!$client) {
if (!$client && $show_errors) {
Hm_Msgs::add("ERRFailed to authenticate to the Sieve host");
}
} catch (Exception $e) {
Hm_Msgs::add("ERRFailed to authenticate to the Sieve host");
if ($show_errors) {
Hm_Msgs::add("ERRFailed to authenticate to the Sieve host");
}
if (! $server_id) {
Hm_IMAP_List::del($imap_server_id);
}
return;
}
}
Expand All @@ -1580,9 +1585,11 @@ function connect_to_imap_server($address, $name, $port, $user, $pass, $tls, $ima

if (imap_authed($imap)) {
return $imap_server_id;
}else {
} else {
Hm_IMAP_List::del($imap_server_id);
Hm_Msgs::add('ERRAuthentication failed');
if ($show_errors) {
Hm_Msgs::add('ERRAuthentication failed');
}
return null;
}
}
Expand Down
5 changes: 3 additions & 2 deletions modules/nux/assets/data/server_accounts_sample.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
server_name;jmap_server;jmap_hide_from_combined_view;username;password;imap_port;imap_tls;imap_hide_from_combined_view;imap_server;smtp_server;smtp_port;smtp_tls;sieve_host;sieve_port
Exemple;;FALSE;[email protected];secret;993;TRUE;FALSE;imap.exemple.org;smtp.exemple.org;465;TRUE;tls://imap.exemple.org;4190
server_name;username;password;jmap_server;jmap_hide_from_combined_view;imap_server;imap_port;imap_tls;imap_hide_from_combined_view;smtp_server;smtp_port;smtp_tls;sieve_host;sieve_port;profile_reply_to;profile_signature;profile_is_default
Mailbox 1;[email protected];secret;;FALSE;imap.example.org;993;TRUE;FALSE;smtp.example.org;465;TRUE;tls://imap.exemple.org;4190;[email protected];;FALSE
Mailbox 2;[email protected];secret2;jmap.example2.org;FALSE;;;;;smtp.example2.org;465;TRUE;tls://jmap.example2.org;4190;[email protected];my-signature;TRUE
40 changes: 24 additions & 16 deletions modules/nux/assets/data/server_accounts_sample.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
Test1:
Mailbox 1:
username: [email protected]
password: secret
jmap:
server:
hide_from_combined_view: false
user:
username: [email protected]
password: secret
hide_from_combined_view:
imap:
server: imap.example.org
port: 993
tls: true
hide_from_combined_view: false
server: imap.example.org
smtp:
server: smtp.example.org
port: 465
tls: true
sieve:
host: tls://imap.example.org
port: 4190
Test2:
profile:
reply_to: [email protected]
signature:
is_default: false
Mailbox 2:
username: [email protected]
password: secret2
jmap:
server:
user:
username: [email protected]
password: secret
server: jmap.example2.org
hide_from_combined_view: false
imap:
port: 993
tls: true
server: mail.example.org
server:
port:
tls:
hide_from_combined_view:
smtp:
server: mail.example.org
server: smtp.example2.org
port: 465
tls: true
sieve:
host: tls://mail.example.org
host: tls://jmap.example2.org
port: 4190
profile:
reply_to: [email protected]
signature: my-signature
is_default: true
17 changes: 15 additions & 2 deletions modules/nux/functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
use SplFileObject;

/**
* NUX modules
Expand Down Expand Up @@ -47,13 +46,27 @@ function parse_csv_with_headers($file_path, $delimiter = ';') {
// 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);
$line_data = array_combine($header, $fields);
foreach ($line_data as $key => $value) {
$line_data[$key] = convert_to_boolean($value);
}
$rows[] = $line_data;
}
}
}
return $rows;
}}

if (!hm_exists('convert_to_boolean')) {
function convert_to_boolean($value) {
if (in_array($value, ['true', '1', 'yes'])) {
return true;
} elseif (in_array($value, ['false', '0', 'no'])) {
return false;
}
return $value;
}}

/**
* @subpackage nux/functions
*/
Expand Down
Loading

0 comments on commit 286814b

Please sign in to comment.