@@ -734,7 +734,7 @@ public function process() {
734734
735735 if ($ ceo_use_detect_ceo_fraud && hex2bin ($ form ['folder ' ]) == 'INBOX ' ) {
736736 if ($ this ->isCeoFraud ($ msg ['to ' ], $ msg ['subject ' ], $ msg ['preview_msg ' ])) {
737-
737+
738738 $ folder = "Suspicious emails " ;
739739 if (!count ($ mailbox ->get_mailbox_status ($ folder ))) {
740740 $ mailbox ->create_folder ($ folder );
@@ -750,7 +750,7 @@ public function process() {
750750 $ total --;
751751 }
752752 }
753-
753+
754754 if ($ msg ) {
755755 if (! $ include_preview && isset ($ msg ['preview_msg ' ])) {
756756 $ msg ['preview_msg ' ] = "" ;
@@ -770,18 +770,18 @@ public function process() {
770770 $ this ->out ('do_not_flag_as_read_on_open ' , $ this ->user_config ->get ('unread_on_open_setting ' , false ));
771771 }
772772 }
773- public function isCeoFraud ($ email , $ subject , $ msg ) {
773+ public function isCeoFraud ($ email , $ subject , $ msg ) {
774774 // 1. Check Suspicious Terms or Requests
775775 $ suspiciousTerms = explode (", " , $ this ->user_config ->get ("ceo_suspicious_terms_setting " ));
776776 if ($ this ->detectSuspiciousTerms ($ msg , $ suspiciousTerms ) || $ this ->detectSuspiciousTerms ($ subject , $ suspiciousTerms )) {
777-
777+
778778 // 2. check ceo_rate_limit
779779 $ amounts = $ this ->extractAmountFromEmail ($ msg );
780780 $ amountLimit = $ this ->user_config ->get ("ceo_amount_limit_setting " );
781781 $ isUpperAmount = array_reduce ($ amounts , function ($ carry , $ value ) use ($ amountLimit ) {
782782 return $ carry || $ value > $ amountLimit ;
783783 }, false );
784-
784+
785785 if ($ isUpperAmount ) {
786786 if ($ this ->user_config ->get ("ceo_use_trusted_contact_setting " )) {
787787 $ contacts = $ this ->get ('contact_store ' );
@@ -815,16 +815,16 @@ private function isEmailInTrustedDomainList($trustedDomain, $email) {
815815 }
816816 private function extractAmountFromEmail ($ emailBody ) {
817817 $ pattern = '/\b\d+(?:,\d+)?\.?\d*\s*(?:USD|dollars?|US\$?|EUR|euros?|€|JPY|yen|¥|GBP|pounds?|£|CAD|CAD\$|AUD|AUD\$)/i ' ;
818-
818+
819819 preg_match_all ($ pattern , $ emailBody , $ matches );
820-
820+
821821 if ($ matches ) {
822- return array_map (function ($ value ) {
823- return floatval (preg_replace ('/[^0-9]/ ' , '' , $ value ));
822+ return array_map (function ($ value ) {
823+ return floatval (preg_replace ('/[^0-9]/ ' , '' , $ value ));
824824 }, $ matches [0 ]);
825825 }
826826 }
827-
827+
828828}
829829
830830/**
@@ -1135,7 +1135,7 @@ public function process() {
11351135 * @param string $folder The folder where the messages currently reside.
11361136 * @param array $specials Special folder information for handling specific actions.
11371137 * @param array $server_details Details of the server, including its unique ID and settings.
1138- *
1138+ *
11391139 * @return array Returns an associative array with:
11401140 * - 'error' => bool Indicates if an error occurred during the operation.
11411141 * - 'moved' => array List of moved message identifiers in a specific format.
@@ -1182,7 +1182,7 @@ private function perform_action($mailbox, $action_type, $uids, $folder, $special
11821182 * @param string $action_type The action type that determines which special folder to retrieve (e.g., 'delete', 'archive').
11831183 * @param array $specials An associative array of special folder names, like 'trash', 'archive', and 'junk'.
11841184 * @param array $server_details Details of the server, including its name.
1185- *
1185+ *
11861186 * @return string|false Returns the special folder name if found, or false if no corresponding folder is configured.
11871187 */
11881188 private function get_special_folder ($ action_type , $ specials , $ server_details ) {
@@ -1273,7 +1273,7 @@ public function process() {
12731273 $ offset = 0 ;
12741274 $ list_page = 1 ;
12751275 $ maxPerSource = round ($ limit / count ($ data_sources ));
1276-
1276+
12771277 if (isset ($ this ->request ->get ['list_page ' ])) {
12781278 $ list_page = (int ) $ this ->request ->get ['list_page ' ];
12791279 if ($ list_page && $ list_page > 1 ) {
@@ -1373,7 +1373,7 @@ public function process() {
13731373 $ offsets = explode (', ' , $ offsets );
13741374 }
13751375 $ searchTerms [] = [search_since_based_on_setting ($ this ->user_config ), $ date ];
1376-
1376+
13771377 $ result = getCombinedMessagesLists ($ data_sources , [
13781378 'cache ' => $ this ->cache ,
13791379 'session ' => $ this ->session ,
@@ -1463,7 +1463,7 @@ public function process() {
14631463 'type ' => 'jmap ' ,
14641464 'port ' => false ,
14651465 'tls ' => false ));
1466- Hm_Msgs::add (' Added server! ' );
1466+ Hm_Msgs::add (" Added server!. To preserve these settings after logout, please go to <a class='alert-link' href='/?page=save'>Save Settings</a>. " );
14671467 $ this ->session ->record_unsaved ('JMAP server added ' );
14681468 }
14691469 else {
@@ -1693,12 +1693,12 @@ class Hm_Handler_load_imap_folders_permissions extends Hm_Handler_Module {
16931693 */
16941694 public function process () {
16951695 list ($ success , $ form ) = $ this ->process_form (array ('imap_server_id ' ,'imap_folder_uid ' ,'imap_folder ' ));
1696-
1696+
16971697 if ($ success && !empty ($ form ['imap_server_id ' ]) && !empty ($ form ['imap_folder ' ]) && !empty ($ form ['imap_folder_uid ' ])) {
16981698 Hm_IMAP_List::init ($ this ->user_config , $ this ->session );
16991699 $ server = Hm_IMAP_List::dump ($ form ['imap_server_id ' ], true );
17001700 $ cache = Hm_IMAP_List::get_cache ($ this ->cache , $ form ['imap_server_id ' ]);
1701-
1701+
17021702 $ imap = Hm_IMAP_List::connect ($ form ['imap_server_id ' ], $ cache , $ server ['user ' ], $ server ['pass ' ]);
17031703 $ permissions = $ imap ->get_acl ($ form ['imap_folder ' ]);
17041704 $ this ->out ('imap_folders_permissions ' , $ permissions );
@@ -1716,13 +1716,13 @@ class Hm_Handler_set_acl_to_imap_folders extends Hm_Handler_Module {
17161716 */
17171717 public function process () {
17181718 list ($ success , $ form ) = $ this ->process_form (array ('imap_server_id ' ,'imap_folder ' ,'identifier ' ,'permissions ' ,'action ' ));
1719-
1719+
17201720 if ($ success && !empty ($ form ['imap_server_id ' ]) && !empty ($ form ['identifier ' ]) && !empty ($ form ['permissions ' ]) && !empty ($ form ['action ' ])) {
17211721
17221722 Hm_IMAP_List::init ($ this ->user_config , $ this ->session );
17231723 $ server = Hm_IMAP_List::dump ($ form ['imap_server_id ' ], true );
17241724 $ cache = Hm_IMAP_List::get_cache ($ this ->cache , $ form ['imap_server_id ' ]);
1725-
1725+
17261726 $ imap = Hm_IMAP_List::connect ($ form ['imap_server_id ' ], $ cache , $ server ['user ' ], $ server ['pass ' ]);
17271727 if ($ form ['action ' ] === 'add ' ) {
17281728 $ response = $ imap ->set_acl ($ form ['imap_folder ' ], $ form ['identifier ' ], $ form ['permissions ' ]);
@@ -1903,7 +1903,7 @@ public function process() {
19031903 if (isset ($ this ->request ->post ['imap_connect ' ])) {
19041904 list ($ success , $ form ) = $ this ->process_form (array ('imap_server_id ' ));
19051905 $ imap_details = Hm_IMAP_List::dump ($ form ['imap_server_id ' ], true );
1906- if ($ success && $ imap_details ) {
1906+ if ($ success && $ imap_details ) {
19071907 if ($ this ->module_is_supported ('sievefilters ' ) && $ this ->user_config ->get ('enable_sieve_filter_setting ' , DEFAULT_ENABLE_SIEVE_FILTER )) {
19081908 try {
19091909 list ($ sieve_host , $ sieve_port ) = parse_sieve_config_host ($ imap_details ['sieve_config_host ' ]);
@@ -2325,9 +2325,15 @@ public function process() {
23252325 if (isset ($ this ->request ->post ['hide_imap_server ' ])) {
23262326 list ($ success , $ form ) = $ this ->process_form (array ('imap_server_id ' ));
23272327 if ($ success ) {
2328- Hm_IMAP_List::toggle_hidden ($ form ['imap_server_id ' ], (bool ) $ this ->request ->post ['hide_imap_server ' ]);
2329- Hm_Msgs::add ('Hidden status updated ' );
2330- $ this ->session ->record_unsaved (sprintf ('%s server hidden status updated ' , imap_server_type ($ form ['imap_server_id ' ])));
2328+ $ action = (bool ) $ this ->request ->post ['hide_imap_server ' ];
2329+ $ server_type = imap_server_type ($ form ['imap_server_id ' ]);
2330+ Hm_IMAP_List::toggle_hidden ($ form ['imap_server_id ' ], $ action );
2331+ if ($ action ) {
2332+ Hm_Msgs::add (sprintf ('%s server has been hidden ' , $ server_type ));
2333+ } else {
2334+ Hm_Msgs::add (sprintf ('%s server is now visible ' , $ server_type ));
2335+ }
2336+ $ this ->session ->record_unsaved (sprintf ('%s server visibility updated ' , $ server_type ));
23312337 }
23322338 }
23332339 }
@@ -2495,7 +2501,7 @@ function process_ceo_use_detect_ceo_fraud_callback($val) { return $val; }
24952501 function process_ceo_use_trusted_contact_callback ($ val ) { return $ val ; }
24962502 function process_ceo_suspicious_terms_callback ($ val ) { return $ val ; }
24972503 function process_ceo_amount_limit_callback ($ val ) { return $ val ; }
2498-
2504+
24992505 process_site_setting ('ceo_use_detect_ceo_fraud ' , $ this , 'process_ceo_use_detect_ceo_fraud_callback ' );
25002506 process_site_setting ('ceo_use_trusted_contact ' , $ this , 'process_ceo_use_trusted_contact_callback ' );
25012507 process_site_setting ('ceo_suspicious_terms ' , $ this , 'process_ceo_suspicious_terms_callback ' );
0 commit comments