diff --git a/language/az.php b/language/az.php index a1415a8ecf..9b0952e337 100755 --- a/language/az.php +++ b/language/az.php @@ -635,4 +635,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/de.php b/language/de.php index af3fa782fc..53962bf155 100755 --- a/language/de.php +++ b/language/de.php @@ -632,4 +632,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/en.php b/language/en.php index ef42888b8f..f6ec1f916e 100755 --- a/language/en.php +++ b/language/en.php @@ -650,4 +650,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/es.php b/language/es.php index 5aa565a855..85159e9d1b 100755 --- a/language/es.php +++ b/language/es.php @@ -632,4 +632,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/et.php b/language/et.php index 3b9030ec2e..0f5312a61b 100755 --- a/language/et.php +++ b/language/et.php @@ -640,4 +640,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/fa.php b/language/fa.php index 638d8ff593..5fe850cb9d 100755 --- a/language/fa.php +++ b/language/fa.php @@ -684,4 +684,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/fr.php b/language/fr.php index 2d428b79d5..2f13509cde 100755 --- a/language/fr.php +++ b/language/fr.php @@ -631,4 +631,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/hu.php b/language/hu.php index cb6049dbe1..2d3fa3fc2d 100755 --- a/language/hu.php +++ b/language/hu.php @@ -632,4 +632,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/id.php b/language/id.php index dfd2ec6b00..5176da2c5c 100755 --- a/language/id.php +++ b/language/id.php @@ -639,4 +639,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/it.php b/language/it.php index d18a962ca9..8ef231caa6 100755 --- a/language/it.php +++ b/language/it.php @@ -632,4 +632,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/ja.php b/language/ja.php index 2be5431efb..1cc1071d46 100755 --- a/language/ja.php +++ b/language/ja.php @@ -632,4 +632,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/nl.php b/language/nl.php index 618860defe..c563421f13 100755 --- a/language/nl.php +++ b/language/nl.php @@ -632,4 +632,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/pt-BR.php b/language/pt-BR.php index e9bccf01b6..630189a51e 100755 --- a/language/pt-BR.php +++ b/language/pt-BR.php @@ -631,4 +631,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/ro.php b/language/ro.php index d7263cd337..a537a525f5 100755 --- a/language/ro.php +++ b/language/ro.php @@ -631,4 +631,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/ru.php b/language/ru.php index d2a3bc4c07..b9821f5ca2 100755 --- a/language/ru.php +++ b/language/ru.php @@ -633,4 +633,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/language/zh-Hans.php b/language/zh-Hans.php index 153d7d1669..27cf4adcff 100644 --- a/language/zh-Hans.php +++ b/language/zh-Hans.php @@ -653,4 +653,5 @@ 'No tags available yet.' => false, 'Server capabilities' => false, 'Capabilities' => false, + 'Screen %s first emails' => false, ); diff --git a/lib/repository.php b/lib/repository.php index 08e44c1d80..deee4b2271 100644 --- a/lib/repository.php +++ b/lib/repository.php @@ -55,7 +55,11 @@ public static function add($entity, $save = true) { public static function edit($id, $entity) { if (array_key_exists($id, self::$entities)) { - self::$entities[$id] = array_merge(self::$entities[$id], $entity); + if (is_array($entity)) { + self::$entities[$id] = array_merge(self::$entities[$id], $entity); + } else { + self::$entities[$id] = $entity; + } self::save(); return true; } diff --git a/modules/contacts/modules.php b/modules/contacts/modules.php index c03f1e8166..0e7bbd3c4d 100644 --- a/modules/contacts/modules.php +++ b/modules/contacts/modules.php @@ -399,6 +399,56 @@ protected function output() { } } +/** + * @subpackage contacts/handler + */ +class Hm_Handler_save_contact extends Hm_Handler_Module +{ + public function process() + { + list($success, $form ) = $this->process_form(array('email_address')); + if ($success) { + $contacts = $this->get('contact_store'); + $contact_list = $contacts->getAll(); + $existingEmails = array_map(function($contact){ + return $contact->value('email_address'); + },$contact_list); + + $list_mails = array_unique(explode(",", $form['email_address'])); + + foreach ($list_mails as $addr) { + $addresses = process_address_fld($addr); + $newEmails = array_column($addresses, 'email'); + if (!empty($newEmails)) { + $newContacts = array_filter($newEmails, function ($email) use ($existingEmails) { + return !in_array($email, $existingEmails); + }); + $existingContacts = array_filter($existingEmails, function ($email) use ($newEmails) { + return in_array($email, $newEmails); + }); + if (!empty($newContacts)) { + $newContacts = array_map(function ($email) { + return ['source' => 'local', 'email_address' => $email, 'display_name' => $email, 'group' => 'Trusted Senders']; + }, $newContacts); + $contacts->add_contact($newContacts[0]); + } + if (!empty($existingContacts)) { + $existingContacts = array_map(function ($email) { + return ['source' => 'local', 'email_address' => $email, 'group' => 'Trusted Senders']; + }, $existingContacts); + foreach ($existingContacts as $key => $contact) { + $contacts->update_contact($key, $contact); + } + } + } + } + $this->session->record_unsaved('Contacts added to Trusted Contacts list'); + Hm_Msgs::add('Contacts added to Trusted Contacts list'); + } + + } +} + /** * @subpackage contacts/output */ diff --git a/modules/contacts/setup.php b/modules/contacts/setup.php index 352d5450fd..e2db6e7296 100644 --- a/modules/contacts/setup.php +++ b/modules/contacts/setup.php @@ -23,6 +23,8 @@ add_handler('compose', 'load_contacts', true, 'contacts', 'process_compose_form_submit', 'after'); add_handler('compose', 'store_contact_message', true, 'contacts', 'load_contacts', 'after'); +add_handler('ajax_imap_folder_display', 'load_contacts', true, 'contacts', 'load_user_data', 'after'); + add_handler('ajax_imap_message_content', 'load_contacts', true, 'contacts', 'load_user_data', 'after'); add_handler('ajax_imap_message_content', 'find_message_contacts', true, 'contacts', 'imap_message_content', 'after'); add_output('ajax_imap_message_content', 'add_message_contacts', true, 'contacts', 'filter_message_headers', 'after'); @@ -31,6 +33,7 @@ setup_base_ajax_page('ajax_add_contact', 'core'); add_handler('ajax_add_contact', 'load_contacts', true, 'contacts', 'load_user_data', 'after'); add_handler('ajax_add_contact', 'save_user_data', true, 'core', 'language', 'after'); +add_handler('ajax_add_contact', 'save_contact', true); setup_base_ajax_page('ajax_autocomplete_contact', 'core'); @@ -81,8 +84,8 @@ 'contact_source' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, 'contact_type' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, 'contact_auto_collect' => FILTER_VALIDATE_BOOLEAN, - 'enable_warn_contacts_cc_not_exist_in_list_contact' => FILTER_VALIDATE_INT - + 'enable_warn_contacts_cc_not_exist_in_list_contact' => FILTER_VALIDATE_INT, + 'email_address' => FILTER_SANITIZE_FULL_SPECIAL_CHARS ), 'allowed_get' => array( 'contact_id' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, diff --git a/modules/core/message_list_functions.php b/modules/core/message_list_functions.php index d0057c4c9c..e0fd2e1759 100644 --- a/modules/core/message_list_functions.php +++ b/modules/core/message_list_functions.php @@ -206,7 +206,18 @@ function message_list_row($values, $id, $style, $output_mod, $row_class='') { if ($row_class) { $res .= ' '.$output_mod->html_safe($row_class); } - $res .= '">'; + $data_uid = ""; + if ($uids = explode("_", $id)) { + if (isset($uids[2])) { + $data_uid = 'data-uid="'. $uids[2] .'"'; + } + } + if (!empty($data_uid)) { + $res .= '" '.$data_uid.'>'; + } else { + $res .= '">'; + } + if ($style == 'news') { $res .= ''; } diff --git a/modules/core/setup.php b/modules/core/setup.php index 941528b6c9..6e5003b6cc 100644 --- a/modules/core/setup.php +++ b/modules/core/setup.php @@ -264,6 +264,7 @@ 'filter' => FILTER_DEFAULT, 'sort' => FILTER_DEFAULT, 'keyword' => FILTER_DEFAULT, + 'screen_emails' => FILTER_DEFAULT, ), 'allowed_post' => array( diff --git a/modules/imap/functions.php b/modules/imap/functions.php index 1f7e8c18b4..79f6f5994b 100644 --- a/modules/imap/functions.php +++ b/modules/imap/functions.php @@ -857,7 +857,7 @@ function imap_refresh_oauth2_token($server, $config) { * @return int count of messages moved */ if (!hm_exists('imap_move_same_server')) { -function imap_move_same_server($ids, $action, $hm_cache, $dest_path) { +function imap_move_same_server($ids, $action, $hm_cache, $dest_path, $screen_emails=false) { $moved = array(); $keys = array_keys($ids); $server_id = array_pop($keys); @@ -865,11 +865,25 @@ function imap_move_same_server($ids, $action, $hm_cache, $dest_path) { $imap = Hm_IMAP_List::connect($server_id, $cache); foreach ($ids[$server_id] as $folder => $msgs) { if (imap_authed($imap) && $imap->select_mailbox(hex2bin($folder))) { - if ($imap->message_action(mb_strtoupper($action), $msgs, hex2bin($dest_path[2]))) { + if ($screen_emails) { foreach ($msgs as $msg) { $moved[] = sprintf('imap_%s_%s_%s', $server_id, $msg, $folder); + $email = current(array_column(process_address_fld($imap->get_message_headers($msg)['From']), "email")); + $uids = $imap->search('ALL', false, array(array('FROM', $email))); + foreach ($uids as $uid) { + if ($imap->message_action(mb_strtoupper($action), $uid, hex2bin($dest_path[2]))) { + $moved[] = sprintf('imap_%s_%s_%s', $server_id, $uid, $folder); + } + } + } + } else { + if ($imap->message_action(mb_strtoupper($action), $msgs, hex2bin($dest_path[2]))) { + foreach ($msgs as $msg) { + $moved[] = sprintf('imap_%s_%s_%s', $server_id, $msg, $folder); + } } } + } } return $moved; diff --git a/modules/imap/handler_modules.php b/modules/imap/handler_modules.php index 3d0c9f0dd3..18c4f57c4e 100644 --- a/modules/imap/handler_modules.php +++ b/modules/imap/handler_modules.php @@ -252,10 +252,25 @@ class Hm_Handler_imap_process_move extends Hm_Handler_Module { public function process() { list($success, $form) = $this->process_form(array('imap_move_to', 'imap_move_page', 'imap_move_action', 'imap_move_ids')); if ($success) { + $screen = false; + $parts = explode("_", $this->request->get['list_path']); + $imap_server_id = $parts[1] ?? ''; + $cache = Hm_IMAP_List::get_cache($this->cache, $imap_server_id); + $imap = Hm_IMAP_List::connect($imap_server_id, $cache); + if ($form['imap_move_action'] == "screen_mail") { + $form['imap_move_action'] = "move"; + $screen = true; + $screen_folder = 'Screen emails'; + if (!count($imap->get_mailbox_status($screen_folder))) { + $imap->create_mailbox($screen_folder); + } + $form['imap_move_to'] = $parts[0] ."_". $parts[1] ."_".bin2hex($screen_folder); + } + list($msg_ids, $dest_path, $same_server_ids, $other_server_ids) = process_move_to_arguments($form); $moved = array(); if (count($same_server_ids) > 0) { - $moved = array_merge($moved, imap_move_same_server($same_server_ids, $form['imap_move_action'], $this->cache, $dest_path)); + $moved = array_merge($moved, imap_move_same_server($same_server_ids, $form['imap_move_action'], $this->cache, $dest_path, $screen)); } if (count($other_server_ids) > 0) { $moved = array_merge($moved, imap_move_different_server($other_server_ids, $form['imap_move_action'], $dest_path, $this->cache)); @@ -263,7 +278,11 @@ public function process() { } if (count($moved) > 0 && count($moved) == count($msg_ids)) { if ($form['imap_move_action'] == 'move') { - Hm_Msgs::add('Messages moved'); + if ($screen) { + Hm_Msgs::add('Emails moved to Screen email folder'); + } else { + Hm_Msgs::add('Messages moved'); + } } else { Hm_Msgs::add('Messages copied'); @@ -271,7 +290,11 @@ public function process() { } elseif (count($moved) > 0) { if ($form['imap_move_action'] == 'move') { - Hm_Msgs::add('Some messages moved (only IMAP message types can be moved)'); + if ($screen) { + Hm_Msgs::add('Some Emails moved to Screen email folder'); + } else { + Hm_Msgs::add('Some messages moved (only IMAP message types can be moved)'); + } } else { Hm_Msgs::add('Some messages copied (only IMAP message types can be copied)'); @@ -622,6 +645,7 @@ public function process() { $this->out('list_filter', $this->request->get['filter']); } } + $folder = hex2bin($parts[2]); if (!empty($details)) { if (array_key_exists('folder_label', $this->request->get)) { $folder = $this->request->get['folder_label']; @@ -636,6 +660,13 @@ public function process() { } $this->out('mailbox_list_title', $title); } + + if ($this->module_is_supported("contacts") && $folder == 'INBOX') { + $this->out('folder', $folder); + $this->out('screen_emails', isset($this->request->get['screen_emails'])); + $this->out('first_time_screen_emails', $this->user_config->get('first_time_screen_emails_setting', DEFAULT_PER_SOURCE)); + $this->out('move_messages_in_screen_email', $this->user_config->get('move_messages_in_screen_email_setting', DEFAULT_PER_SOURCE)); + } } elseif ($path == 'sent') { $this->out('mailbox_list_title', array('Sent')); @@ -804,7 +835,17 @@ public function process() { $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); if (imap_authed($imap)) { $this->out('imap_mailbox_page_path', $path); - list($total, $results) = $imap->get_mailbox_page(hex2bin($form['folder']), $sort, $rev, $filter, $offset, $limit, $keyword); + if (isset($this->request->get['screen_emails']) && hex2bin($form['folder']) == 'INBOX' && $this->module_is_supported("contacts")) { + $contacts = $this->get('contact_store'); + $contact_list = $contacts->getAll(); + + $existingEmails = array_map(function($c){ + return $c->value('email_address'); + },$contact_list); + list($total, $results) = $imap->get_mailbox_page(hex2bin($form['folder']), $sort, $rev, $filter, $offset, $limit, $keyword, $existingEmails); + } else { + list($total, $results) = $imap->get_mailbox_page(hex2bin($form['folder']), $sort, $rev, $filter, $offset, $limit, $keyword); + } foreach ($results as $msg) { $msg['server_id'] = $form['imap_server_id']; $msg['server_name'] = $details['name']; @@ -2128,3 +2169,23 @@ public function process() { } } } + +/** + * Process first-time screen emails per page in the settings page + * @subpackage core/handler + */ +class Hm_Handler_process_first_time_screen_emails_per_page_setting extends Hm_Handler_Module { + public function process() { + function process_first_time_screen_emails_callback($val) { + return $val; + } + process_site_setting('first_time_screen_emails', $this, 'process_first_time_screen_emails_callback'); + } +} + +class Hm_Handler_process_setting_move_messages_in_screen_email extends Hm_Handler_Module { + public function process() { + function process_move_messages_in_screen_email_enabled_callback($val) { return $val; } + process_site_setting('move_messages_in_screen_email', $this, 'process_move_messages_in_screen_email_enabled_callback', true, true); + } +} diff --git a/modules/imap/hm-imap.php b/modules/imap/hm-imap.php index 7e6d895280..83686d4323 100644 --- a/modules/imap/hm-imap.php +++ b/modules/imap/hm-imap.php @@ -2141,7 +2141,7 @@ public function get_first_message_part($uid, $type, $subtype=false, $struct=fals * @return array list of headers */ - public function get_mailbox_page($mailbox, $sort, $rev, $filter, $offset=0, $limit=0, $keyword=false) { + public function get_mailbox_page($mailbox, $sort, $rev, $filter, $offset=0, $limit=0, $keyword=false, $trusted_senders=array()) { $result = array(); /* select the mailbox if need be */ @@ -2158,8 +2158,19 @@ public function get_mailbox_page($mailbox, $sort, $rev, $filter, $offset=0, $lim else { $uids = $this->sort_by_fetch($sort, $rev, $filter); } + $terms = array(); if ($keyword) { - $uids = $this->search($filter, $uids, array(array('TEXT', $keyword))); + $terms[] = array('TEXT', $keyword); + } + if ($trusted_senders && is_array($trusted_senders)) { + foreach ($trusted_senders as $sender) { + $terms[] = array('FROM', 'NOT '. $sender); + } + + } + // Perform a single search call with the combined terms + if (!empty($terms)) { + $uids = $this->search($filter, $uids, $terms); } $total = count($uids); diff --git a/modules/imap/output_modules.php b/modules/imap/output_modules.php index f8e718d9ee..e166a7c779 100644 --- a/modules/imap/output_modules.php +++ b/modules/imap/output_modules.php @@ -75,6 +75,20 @@ protected function output() { '" href="">'; } + if ($this->get('folder')) { + if ($this->get('screen_emails')) { + $custom .= ''; + if ($this->get('move_messages_in_screen_email')) { + $custom .= ''; + } else { + $custom .= ''; + } + } else { + $path = sprintf('?page=message_list&list_path=%s&screen_emails=1', $this->html_safe($this->get('list_path'))); + $custom .= ''; + } + } $this->out('custom_list_controls', $custom); } } @@ -1410,3 +1424,39 @@ protected function output() { return $res; } } + +/** + * Option to set the per page count for IMAP folder views + * @subpackage imap/output + */ +class Hm_Output_first_time_screen_emails_per_page_setting extends Hm_Output_Module { + protected function output() { + $settings = $this->get('user_settings', array()); + $per_page = 20; + $reset = ''; + if (array_key_exists('first_time_screen_emails', $settings) && $settings['first_time_screen_emails']) { + $per_page = $settings['first_time_screen_emails']; + } + if ($per_page != 20) { + $reset = ''; + } + return ''.$reset.''; + } +} +class Hm_Output_setting_move_messages_in_screen_email extends Hm_Output_Module { + protected function output() { + $settings = $this->get('user_settings', array()); + $checked = ""; + if (array_key_exists('move_messages_in_screen_email', $settings) && $settings['move_messages_in_screen_email']) { + if ($settings['move_messages_in_screen_email']) { + $checked = "checked"; + } + } + $res = ''; + + return $res; + } +} diff --git a/modules/imap/setup.php b/modules/imap/setup.php index 4de2800c29..5056817aba 100644 --- a/modules/imap/setup.php +++ b/modules/imap/setup.php @@ -43,6 +43,8 @@ add_handler('settings', 'process_max_google_contacts_number', true, 'imap', 'date', 'after'); add_handler('settings', 'process_review_sent_email_setting', true, 'imap', 'date', 'after'); add_handler('settings', 'process_auto_advance_email_setting', true, 'imap', 'date', 'after'); +add_handler('settings', 'process_first_time_screen_emails_per_page_setting', true, 'imap', 'date', 'after'); +add_handler('settings', 'process_setting_move_messages_in_screen_email', true, 'imap', 'process_first_time_screen_emails_per_page_setting', 'after'); add_output('settings', 'imap_server_ids', true, 'imap', 'page_js', 'before'); add_output('settings', 'start_sent_settings', true, 'imap', 'end_settings_form', 'before'); add_output('settings', 'sent_since_setting', true, 'imap', 'start_sent_settings', 'after'); @@ -58,6 +60,8 @@ add_output('settings', 'max_google_contacts_number', true, 'imap', 'imap_per_page_setting', 'after'); add_output('settings', 'review_sent_email', true, 'imap', 'imap_pagination_links', 'after'); add_output('settings', 'imap_auto_advance_email', true, 'imap', 'imap_pagination_links', 'after'); +add_output('settings', 'first_time_screen_emails_per_page_setting', true, 'imap', 'imap_auto_advance_email', 'after'); +add_output('settings', 'setting_move_messages_in_screen_email', true, 'imap', 'first_time_screen_emails_per_page_setting', 'after'); /* compose page data */ add_output('compose', 'imap_server_ids', true, 'imap', 'page_js', 'before'); @@ -430,6 +434,8 @@ 'imap_snooze_until' => FILTER_DEFAULT, 'auto_advance_email' => FILTER_VALIDATE_BOOLEAN, 'imap_server_ids' => FILTER_DEFAULT, - 'tag_id' => FILTER_DEFAULT + 'tag_id' => FILTER_DEFAULT, + 'first_time_screen_emails' => FILTER_VALIDATE_INT, + 'move_messages_in_screen_email' => FILTER_VALIDATE_BOOLEAN, ) ); diff --git a/modules/imap/site.js b/modules/imap/site.js index 3d654a5ecb..4fd966400a 100644 --- a/modules/imap/site.js +++ b/modules/imap/site.js @@ -946,8 +946,10 @@ var imap_move_copy = function(e, action, context) { return false; }; -var imap_perform_move_copy = function(dest_id, context) { - var action = $('.move_to_type').val(); +var imap_perform_move_copy = function(dest_id, context, action = null) { + if (!action) { + action = $('.move_to_type').val(); + } var ids = []; var page = hm_page_name(); $('.move_to_location').html(''); @@ -983,7 +985,7 @@ var imap_perform_move_copy = function(dest_id, context) { var index; if (hm_page_name() == 'message_list') { Hm_Message_List.reset_checkboxes(); - if (action == 'move') { + if (action == 'move' || action == 'screen_mail') { for (index in res.move_count) { $('.'+Hm_Utils.clean_selector(res.move_count[index])).remove(); } @@ -1345,3 +1347,48 @@ const handleCopyMsgSource = function(e) { navigator.clipboard.writeText(messageSource.textContent); Hm_Notices.show(['Copied to clipboard']); } + +var imap_screen_email = function() { + var list_msg_uid = []; + + $('input[type=checkbox]').each(function() { + if (this.checked && this.id.search('imap') != -1) { + list_msg_uid.push($(this).parent().parent().attr("data-uid")); + } + }); + if ($("#move_messages_in_screen_email").val() == 1) { + imap_perform_move_copy("Screen email", "list", 'screen_mail'); + } + list_msg_uid.forEach(function(msg_uid) { + block_unblock_sender(msg_uid, Hm_Utils.parse_folder_path(hm_list_path()), 'sender', 'blocked'); + }) +}; + +var add_email_in_contact_trusted = function(list_email) { + if (list_email) { + Hm_Ajax.request( + [ + { name: 'hm_ajax_hook', value: 'ajax_add_contact' }, + { name: 'email_address', value: list_email.join(',') }, + ], + function (res) { + window.location.reload(); + } + ); + } + }; + +$('.screen-email-unlike').on("click", function() { imap_screen_email(); return false; }); + +$('.screen-email-like').on("click", function() { + var list_email = []; + $('input[type=checkbox]').each(function() { + if (this.checked && this.id.search('imap') != -1) { + let email = $('.'+ this.id +' .from').attr("data-title") + if (email = email.trim()) { + list_email.push(email); + } + } + }); + add_email_in_contact_trusted(list_email); return false; +});