comparison program/steps/mail/func.inc @ 19:b6a96bdd6b29

More cleaning up php8 Warnings/deprecations
author Charlie Root
date Wed, 08 Oct 2025 08:50:44 -0400
parents 1866b439e6d3
children 73124dd49283
comparison
equal deleted inserted replaced
18:b631c1c7a3ce 19:b6a96bdd6b29
76 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); 76 $delimiter = $RCMAIL->storage->get_hierarchy_delimiter();
77 77
78 // set current mailbox and some other vars in client environment 78 // set current mailbox and some other vars in client environment
79 $OUTPUT->set_env('mailbox', $mbox_name); 79 $OUTPUT->set_env('mailbox', $mbox_name);
80 $OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize()); 80 $OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize());
81 $OUTPUT->set_env('current_page', max(1, $_SESSION['page'])); 81 $OUTPUT->set_env('current_page', max(1, ($_SESSION['page']??0)));
82 $OUTPUT->set_env('delimiter', $delimiter); 82 $OUTPUT->set_env('delimiter', $delimiter);
83 $OUTPUT->set_env('threading', $threading); 83 $OUTPUT->set_env('threading', $threading);
84 $OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD')); 84 $OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD'));
85 $OUTPUT->set_env('reply_all_mode', (int) $RCMAIL->config->get('reply_all_mode')); 85 $OUTPUT->set_env('reply_all_mode', (int) $RCMAIL->config->get('reply_all_mode'));
86 $OUTPUT->set_env('layout', $RCMAIL->config->get('layout') ?: 'widescreen'); 86 $OUTPUT->set_env('layout', $RCMAIL->config->get('layout') ?: 'widescreen');
161 $a_threading = $RCMAIL->config->get('message_threading', array()); 161 $a_threading = $RCMAIL->config->get('message_threading', array());
162 $message_sort_col = $RCMAIL->config->get('message_sort_col'); 162 $message_sort_col = $RCMAIL->config->get('message_sort_col');
163 $message_sort_order = $RCMAIL->config->get('message_sort_order'); 163 $message_sort_order = $RCMAIL->config->get('message_sort_order');
164 164
165 // set imap properties and session vars 165 // set imap properties and session vars
166 if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) { 166 $mbox = (rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)??null) ?: (!empty($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX');
167 $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX';
168 }
169 167
170 // we handle 'page' argument on 'list' and 'getunread' to prevent from 168 // we handle 'page' argument on 'list' and 'getunread' to prevent from
171 // race condition and unintentional page overwrite in session 169 // race condition and unintentional page overwrite in session
172 if ($RCMAIL->action == 'list' || $RCMAIL->action == 'getunread') { 170 if ($RCMAIL->action == 'list' || $RCMAIL->action == 'getunread') {
173 if (!($page = intval($_GET['_page']))) { 171 if (!($page = intval($_GET['_page']??null))) {
174 $page = $_SESSION['page'] ?: 1; 172 $page = ($_SESSION['page']??null) ?: 1;
175 } 173 }
176 174
177 $_SESSION['page'] = $page; 175 $_SESSION['page'] = $page;
178 } 176 }
179 177
180 $RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox); 178 $RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox);
181 $RCMAIL->storage->set_page($_SESSION['page']); 179 $RCMAIL->storage->set_page($_SESSION['page']??null);
182 180
183 // set default sort col/order to session 181 // set default sort col/order to session
184 if (!isset($_SESSION['sort_col'])) { 182 if (!isset($_SESSION['sort_col'])) {
185 $_SESSION['sort_col'] = $message_sort_col ?: ''; 183 $_SESSION['sort_col'] = $message_sort_col ?: '';
186 } 184 }
378 376
379 $OUTPUT->include_script('list.js'); 377 $OUTPUT->include_script('list.js');
380 378
381 $table = new html_table($attrib); 379 $table = new html_table($attrib);
382 380
383 if (!$attrib['noheader']) { 381 if (empty($attrib['noheader'])) {
384 foreach (rcmail_message_list_head($attrib, $a_show_cols) as $cell) 382 foreach (rcmail_message_list_head($attrib, $a_show_cols) as $cell)
385 $table->add_header(array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']); 383 $table->add_header(array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']);
386 } 384 }
387 385
388 return $table->show(); 386 return $table->show();
457 unset($a_show_cols[$idx]); 455 unset($a_show_cols[$idx]);
458 } 456 }
459 } 457 }
460 } 458 }
461 459
462 $thead = $head_replace ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL; 460 $thead = !empty($head_replace) ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL;
463 461
464 // get name of smart From/To column in folder context 462 // get name of smart From/To column in folder context
465 if (array_search('fromto', $a_show_cols) !== false) { 463 if (array_search('fromto', $a_show_cols) !== false) {
466 $smart_col = rcmail_message_list_smart_column_name(); 464 $smart_col = rcmail_message_list_smart_column_name();
467 } 465 }
699 697
700 function rcmail_messagecount_display($attrib) 698 function rcmail_messagecount_display($attrib)
701 { 699 {
702 global $RCMAIL; 700 global $RCMAIL;
703 701
704 if (!$attrib['id']) { 702 if (empty($attrib['id'])) {
705 $attrib['id'] = 'rcmcountdisplay'; 703 $attrib['id'] = 'rcmcountdisplay';
706 } 704 }
707 705
708 $RCMAIL->output->add_gui_object('countdisplay', $attrib['id']); 706 $RCMAIL->output->add_gui_object('countdisplay', $attrib['id']);
709 707
784 function rcmail_set_unseen_count($mbox_name, $count) 782 function rcmail_set_unseen_count($mbox_name, $count)
785 { 783 {
786 // @TODO: this data is doubled (session and cache tables) if caching is enabled 784 // @TODO: this data is doubled (session and cache tables) if caching is enabled
787 785
788 // Make sure we have an array here (#1487066) 786 // Make sure we have an array here (#1487066)
789 if (!is_array($_SESSION['unseen_count'])) { 787 if (!is_array($_SESSION['unseen_count']??null)) {
790 $_SESSION['unseen_count'] = array(); 788 $_SESSION['unseen_count'] = array();
791 } 789 }
792 790
793 $_SESSION['unseen_count'][$mbox_name] = $count; 791 $_SESSION['unseen_count'][$mbox_name] = $count;
794 } 792 }
795 793
796 function rcmail_get_unseen_count($mbox_name) 794 function rcmail_get_unseen_count($mbox_name)
797 { 795 {
798 if (is_array($_SESSION['unseen_count']) && array_key_exists($mbox_name, $_SESSION['unseen_count'])) { 796 if (is_array($_SESSION['unseen_count']??null) && array_key_exists($mbox_name, $_SESSION['unseen_count'])) {
799 return $_SESSION['unseen_count'][$mbox_name]; 797 return $_SESSION['unseen_count'][$mbox_name];
800 } 798 }
801 } 799 }
802 800
803 /** 801 /**
966 // free some memory (hopefully) 964 // free some memory (hopefully)
967 unset($data['body']); 965 unset($data['body']);
968 966
969 // plaintext postprocessing 967 // plaintext postprocessing
970 if ($part->ctype_secondary == 'plain') { 968 if ($part->ctype_secondary == 'plain') {
971 $flowed = $part->ctype_parameters['format'] == 'flowed'; 969 $flowed = ($part->ctype_parameters['format']??null) == 'flowed';
972 $delsp = $part->ctype_parameters['delsp'] == 'yes'; 970 $delsp = ($part->ctype_parameters['delsp']??null) == 'yes';
973 $body = rcmail_plain_body($body, $flowed, $delsp); 971 $body = rcmail_plain_body($body, $flowed, $delsp);
974 } 972 }
975 973
976 // allow post-processing of the message body 974 // allow post-processing of the message body
977 $data = $RCMAIL->plugins->exec_hook('message_part_after', 975 $data = $RCMAIL->plugins->exec_hook('message_part_after',
1044 { 1042 {
1045 global $MESSAGE, $PRINT_MODE, $RCMAIL; 1043 global $MESSAGE, $PRINT_MODE, $RCMAIL;
1046 static $sa_attrib; 1044 static $sa_attrib;
1047 1045
1048 // keep header table attrib 1046 // keep header table attrib
1049 if (is_array($attrib) && !$sa_attrib && !$attrib['valueof']) { 1047 if (is_array($attrib) && !$sa_attrib && empty($attrib['valueof'])) {
1050 $sa_attrib = $attrib; 1048 $sa_attrib = $attrib;
1051 } 1049 }
1052 else if (!is_array($attrib) && is_array($sa_attrib)) { 1050 else if (!is_array($attrib) && is_array($sa_attrib)) {
1053 $attrib = $sa_attrib; 1051 $attrib = $sa_attrib;
1054 } 1052 }
1071 } 1069 }
1072 1070
1073 // show these headers 1071 // show these headers
1074 $standard_headers = array('subject', 'from', 'sender', 'to', 'cc', 'bcc', 'replyto', 1072 $standard_headers = array('subject', 'from', 'sender', 'to', 'cc', 'bcc', 'replyto',
1075 'mail-reply-to', 'mail-followup-to', 'date', 'priority'); 1073 'mail-reply-to', 'mail-followup-to', 'date', 'priority');
1076 $exclude_headers = $attrib['exclude'] ? explode(',', $attrib['exclude']) : array(); 1074 $exclude_headers = !empty($attrib['exclude']) ? explode(',', $attrib['exclude']) : array();
1077 $output_headers = array(); 1075 $output_headers = array();
1078 1076
1079 foreach ($standard_headers as $hkey) { 1077 foreach ($standard_headers as $hkey) {
1080 if ($headers[$hkey]) 1078 if ($headers[$hkey]??null)
1081 $value = $headers[$hkey]; 1079 $value = $headers[$hkey];
1082 else if ($headers['others'][$hkey]) 1080 else if ($headers['others'][$hkey]??null)
1083 $value = $headers['others'][$hkey]; 1081 $value = $headers['others'][$hkey];
1084 else if (!$attrib['valueof']) 1082 else if (empty($attrib['valueof']))
1085 continue; 1083 continue;
1086 1084
1087 if (in_array($hkey, $exclude_headers)) 1085 if (in_array($hkey, $exclude_headers))
1088 continue; 1086 continue;
1089 1087
1105 continue; 1103 continue;
1106 } 1104 }
1107 } 1105 }
1108 else if ($hkey == 'replyto') { 1106 else if ($hkey == 'replyto') {
1109 if ($headers['replyto'] != $headers['from']) { 1107 if ($headers['replyto'] != $headers['from']) {
1110 $header_value = rcmail_address_string($value, $attrib['max'], true, 1108 $header_value = rcmail_address_string($value, $attrib['max']??null, true,
1111 $attrib['addicon'], $headers['charset'], $header_title); 1109 $attrib['addicon']??null, $headers['charset'], $header_title);
1112 $ishtml = true; 1110 $ishtml = true;
1113 } 1111 }
1114 else { 1112 else {
1115 continue; 1113 continue;
1116 } 1114 }
1117 } 1115 }
1118 else if ($hkey == 'mail-reply-to') { 1116 else if ($hkey == 'mail-reply-to') {
1119 if ($headers['mail-replyto'] != $headers['replyto'] 1117 if (($headers['mail-replyto']??null) != $headers['replyto']
1120 && $headers['replyto'] != $headers['from'] 1118 && $headers['replyto'] != $headers['from']
1121 ) { 1119 ) {
1122 $header_value = rcmail_address_string($value, $attrib['max'], true, 1120 $header_value = rcmail_address_string($value, $attrib['max']??null, true,
1123 $attrib['addicon'], $headers['charset'], $header_title); 1121 $attrib['addicon']??null, $headers['charset'], $header_title);
1124 $ishtml = true; 1122 $ishtml = true;
1125 } 1123 }
1126 else { 1124 else {
1127 continue; 1125 continue;
1128 } 1126 }
1129 } 1127 }
1130 else if ($hkey == 'sender') { 1128 else if ($hkey == 'sender') {
1131 if ($headers['sender'] != $headers['from']) { 1129 if (($headers['sender']??null) != $headers['from']) {
1132 $header_value = rcmail_address_string($value, $attrib['max'], true, 1130 $header_value = rcmail_address_string($value, $attrib['max']??null, true,
1133 $attrib['addicon'], $headers['charset'], $header_title); 1131 $attrib['addicon']??null, $headers['charset'], $header_title);
1134 $ishtml = true; 1132 $ishtml = true;
1135 } 1133 }
1136 else { 1134 else {
1137 continue; 1135 continue;
1138 } 1136 }
1139 } 1137 }
1140 else if ($hkey == 'mail-followup-to') { 1138 else if ($hkey == 'mail-followup-to') {
1141 $header_value = rcmail_address_string($value, $attrib['max'], true, 1139 $header_value = rcmail_address_string($value, $attrib['max']??null,
1142 $attrib['addicon'], $headers['charset'], $header_title); 1140 true,
1141 $attrib['addicon']??null, $headers['charset'], $header_title);
1143 $ishtml = true; 1142 $ishtml = true;
1144 } 1143 }
1145 else if (in_array($hkey, array('from', 'to', 'cc', 'bcc'))) { 1144 else if (in_array($hkey, array('from', 'to', 'cc', 'bcc'))) {
1146 $header_value = rcmail_address_string($value, $attrib['max'], true, 1145 $header_value = rcmail_address_string($value, $attrib['max']??null, true,
1147 $attrib['addicon'], $headers['charset'], $header_title); 1146 $attrib['addicon']??null, $headers['charset'], $header_title);
1148 $ishtml = true; 1147 $ishtml = true;
1149 } 1148 }
1150 else if ($hkey == 'subject' && empty($value)) { 1149 else if ($hkey == 'subject' && empty($value)) {
1151 $header_value = $RCMAIL->gettext('nosubject'); 1150 $header_value = $RCMAIL->gettext('nosubject');
1152 } 1151 }
1203 '3' => 'normal', 1202 '3' => 'normal',
1204 '4' => 'low', 1203 '4' => 'low',
1205 '5' => 'lowest', 1204 '5' => 'lowest',
1206 ); 1205 );
1207 1206
1208 if ($value && $labels_map[$value]) { 1207 if ($value && !empty($labels_map[$value])) {
1209 return $RCMAIL->gettext($labels_map[$value]); 1208 return $RCMAIL->gettext($labels_map[$value]);
1210 } 1209 }
1211 1210
1212 return ''; 1211 return '';
1213 } 1212 }
1247 } 1246 }
1248 1247
1249 if (!$attrib['id']) 1248 if (!$attrib['id'])
1250 $attrib['id'] = 'rcmailMsgBody'; 1249 $attrib['id'] = 'rcmailMsgBody';
1251 1250
1252 $safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']); 1251 $safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']??null);
1253 $out = ''; 1252 $out = '';
1254 $part_no = 0; 1253 $part_no = 0;
1255 1254
1256 $header_attrib = array(); 1255 $header_attrib = array();
1257 foreach ($attrib as $attr => $value) { 1256 foreach ($attrib as $attr => $value) {
1265 if ($part->type == 'headers') { 1264 if ($part->type == 'headers') {
1266 $out .= html::div('message-partheaders', rcmail_message_headers(count($header_attrib) ? $header_attrib : null, $part->headers)); 1265 $out .= html::div('message-partheaders', rcmail_message_headers(count($header_attrib) ? $header_attrib : null, $part->headers));
1267 } 1266 }
1268 else if ($part->type == 'content') { 1267 else if ($part->type == 'content') {
1269 // unsupported (e.g. encrypted) 1268 // unsupported (e.g. encrypted)
1270 if ($part->realtype) { 1269 if ($part->realtype??null) {
1271 if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') { 1270 if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') {
1272 if (!empty($_SESSION['browser_caps']['pgpmime']) && ($pgp_mime_part = $MESSAGE->get_multipart_encrypted_part())) { 1271 if (!empty($_SESSION['browser_caps']['pgpmime']) && ($pgp_mime_part = $MESSAGE->get_multipart_encrypted_part())) {
1273 $out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption')); 1272 $out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption'));
1274 $OUTPUT->set_env('pgp_mime_part', $pgp_mime_part->mime_id); 1273 $OUTPUT->set_env('pgp_mime_part', $pgp_mime_part->mime_id);
1275 $OUTPUT->set_env('pgp_mime_container', '#' . $attrib['id']); 1274 $OUTPUT->set_env('pgp_mime_container', '#' . $attrib['id']);
2134 $select->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('low'), 'HEADER X-PRIORITY 4'); 2133 $select->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('low'), 'HEADER X-PRIORITY 4');
2135 $select->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('lowest'), 'HEADER X-PRIORITY 5'); 2134 $select->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('lowest'), 'HEADER X-PRIORITY 5');
2136 2135
2137 $RCMAIL->output->add_gui_object('search_filter', $attrib['id']); 2136 $RCMAIL->output->add_gui_object('search_filter', $attrib['id']);
2138 2137
2139 return $select->show($_REQUEST['_search'] ? $_SESSION['search_filter'] : 'ALL'); 2138 return $select->show(($_REQUEST['_search']??null) ? $_SESSION['search_filter'] : 'ALL');
2140 } 2139 }
2141 2140
2142 function rcmail_search_interval($attrib) 2141 function rcmail_search_interval($attrib)
2143 { 2142 {
2144 global $RCMAIL; 2143 global $RCMAIL;
2154 $select->add($RCMAIL->gettext('searchinterval' . $value), $value); 2153 $select->add($RCMAIL->gettext('searchinterval' . $value), $value);
2155 } 2154 }
2156 2155
2157 $RCMAIL->output->add_gui_object('search_interval', $attrib['id']); 2156 $RCMAIL->output->add_gui_object('search_interval', $attrib['id']);
2158 2157
2159 return $select->show($_REQUEST['_search'] ? $_SESSION['search_interval'] : ''); 2158 return $select->show(($_REQUEST['_search']??null) ? $_SESSION['search_interval'] : '');
2160 } 2159 }
2161 2160
2162 function rcmail_message_error() 2161 function rcmail_message_error()
2163 { 2162 {
2164 global $RCMAIL; 2163 global $RCMAIL;