diff options
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions_notification_by_mail.inc.php | 33 | ||||
-rw-r--r-- | admin/notification_by_mail.php | 30 | ||||
-rw-r--r-- | include/functions.inc.php | 2 | ||||
-rw-r--r-- | include/functions_comment.inc.php | 50 | ||||
-rw-r--r-- | include/functions_mail.inc.php | 49 | ||||
-rw-r--r-- | include/functions_user.inc.php | 14 | ||||
-rw-r--r-- | themes/default/template/mail/text/html/notification_admin.tpl | 4 | ||||
-rw-r--r-- | themes/default/template/mail/text/html/notification_by_mail.tpl | 4 | ||||
-rw-r--r-- | themes/default/template/mail/text/plain/notification_admin.tpl | 4 | ||||
-rw-r--r-- | tools/triggers_list.php | 34 |
10 files changed, 112 insertions, 112 deletions
diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php index 9d5e7ecfc..81d374b0d 100644 --- a/admin/include/functions_notification_by_mail.inc.php +++ b/admin/include/functions_notification_by_mail.inc.php @@ -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'); } } @@ -423,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); @@ -439,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); } diff --git a/admin/notification_by_mail.php b/admin/notification_by_mail.php index cd3445f7c..8c2f5e278 100644 --- a/admin/notification_by_mail.php +++ b/admin/notification_by_mail.php @@ -305,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); @@ -377,20 +377,22 @@ 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); diff --git a/include/functions.inc.php b/include/functions.inc.php index 83edf45a2..41fbb7d44 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1026,7 +1026,7 @@ function l10n_dec($singular_fmt_key, $plural_fmt_key, $decimal) * if args is a array, each values are used on sprintf * @return string */ -function get_l10n_args($key, $args) +function get_l10n_args($key, $args='') { if (is_array($args)) { diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php index 344a56335..b4599fd4f 100644 --- a/include/functions_comment.inc.php +++ b/include/functions_comment.inc.php @@ -232,22 +232,22 @@ INSERT INTO '.COMMENTS_TABLE.' $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comm['id']; - $content = array( - l10n('Author: %s', stripslashes($comm['author']) ), - l10n('Email: %s', stripslashes($comm['email']) ), - l10n('Comment: %s', stripslashes($comm['content']) ), - '', - l10n('Manage this user comment: %s', $comment_url), + $keyargs_content = array( + get_l10n_args('Author: %s', stripslashes($comm['author']) ), + get_l10n_args('Email: %s', stripslashes($comm['email']) ), + get_l10n_args('Comment: %s', stripslashes($comm['content']) ), + get_l10n_args(''), + get_l10n_args('Manage this user comment: %s', $comment_url), ); if ('moderate' == $comment_action) { - $content[] = l10n('(!) This comment requires validation'); + $keyargs_content[] = get_l10n_args('(!) This comment requires validation'); } pwg_mail_notification_admins( - l10n('Comment by %s', stripslashes($comm['author']) ), - implode("\n", $content) + get_l10n_args('Comment by %s', stripslashes($comm['author']) ), + $keyargs_content ); } } @@ -373,17 +373,17 @@ $user_where_clause.' $comment_url = get_absolute_root_url().'comments.php?comment_id='.$comment['comment_id']; - $content = array( - l10n('Author: %s', stripslashes($GLOBALS['user']['username']) ), - l10n('Comment: %s', stripslashes($comment['content']) ), - '', - l10n('Manage this user comment: %s', $comment_url), - l10n('(!) This comment requires validation'), + $keyargs_content = array( + get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ), + get_l10n_args('Comment: %s', stripslashes($comment['content']) ), + get_l10n_args(''), + get_l10n_args('Manage this user comment: %s', $comment_url), + get_l10n_args('(!) This comment requires validation'), ); pwg_mail_notification_admins( - l10n('Comment by %s', stripslashes($GLOBALS['user']['username']) ), - implode("\n", $content) + get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ), + $keyargs_content ); } // just mail admin @@ -410,24 +410,24 @@ function email_admin($action, $comment) include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); - $content = array( - l10n('Author: %s', $comment['author']), + $keyargs_content = array( + get_l10n_args('Author: %s', $comment['author']), ); if ($action=='delete') { - $content[] = l10n('This author removed the comment with id %d', $comment['comment_id']); + $keyargs_content[] = get_l10n_args('This author removed the comment with id %d', $comment['comment_id']); } else { - $content[] = l10n('This author modified following comment:'); - $content[] = l10n('Comment: %s', $comment['content']); + $keyargs_content[] = get_l10n_args('This author modified following comment:'); + $keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']); } pwg_mail_notification_admins( - l10n('Comment by %s', $comment['author']), - implode("\n", $content) - ); + get_l10n_args('Comment by %s', $comment['author']), + $keyargs_content + ); } function get_comment_author_id($comment_id, $die_on_error=true) diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index 20308f9ed..24f8db247 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -168,6 +168,16 @@ function &get_mail_template($email_format) } /** + * Return string email format (text/html or text/plain) + * @param bool is_html + * @return string + */ +function get_str_email_format($is_html) +{ + return ($is_html ? 'text/html' : 'text/plain'); +} + +/** * Switch language to specified language * All entries are push on language stack * @param string $language @@ -255,8 +265,8 @@ function switch_lang_back() /** * Send a notification email to all administrators * current user (if admin) is not notified - * @param string $subject - * @param string $content + * @param string|array $subject + * @param string|array $content * @param boolean $send_technical_details - send user IP and browser * @return boolean */ @@ -266,26 +276,33 @@ function pwg_mail_notification_admins($subject, $content, $send_technical_detail { return false; } - - // for backward compatibility < 2.6 - if (is_array($subject)) - { - $subject = l10n_args($subject); - } - if (is_array($content)) + + global $conf, $user; + + if (is_array($subject) or is_array($content)) { - $content = l10n_args($content); + switch_lang_to(get_default_language()); + + if (is_array($subject)) + { + $subject = l10n_args($subject); + } + if (is_array($content)) + { + $content = l10n_args($content); + } + + switch_lang_back(); } - global $conf, $user; - $tpl_vars = array(); if ($send_technical_details) { - $tpl_vars['TECHNICAL'] = - l10n('Connected user: %s', stripslashes($user['username'])) ."\n". - l10n('IP: %s', $_SERVER['REMOTE_ADDR']) . "\n" . - l10n('Browser: %s', $_SERVER['HTTP_USER_AGENT']); + $tpl_vars['TECHNICAL'] = array( + 'username' => stripslashes($user['username']), + 'ip' => $_SERVER['REMOTE_ADDR'], + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + ); } return pwg_mail_admins( diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index a71335e74..21844b290 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -229,16 +229,16 @@ SELECT id include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); $admin_url = get_absolute_root_url().'admin.php?page=user_list&username='.$login; - $content = array( - l10n('User: %s', stripslashes($login) ), - l10n('Email: %s', $_POST['mail_address']), - '', - l10n('Admin: %s', $admin_url), + $keyargs_content = array( + get_l10n_args('User: %s', stripslashes($login) ), + get_l10n_args('Email: %s', $_POST['mail_address']), + get_l10n_args(''), + get_l10n_args('Admin: %s', $admin_url), ); pwg_mail_notification_admins( - l10n('Registration of %s', stripslashes($login) ), - implode("\n", $content) + get_l10n_args('Registration of %s', stripslashes($login) ), + $keyargs_content ); } diff --git a/themes/default/template/mail/text/html/notification_admin.tpl b/themes/default/template/mail/text/html/notification_admin.tpl index f30c0df07..f236b8ee6 100644 --- a/themes/default/template/mail/text/html/notification_admin.tpl +++ b/themes/default/template/mail/text/html/notification_admin.tpl @@ -2,6 +2,8 @@ {if isset($TECHNICAL)} <p style="padding-top:10px;font-size:11px;"> -{$TECHNICAL|nl2br} +{'Connected user: %s'|translate:$TECHNICAL.username}<br> +{'IP: %s'|translate:$TECHNICAL.ip}<br> +{'Browser: %s'|translate:$TECHNICAL.user_agent} </p> {/if}
\ No newline at end of file diff --git a/themes/default/template/mail/text/html/notification_by_mail.tpl b/themes/default/template/mail/text/html/notification_by_mail.tpl index 9989a32c0..df3e431e1 100644 --- a/themes/default/template/mail/text/html/notification_by_mail.tpl +++ b/themes/default/template/mail/text/html/notification_by_mail.tpl @@ -38,13 +38,13 @@ {/if} <p>{'See you soon,'|@translate}</p> <p style="text-align:center">{$SEND_AS_NAME}</p> +<hr> <p> -<br><hr> {'To unsubscribe'|@translate}{', click on'|@translate} <a href="{$UNSUBSCRIBE_LINK}">{$UNSUBSCRIBE_LINK}</a><br> {'To subscribe'|@translate}{', click on'|@translate} <a href="{$SUBSCRIBE_LINK}">{$SUBSCRIBE_LINK}</a><br> {'If you encounter problems or have any question, please send a message to'|@translate} <a href="mailto:{$CONTACT_EMAIL}?subject={'[NBM] Problems or questions'|@translate}">{$CONTACT_EMAIL}</a><br> -<hr><br> </p> +<hr> {if not empty($recent_posts)} </div> <div id="nbm_recent_post"> diff --git a/themes/default/template/mail/text/plain/notification_admin.tpl b/themes/default/template/mail/text/plain/notification_admin.tpl index b7d552626..e6970842f 100644 --- a/themes/default/template/mail/text/plain/notification_admin.tpl +++ b/themes/default/template/mail/text/plain/notification_admin.tpl @@ -2,5 +2,7 @@ {if isset($TECHNICAL)} ----------------------------- -{$TECHNICAL} +{'Connected user: %s'|translate:$TECHNICAL.username} +{'IP: %s'|translate:$TECHNICAL.ip} +{'Browser: %s'|translate:$TECHNICAL.user_agent} {/if}
\ No newline at end of file diff --git a/tools/triggers_list.php b/tools/triggers_list.php index bd57023c1..e9ec6eb3c 100644 --- a/tools/triggers_list.php +++ b/tools/triggers_list.php @@ -568,12 +568,6 @@ array( 'files' => array('include\functions_user.inc.php (auto_login, try_log_user)'), ), array( - 'name' => 'mail_group_assign_vars', - 'type' => 'trigger_event', - 'vars' => array('array', 'assign_vars'), - 'files' => array('include\functions_mail.inc.php (pwg_mail_group)'), -), -array( 'name' => 'nbm_event_handler_added', 'type' => 'trigger_action', 'vars' => array(), @@ -706,33 +700,15 @@ array( 'files' => array('profile.php (save_profile_from_post)'), ), array( - 'name' => 'send_mail', + 'name' => 'before_send_mail', 'type' => 'trigger_event', - 'vars' => array('bool', 'result', 'string', 'mail_to', 'string', 'mail_subject', 'string', 'mail_content', 'array', 'mail_headers'), + 'vars' => array('bool', 'result', 'mixed', 'to', 'array', 'arguments', 'PHPMailer', 'mail'), 'files' => array('include\functions_mail.inc.php (pwg_mail)'), ), array( - 'name' => 'send_mail_content', - 'type' => 'trigger_event', - 'vars' => array('string', 'content'), - 'files' => array('include\functions_mail.inc.php (pwg_mail)'), -), -array( - 'name' => 'send_mail_headers', - 'type' => 'trigger_event', - 'vars' => array('array', 'headers'), - 'files' => array('include\functions_mail.inc.php (pwg_mail)'), -), -array( - 'name' => 'send_mail_subject', - 'type' => 'trigger_event', - 'vars' => array('string', 'cvt_subject'), - 'files' => array('include\functions_mail.inc.php (pwg_mail)'), -), -array( - 'name' => 'send_mail_to', - 'type' => 'trigger_event', - 'vars' => array('string', 'to'), + 'name' => 'before_parse_mail_template', + 'type' => 'trigger_action', + 'vars' => array('string', 'cache_key', 'string', 'content_type'), 'files' => array('include\functions_mail.inc.php (pwg_mail)'), ), array( |