feature 2995: New email template
restore get_l10n_args removed at r25357 apply changes to NBM git-svn-id: http://piwigo.org/svn/trunk@25360 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
68636067e9
commit
fc3b787b70
10 changed files with 113 additions and 113 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -167,6 +167,16 @@ function &get_mail_template($email_format)
|
|||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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))
|
||||
{
|
||||
$content = l10n_args($content);
|
||||
}
|
||||
|
||||
global $conf, $user;
|
||||
|
||||
|
||||
if (is_array($subject) or is_array($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();
|
||||
}
|
||||
|
||||
$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(
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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}
|
|
@ -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">
|
||||
|
|
|
@ -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}
|
|
@ -567,12 +567,6 @@ array(
|
|||
'vars' => array('string', 'username'),
|
||||
'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',
|
||||
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue