Changeset 1156 for trunk/admin/notification_by_mail.php
- Timestamp:
- Apr 13, 2006, 12:49:42 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/notification_by_mail.php
r1116 r1156 48 48 49 49 // +-----------------------------------------------------------------------+ 50 // | Initialization | 51 // +-----------------------------------------------------------------------+ 52 $base_url = get_root_url().'admin.php'; 53 54 // +-----------------------------------------------------------------------+ 50 55 // | functions | 51 56 // +-----------------------------------------------------------------------+ 57 58 /* 59 * Do background treatmetn in order to finish to send mails 60 * 61 * @param $post_keyname: key of check_key post array 62 * @param check_key_treated:array of check_key treated 63 * @return none 64 */ 65 function do_background_treatment($post_keyname, $check_key_treated = array()) 66 { 67 global $env_nbm, $base_url; 68 69 if ($env_nbm['is_sendmail_timeout']) 70 { 71 if (isset($_POST[$post_keyname])) 72 { 73 $post_count = count($_POST[$post_keyname]); 74 $treated_count = count($check_key_treated); 75 if ($treated_count != 0) 76 { 77 $time_refresh = ceil((get_moment() - $env_nbm['start_time']) * $post_count / $treated_count); 78 } 79 else 80 { 81 $time_refresh = 10; 82 } 83 $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated); 84 re_post_http($base_url.get_query_string_diff(array()), sprintf(l10n('nbm_background_treatment_redirect'), $time_refresh) , $time_refresh); 85 } 86 } 87 88 } 52 89 53 90 /* … … 79 116 function insert_new_data_user_mail_notification() 80 117 { 81 global $conf, $page ;118 global $conf, $page, $env_nbm; 82 119 83 120 // Set null mail_address empty … … 138 175 mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts); 139 176 // Update field enabled with specific function 140 do_subscribe_unsubcribe_notification_by_mail177 $check_key_treated = do_subscribe_unsubcribe_notification_by_mail 141 178 ( 142 179 true, … … 144 181 $check_key_list 145 182 ); 183 184 // On timeout simulate like tabsheet send 185 if ($env_nbm['is_sendmail_timeout']) 186 { 187 if ($conf['nbm_default_value_user_enabled']) 188 { 189 $_POST['trueify'] = 'trueify'; 190 $_POST['cat_false'] = $check_key_list; 191 do_background_treatment('cat_false', $check_key_treated); 192 } 193 else 194 { 195 $_POST['falsify'] = 'falsify'; 196 $_POST['cat_true'] = $check_key_list; 197 do_background_treatment('cat_true', $check_key_treated); 198 } 199 } 146 200 } 147 201 } … … 149 203 /* 150 204 * Send mail for notification to all users 151 * Return list of "treated/selected" users 205 * Return list of "selected" users for 'list_to_send' 206 * Return list of "treated" check_key for 'send' 152 207 */ 153 208 function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '') … … 177 232 $datas = array(); 178 233 234 // Prepare message after change language 235 if ($is_action_send) 236 { 237 $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail'); 238 } 239 else 240 { 241 $msg_break_timeout = l10n('nbm_break_timeout_list_user'); 242 } 243 179 244 // Begin nbm users environment 180 245 begin_users_env_nbm($is_action_send); … … 182 247 foreach ($data_users as $nbm_user) 183 248 { 184 if ((!$is_action_send) and (count($return_list) >= $conf['nbm_max_list_users_to_send']))249 if ((!$is_action_send) and check_sendmail_timeout()) 185 250 { 186 251 // Stop fill list on 'list_to_send', if the quota is override 187 array_push($page['infos'], sprintf(l10n('nbm_break_list_user'), $conf['nbm_max_list_users_to_send']));252 array_push($page['infos'], $msg_break_timeout); 188 253 break; 189 254 } 190 if (($is_action_send) and (count($return_list) >= $conf['nbm_max_mails_send']))255 if (($is_action_send) and check_sendmail_timeout()) 191 256 { 192 257 // Stop fill list on 'send', if the quota is override 193 array_push($page['errors'], sprintf(l10n('nbm_nbm_break_send_mail'), $conf['nbm_max_mails_send']));258 array_push($page['errors'], $msg_break_timeout); 194 259 break; 195 260 } … … 200 265 if ($is_action_send) 201 266 { 267 // Fill return list of "treated" check_key for 'send' 268 array_push($return_list, $nbm_user['check_key']); 202 269 $message = ''; 203 270 … … 214 281 if ($exist_data) 215 282 { 216 array_push($return_list, $nbm_user);217 218 283 $subject = '['.$conf['gallery_title'].']: '.l10n('nbm_object_news'); 219 284 $message .= sprintf(l10n('nbm_content_hello'), $nbm_user['username']).",\n\n"; … … 263 328 if (news_exists($nbm_user['last_send'], $dbnow)) 264 329 { 330 // Fill return list of "selected" users for 'list_to_send' 265 331 array_push($return_list, $nbm_user); 266 332 } … … 296 362 { 297 363 // Quick List, don't check news 364 // Fill return list of "selected" users for 'list_to_send' 298 365 $return_list = $data_users; 299 366 } 300 367 } 368 369 // Return list of "selected" users for 'list_to_send' 370 // Return list of "treated" check_key for 'send' 301 371 return $return_list; 302 372 } … … 384 454 if (isset($_POST['falsify']) and isset($_POST['cat_true'])) 385 455 { 386 unsubcribe_notification_by_mail(true, $_POST['cat_true']); 456 $check_key_treated = unsubcribe_notification_by_mail(true, $_POST['cat_true']); 457 do_background_treatment('cat_true', $check_key_treated); 387 458 } 388 459 else 389 460 if (isset($_POST['trueify']) and isset($_POST['cat_false'])) 390 461 { 391 subcribe_notification_by_mail(true, $_POST['cat_false']); 462 $check_key_treated = subcribe_notification_by_mail(true, $_POST['cat_false']); 463 do_background_treatment('cat_false', $check_key_treated); 392 464 } 393 465 break; … … 398 470 if (isset($_POST['send_submit']) and isset($_POST['send_selection']) and isset($_POST['send_customize_mail_content'])) 399 471 { 400 do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']); 472 $check_key_treated = do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']); 473 do_background_treatment('send_selection', $check_key_treated); 401 474 } 402 475 } … … 415 488 ); 416 489 417 $base_url = get_root_url().'admin.php';418 419 490 $template->assign_vars 420 491 ( … … 422 493 ( 423 494 'U_TABSHEET_TITLE' => l10n('nbm_'.$page['mode'].'_mode'), 424 'U_HELP' => add_url_params(get_root_url().' /popuphelp.php', array('page' => 'notification_by_mail')),495 'U_HELP' => add_url_params(get_root_url().'popuphelp.php', array('page' => 'notification_by_mail')), 425 496 'F_ACTION'=> $base_url.get_query_string_diff(array()) 426 497 )
Note: See TracChangeset
for help on using the changeset viewer.