diff --git a/lib/output.php b/lib/output.php
index 37c3b76f7d..25dfd0e77c 100644
--- a/lib/output.php
+++ b/lib/output.php
@@ -136,6 +136,8 @@ public static function __callStatic(string $method, array $parameters)
public static $trash = 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20x%3D%220px%22%20y%3D%220px%22%0D%0Awidth%3D%228%22%20height%3D%228%22%0D%0AviewBox%3D%220%200%2024%2024%22%3E%0D%0A%20%20%20%20%3Cpath%20d%3D%22M%2010%202%20L%209%203%20L%204%203%20L%204%205%20L%207%205%20L%2017%205%20L%2020%205%20L%2020%203%20L%2015%203%20L%2014%202%20L%2010%202%20z%20M%205%207%20L%205%2022%20L%2019%2022%20L%2019%207%20L%205%207%20z%22%3E%3C%2Fpath%3E%0D%0A%3C%2Fsvg%3E';
public static $draft = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEI0lEQVR4nO2dTW7UQBCFn2BWLIEowClga0dhjTThEPkB8ZNkLpQhCgqKlKwQh2CFiJAYOAFixx6SRpZsaWK5Pe6Z7qrq7npSLazOOG1/rmq/GscBVCqVSqXyJ6OBIeeATAoECiTGi4BM3AdqIgkFAn4ICgT8Jz4aIAWAMuNxcUCqyW5kPE4m19TNNcjEfaAmkmAH0q6puW0baUDaNTW3bSMNiAYUiBF8IYjLEG4fUKgP6V9TchsnE3cpMJGEAgE/BFFAuH1AoT7kJhBuH1CqD+EvC0ZwsJcsDcgGwu0DCvUhsnxAqT5Ey5apz8EXiSUr1/gK4J4EINw+oBDgQy4B3O84Z485gHD7gJJ5+xuAtY7zNQFwDeCQGkjO8QPAQwuM5mcqKAcKBMFhzAA8WABjHso+V4Zw+4CCYHzDAcY8lLccQLh9QBl4vBqDI4x5KG+ogeRYpsYO+6igvFYg8LKAP7KcyNsA3jtCWbl82XbO7QMKgm3bmtGGcuoI5VUIINw+o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0Ij48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDI0djI0SDBWMHoiLz48cGF0aCBkPSJNNyAxMGw1IDUgNS01SDd6Ii8+PC9zdmc+';
+ public static $arrow_drop_up = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDI0djI0SDBWMHoiLz48cGF0aCBkPSJNNyAxNGw1LTUgNSA1SDd6Ii8+PC9zdmc+';
}
/**
diff --git a/modules/contacts/hm-contacts.php b/modules/contacts/hm-contacts.php
index 97ee992858..3c78a0fce8 100644
--- a/modules/contacts/hm-contacts.php
+++ b/modules/contacts/hm-contacts.php
@@ -25,11 +25,24 @@ public function add_contact($data) {
return true;
}
- public function get($id, $default=false) {
- if (!array_key_exists($id, $this->contacts)) {
- return $default;
+ public function get($id, $default=false, $email_address=""){
+ if(array_key_exists($id, $this->contacts)) {
+ return $this->contacts[$id];
}
- return $this->contacts[$id];
+
+ if(!empty($email_address)){
+ $res = false;
+ foreach ($this->contacts as $id => $contact) {
+ if ($contact->value('email_address') == $email_address) {
+ $res = $contact;
+ break;
+ }
+ }
+
+ return $res;
+ }
+
+ return $default;
}
public function search($flds) {
diff --git a/modules/contacts/site.js b/modules/contacts/site.js
index 4c3ceaaec0..61e89f6444 100644
--- a/modules/contacts/site.js
+++ b/modules/contacts/site.js
@@ -20,12 +20,49 @@ var delete_contact = function(id, source, type) {
var add_contact_from_message_view = function() {
var contact = $('#add_contact').val();
var source = $('#contact_source').val();
+
if (contact) {
+ Hm_Ajax.request(
+ [
+ { name: 'hm_ajax_hook', value: 'ajax_add_contact' },
+ { name: 'contact_value', value: contact },
+ { name: 'contact_source', value: source },
+ ],
+ function (res) {
+ $('.add_contact_controls').toggle();
+ window.location.reload();
+ remove_message_content();
+ }
+ );
+ }
+ };
+
+var add_contact_from_popup = function(event) {
+ event.stopPropagation()
+ var source = 'local:local';
+ var contact = $('#contact_info').text().replace('>','').replace('<','');
+
+
+ if (contact) {
+ var emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
+ var email = contact.match(emailRegex)[0];
+ var name = contact.replace(emailRegex, "");
+
+ var saveContactContent = `
+ Name : | ${name} |
+ Email : | ${email} |
+ Source : | Local |
+
`
+
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_add_contact'},
{'name': 'contact_value', 'value': contact},
{'name': 'contact_source', 'value': source}],
- function(res) { $('.add_contact_controls').toggle(); }
+ function (res) {
+ $("#contact_popup_body").html(saveContactContent);
+ sessionStorage.removeItem(`${window.location.pathname}imap_4_${hm_list_path()}`);
+ sessionStorage.removeItem(`${window.location.pathname}${hm_msg_uid()}_${hm_list_path()}`);
+ }
);
}
};
@@ -60,7 +97,7 @@ var autocomplete_contact = function(e, class_name, list_div) {
$(list_div).html('');
for (i in res.contact_suggestions) {
var suggestion = JSON.parse(res.contact_suggestions[i].replace(/"/g, '"'))
-
+
div.html(suggestion.contact);
if ($(class_name).val().match(div.text())) {
continue;
diff --git a/modules/imap/functions.php b/modules/imap/functions.php
index cac1954dae..c2adc185b6 100644
--- a/modules/imap/functions.php
+++ b/modules/imap/functions.php
@@ -86,7 +86,7 @@ function imap_data_sources($callback, $custom=array()) {
}}
/**
- * Prepare and format message list data
+ * Prepare and format message list data
* @subpackage imap/functions
* @param array $msgs list of message headers to format
* @param object $mod Hm_Output_Module
diff --git a/modules/imap/output_modules.php b/modules/imap/output_modules.php
index 5e30490180..6ba5bb0593 100644
--- a/modules/imap/output_modules.php
+++ b/modules/imap/output_modules.php
@@ -201,6 +201,83 @@ protected function output() {
$value = sprintf('%s (%s)', $dt->format('c Z'), human_readable_interval($value));
} catch (Exception $e) {}
$txt .= '';
+ }
+ elseif($fld == 'from'){
+
+ $regexp = '/\s*(.*[^\s])\s*<\s*(.*[^\s])\s*>/';
+
+ $contact_email = "";
+ $contact_name = "";
+
+ if(preg_match($regexp, $value, $matches)){
+ $contact_name = $matches[1];
+ $contact_email = $matches[2];
+ }else{
+ $EmailRegexp = "/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i";
+ if(preg_match($EmailRegexp, $value, $matches)){
+ $contact_email = $matches[0][0];
+ }
+ }
+
+ $contact = ($this->get('contact_store'))->get(null, false, $contact_email);
+ $contact_exists = !empty($contact);
+
+ $txt .= '';
}
else {
if (strtolower($name) == 'flags') {
@@ -234,7 +311,7 @@ protected function output() {
if ($this->get('list_headers')) {
$txt .= format_list_headers($this);
}
- $lc_headers = lc_headers($headers);
+ $lc_headers = lc_headers($headers);
if (array_key_exists('to', $lc_headers)) {
$addr_list = process_address_fld($lc_headers['to']);
$size = count($addr_list);
@@ -252,7 +329,7 @@ protected function output() {
});
$size += count($addr_list);
}
-
+
$txt .= '
';
$txt .= '|