aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions_notification_by_mail.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/include/functions_notification_by_mail.inc.php')
-rw-r--r--admin/include/functions_notification_by_mail.inc.php100
1 files changed, 58 insertions, 42 deletions
diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php
index e727e9e6f..8d0fe2621 100644
--- a/admin/include/functions_notification_by_mail.inc.php
+++ b/admin/include/functions_notification_by_mail.inc.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 |
// +-----------------------------------------------------------------------+
@@ -169,7 +169,7 @@ order by';
{
while ($nbm_user = pwg_db_fetch_assoc($result))
{
- array_push($data_users, $nbm_user);
+ $data_users[] = $nbm_user;
}
}
}
@@ -256,8 +256,7 @@ function set_user_on_env_nbm(&$nbm_user, $is_action_send)
if ($is_action_send)
{
- $nbm_user['theme'] = $user['theme'];
- $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format'], $nbm_user['theme']);
+ $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']);
$env_nbm['mail_template']->set_filename('notification_by_mail', 'notification_by_mail.tpl');
}
}
@@ -285,7 +284,7 @@ function inc_mail_sent_success($nbm_user)
global $page, $env_nbm;
$env_nbm['sent_mail_count'] += 1;
- array_push($page['infos'], sprintf($env_nbm['msg_info'], stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['infos'][] = sprintf($env_nbm['msg_info'], stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
/*
@@ -298,7 +297,7 @@ function inc_mail_sent_failed($nbm_user)
global $page, $env_nbm;
$env_nbm['error_on_mail_count'] += 1;
- array_push($page['errors'], sprintf($env_nbm['msg_error'], stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['errors'][] = sprintf($env_nbm['msg_error'], stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
/*
@@ -312,16 +311,32 @@ function display_counter_info()
if ($env_nbm['error_on_mail_count'] != 0)
{
- array_push($page['errors'], l10n_dec('%d mail was not sent.', '%d mails were not sent.', $env_nbm['error_on_mail_count']));
+ $page['errors'][] = l10n_dec(
+ '%d mail was not sent.', '%d mails were not sent.',
+ $env_nbm['error_on_mail_count']
+ );
+
if ($env_nbm['sent_mail_count'] != 0)
- array_push($page['infos'], l10n_dec('%d mail was sent.', '%d mails were sent.', $env_nbm['sent_mail_count']));
+ {
+ $page['infos'][] = l10n_dec(
+ '%d mail was sent.', '%d mails were sent.',
+ $env_nbm['sent_mail_count']
+ );
+ }
}
else
{
if ($env_nbm['sent_mail_count'] == 0)
- array_push($page['infos'], l10n('No mail to send.'));
+ {
+ $page['infos'][] = l10n('No mail to send.');
+ }
else
- array_push($page['infos'], l10n_dec('%d mail was sent.', '%d mails were sent.', $env_nbm['sent_mail_count']));
+ {
+ $page['infos'][] = l10n_dec(
+ '%d mail was sent.', '%d mails were sent.',
+ $env_nbm['sent_mail_count']
+ );
+ }
}
}
@@ -394,12 +409,12 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
if (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;
}
// Fill return list
- array_push($check_key_treated, $nbm_user['check_key']);
+ $check_key_treated[] = $nbm_user['check_key'];
$do_update = true;
if ($nbm_user['mail_address'] != '')
@@ -407,7 +422,7 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
// set env nbm user
set_user_on_env_nbm($nbm_user, true);
- $subject = '['.$conf['gallery_title'].']: '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
+ $subject = '['.$conf['gallery_title'].'] '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
// Assign current var for nbm mail
assign_vars_nbm_mail_content($nbm_user);
@@ -423,20 +438,22 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
'GOTO_GALLERY_URL' => get_gallery_home_url(),
)
);
+
+ $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);
}
@@ -453,22 +470,17 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
if ($do_update)
{
- array_push
- (
- $updates,
- array
- (
- 'check_key' => $nbm_user['check_key'],
- 'enabled' => $enabled_value
- )
- );
+ $updates[] = array(
+ 'check_key' => $nbm_user['check_key'],
+ 'enabled' => $enabled_value
+ );
$updated_data_count += 1;
- array_push($page['infos'], sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['infos'][] = sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
else
{
$error_on_updated_data_count += 1;
- array_push($page['errors'], sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']));
+ $page['errors'][] = sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
}
}
@@ -489,13 +501,17 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
}
- array_push($page['infos'], l10n_dec('%d user was updated.', '%d users were updated.', $updated_data_count));
+ $page['infos'][] = l10n_dec(
+ '%d user was updated.', '%d users were updated.',
+ $updated_data_count
+ );
+
if ($error_on_updated_data_count != 0)
{
- array_push($page['errors'],
- l10n_dec('%d user was not updated.',
- '%d users were not updated.',
- $error_on_updated_data_count));
+ $page['errors'][] = l10n_dec(
+ '%d user was not updated.', '%d users were not updated.',
+ $error_on_updated_data_count
+ );
}
unset_make_full_url();