diff options
Diffstat (limited to 'admin/notification_by_mail.php')
-rw-r--r-- | admin/notification_by_mail.php | 104 |
1 files changed, 50 insertions, 54 deletions
diff --git a/admin/notification_by_mail.php b/admin/notification_by_mail.php index 9b773d870..51b284680 100644 --- a/admin/notification_by_mail.php +++ b/admin/notification_by_mail.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | Piwigo - a PHP based photo gallery | // +-----------------------------------------------------------------------+ -// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | +// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ @@ -80,10 +80,11 @@ function do_timeout_treatment($post_keyname, $check_key_treated = array()) $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated); $must_repost = true; - array_push($page['errors'], - l10n_dec('Execution time is out, treatment must be continue [Estimated time: %d second].', - 'Execution time is out, treatment must be continue [Estimated time: %d seconds].', - $time_refresh)); + $page['errors'][] = l10n_dec( + 'Execution time is out, treatment must be continue [Estimated time: %d second].', + 'Execution time is out, treatment must be continue [Estimated time: %d seconds].', + $time_refresh + ); } } @@ -156,29 +157,20 @@ order by $nbm_user['check_key'] = find_available_check_key(); // Save key - array_push($check_key_list, $nbm_user['check_key']); + $check_key_list[] = $nbm_user['check_key']; // Insert new nbm_users - array_push - ( - $inserts, - array - ( - 'user_id' => $nbm_user['user_id'], - 'check_key' => $nbm_user['check_key'], - 'enabled' => 'false' // By default if false, set to true with specific functions - ) - ); - - array_push - ( - $page['infos'], - sprintf( - l10n('User %s [%s] added.'), - stripslashes($nbm_user['username']), - get_email_address_as_display_text($nbm_user['mail_address']) - ) - ); + $inserts[] = array( + 'user_id' => $nbm_user['user_id'], + 'check_key' => $nbm_user['check_key'], + 'enabled' => 'false' // By default if false, set to true with specific functions + ); + + $page['infos'][] = l10n( + 'User %s [%s] added.', + stripslashes($nbm_user['username']), + $nbm_user['mail_address'] + ); } // Insert new nbm_users @@ -282,13 +274,13 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l if ((!$is_action_send) and check_sendmail_timeout()) { // Stop fill list on 'list_to_send', if the quota is override - array_push($page['infos'], $msg_break_timeout); + $page['infos'][] = $msg_break_timeout; break; } if (($is_action_send) and check_sendmail_timeout()) { // Stop fill list on 'send', if the quota is override - array_push($page['errors'], $msg_break_timeout); + $page['errors'][] = $msg_break_timeout; break; } @@ -299,7 +291,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l { set_make_full_url(); // Fill return list of "treated" check_key for 'send' - array_push($return_list, $nbm_user['check_key']); + $return_list[] = $nbm_user['check_key']; if ($conf['nbm_send_detailed_content']) { @@ -313,7 +305,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l if ($exist_data) { - $subject = '['.$conf['gallery_title'].']: '.l10n('New photos added'); + $subject = '['.$conf['gallery_title'].'] '.l10n('New photos added'); // Assign current var for nbm mail assign_vars_nbm_mail_content($nbm_user); @@ -385,26 +377,29 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l 'SEND_AS_NAME' => $env_nbm['send_as_name'], ) ); + + $ret = pwg_mail( + array( + 'name' => stripslashes($nbm_user['username']), + 'email' => $nbm_user['mail_address'], + ), + array( + 'from' => $env_nbm['send_as_mail_formated'], + 'subject' => $subject, + 'email_format' => $env_nbm['email_format'], + 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), + 'content_format' => $env_nbm['email_format'], + ) + ); - if (pwg_mail - ( - format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']), - array - ( - 'from' => $env_nbm['send_as_mail_formated'], - 'subject' => $subject, - 'email_format' => $env_nbm['email_format'], - 'content' => $env_nbm['mail_template']->parse('notification_by_mail', true), - 'content_format' => $env_nbm['email_format'], - 'theme' => $nbm_user['theme'] - ) - )) + if ($ret) { inc_mail_sent_success($nbm_user); - $data = array('user_id' => $nbm_user['user_id'], - 'last_send' => $dbnow); - array_push($datas, $data); + $datas[] = array( + 'user_id' => $nbm_user['user_id'], + 'last_send' => $dbnow + ); } else { @@ -419,7 +414,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l if (news_exists($nbm_user['last_send'], $dbnow)) { // Fill return list of "selected" users for 'list_to_send' - array_push($return_list, $nbm_user); + $return_list[] = $nbm_user; } } @@ -448,7 +443,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l { if ($is_action_send) { - array_push($page['errors'], l10n('No user to send notifications by mail.')); + $page['errors'][] = l10n('No user to send notifications by mail.'); } } } @@ -529,9 +524,10 @@ where } } - array_push($page['infos'], - l10n_dec('%d parameter was updated.', '%d parameters were updated.', - $updated_param_count)); + $page['infos'][] = l10n_dec( + '%d parameter was updated.', '%d parameters were updated.', + $updated_param_count + ); // Reload conf with new values load_conf_from_db('param like \'nbm\\_%\''); @@ -650,7 +646,7 @@ switch ($page['mode']) { if (get_boolean($nbm_user['enabled'])) { - $opt_true[ $nbm_user['check_key'] ] = stripslashes($nbm_user['username']).'['.get_email_address_as_display_text($nbm_user['mail_address']).']'; + $opt_true[ $nbm_user['check_key'] ] = stripslashes($nbm_user['username']).'['.$nbm_user['mail_address'].']'; if ((isset($_POST['falsify']) and isset($_POST['cat_true']) and in_array($nbm_user['check_key'], $_POST['cat_true']))) { $opt_true_selected[] = $nbm_user['check_key']; @@ -658,7 +654,7 @@ switch ($page['mode']) } else { - $opt_false[ $nbm_user['check_key'] ] = stripslashes($nbm_user['username']).'['.get_email_address_as_display_text($nbm_user['mail_address']).']'; + $opt_false[ $nbm_user['check_key'] ] = stripslashes($nbm_user['username']).'['.$nbm_user['mail_address'].']'; if (isset($_POST['trueify']) and isset($_POST['cat_false']) and in_array($nbm_user['check_key'], $_POST['cat_false'])) { $opt_false_selected[] = $nbm_user['check_key']; @@ -704,7 +700,7 @@ switch ($page['mode']) !in_array($nbm_user['check_key'], $_POST['send_selection']) // not selected ) ? '' : 'checked="checked"', 'USERNAME'=> stripslashes($nbm_user['username']), - 'EMAIL' => get_email_address_as_display_text($nbm_user['mail_address']), + 'EMAIL' => $nbm_user['mail_address'], 'LAST_SEND'=> $nbm_user['last_send'] ); } |