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)
|
if ($is_action_send)
|
||||||
{
|
{
|
||||||
$nbm_user['theme'] = $user['theme'];
|
$env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']);
|
||||||
$env_nbm['mail_template'] = get_mail_template($env_nbm['email_format'], $nbm_user['theme']);
|
|
||||||
$env_nbm['mail_template']->set_filename('notification_by_mail', 'notification_by_mail.tpl');
|
$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 env nbm user
|
||||||
set_user_on_env_nbm($nbm_user, true);
|
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 current var for nbm mail
|
||||||
assign_vars_nbm_mail_content($nbm_user);
|
assign_vars_nbm_mail_content($nbm_user);
|
||||||
|
@ -440,19 +439,21 @@ function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_su
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pwg_mail
|
$ret = pwg_mail(
|
||||||
(
|
array(
|
||||||
format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']),
|
'name' => stripslashes($nbm_user['username']),
|
||||||
array
|
'email' => $nbm_user['mail_address'],
|
||||||
(
|
),
|
||||||
|
array(
|
||||||
'from' => $env_nbm['send_as_mail_formated'],
|
'from' => $env_nbm['send_as_mail_formated'],
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
'email_format' => $env_nbm['email_format'],
|
'email_format' => $env_nbm['email_format'],
|
||||||
'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
|
'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
|
||||||
'content_format' => $env_nbm['email_format'],
|
'content_format' => $env_nbm['email_format'],
|
||||||
'theme' => $nbm_user['theme']
|
|
||||||
)
|
)
|
||||||
))
|
);
|
||||||
|
|
||||||
|
if ($ret)
|
||||||
{
|
{
|
||||||
inc_mail_sent_success($nbm_user);
|
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)
|
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 current var for nbm mail
|
||||||
assign_vars_nbm_mail_content($nbm_user);
|
assign_vars_nbm_mail_content($nbm_user);
|
||||||
|
@ -378,19 +378,21 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pwg_mail
|
$ret = pwg_mail(
|
||||||
(
|
array(
|
||||||
format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']),
|
'name' => stripslashes($nbm_user['username']),
|
||||||
array
|
'email' => $nbm_user['mail_address'],
|
||||||
(
|
),
|
||||||
|
array(
|
||||||
'from' => $env_nbm['send_as_mail_formated'],
|
'from' => $env_nbm['send_as_mail_formated'],
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
'email_format' => $env_nbm['email_format'],
|
'email_format' => $env_nbm['email_format'],
|
||||||
'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
|
'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
|
||||||
'content_format' => $env_nbm['email_format'],
|
'content_format' => $env_nbm['email_format'],
|
||||||
'theme' => $nbm_user['theme']
|
|
||||||
)
|
)
|
||||||
))
|
);
|
||||||
|
|
||||||
|
if ($ret)
|
||||||
{
|
{
|
||||||
inc_mail_sent_success($nbm_user);
|
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
|
* if args is a array, each values are used on sprintf
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_l10n_args($key, $args)
|
function get_l10n_args($key, $args='')
|
||||||
{
|
{
|
||||||
if (is_array($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'];
|
$comment_url = get_absolute_root_url().'comments.php?comment_id='.$comm['id'];
|
||||||
|
|
||||||
$content = array(
|
$keyargs_content = array(
|
||||||
l10n('Author: %s', stripslashes($comm['author']) ),
|
get_l10n_args('Author: %s', stripslashes($comm['author']) ),
|
||||||
l10n('Email: %s', stripslashes($comm['email']) ),
|
get_l10n_args('Email: %s', stripslashes($comm['email']) ),
|
||||||
l10n('Comment: %s', stripslashes($comm['content']) ),
|
get_l10n_args('Comment: %s', stripslashes($comm['content']) ),
|
||||||
'',
|
get_l10n_args(''),
|
||||||
l10n('Manage this user comment: %s', $comment_url),
|
get_l10n_args('Manage this user comment: %s', $comment_url),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ('moderate' == $comment_action)
|
if ('moderate' == $comment_action)
|
||||||
{
|
{
|
||||||
$content[] = l10n('(!) This comment requires validation');
|
$keyargs_content[] = get_l10n_args('(!) This comment requires validation');
|
||||||
}
|
}
|
||||||
|
|
||||||
pwg_mail_notification_admins(
|
pwg_mail_notification_admins(
|
||||||
l10n('Comment by %s', stripslashes($comm['author']) ),
|
get_l10n_args('Comment by %s', stripslashes($comm['author']) ),
|
||||||
implode("\n", $content)
|
$keyargs_content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,17 +373,17 @@ $user_where_clause.'
|
||||||
|
|
||||||
$comment_url = get_absolute_root_url().'comments.php?comment_id='.$comment['comment_id'];
|
$comment_url = get_absolute_root_url().'comments.php?comment_id='.$comment['comment_id'];
|
||||||
|
|
||||||
$content = array(
|
$keyargs_content = array(
|
||||||
l10n('Author: %s', stripslashes($GLOBALS['user']['username']) ),
|
get_l10n_args('Author: %s', stripslashes($GLOBALS['user']['username']) ),
|
||||||
l10n('Comment: %s', stripslashes($comment['content']) ),
|
get_l10n_args('Comment: %s', stripslashes($comment['content']) ),
|
||||||
'',
|
get_l10n_args(''),
|
||||||
l10n('Manage this user comment: %s', $comment_url),
|
get_l10n_args('Manage this user comment: %s', $comment_url),
|
||||||
l10n('(!) This comment requires validation'),
|
get_l10n_args('(!) This comment requires validation'),
|
||||||
);
|
);
|
||||||
|
|
||||||
pwg_mail_notification_admins(
|
pwg_mail_notification_admins(
|
||||||
l10n('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
|
get_l10n_args('Comment by %s', stripslashes($GLOBALS['user']['username']) ),
|
||||||
implode("\n", $content)
|
$keyargs_content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// just mail admin
|
// just mail admin
|
||||||
|
@ -410,23 +410,23 @@ function email_admin($action, $comment)
|
||||||
|
|
||||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
|
|
||||||
$content = array(
|
$keyargs_content = array(
|
||||||
l10n('Author: %s', $comment['author']),
|
get_l10n_args('Author: %s', $comment['author']),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($action=='delete')
|
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
|
else
|
||||||
{
|
{
|
||||||
$content[] = l10n('This author modified following comment:');
|
$keyargs_content[] = get_l10n_args('This author modified following comment:');
|
||||||
$content[] = l10n('Comment: %s', $comment['content']);
|
$keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
|
||||||
}
|
}
|
||||||
|
|
||||||
pwg_mail_notification_admins(
|
pwg_mail_notification_admins(
|
||||||
l10n('Comment by %s', $comment['author']),
|
get_l10n_args('Comment by %s', $comment['author']),
|
||||||
implode("\n", $content)
|
$keyargs_content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,16 @@ function &get_mail_template($email_format)
|
||||||
return $template;
|
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
|
* Switch language to specified language
|
||||||
* All entries are push on language stack
|
* All entries are push on language stack
|
||||||
|
@ -255,8 +265,8 @@ function switch_lang_back()
|
||||||
/**
|
/**
|
||||||
* Send a notification email to all administrators
|
* Send a notification email to all administrators
|
||||||
* current user (if admin) is not notified
|
* current user (if admin) is not notified
|
||||||
* @param string $subject
|
* @param string|array $subject
|
||||||
* @param string $content
|
* @param string|array $content
|
||||||
* @param boolean $send_technical_details - send user IP and browser
|
* @param boolean $send_technical_details - send user IP and browser
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -267,7 +277,12 @@ function pwg_mail_notification_admins($subject, $content, $send_technical_detail
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for backward compatibility < 2.6
|
global $conf, $user;
|
||||||
|
|
||||||
|
if (is_array($subject) or is_array($content))
|
||||||
|
{
|
||||||
|
switch_lang_to(get_default_language());
|
||||||
|
|
||||||
if (is_array($subject))
|
if (is_array($subject))
|
||||||
{
|
{
|
||||||
$subject = l10n_args($subject);
|
$subject = l10n_args($subject);
|
||||||
|
@ -277,15 +292,17 @@ function pwg_mail_notification_admins($subject, $content, $send_technical_detail
|
||||||
$content = l10n_args($content);
|
$content = l10n_args($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
global $conf, $user;
|
switch_lang_back();
|
||||||
|
}
|
||||||
|
|
||||||
$tpl_vars = array();
|
$tpl_vars = array();
|
||||||
if ($send_technical_details)
|
if ($send_technical_details)
|
||||||
{
|
{
|
||||||
$tpl_vars['TECHNICAL'] =
|
$tpl_vars['TECHNICAL'] = array(
|
||||||
l10n('Connected user: %s', stripslashes($user['username'])) ."\n".
|
'username' => stripslashes($user['username']),
|
||||||
l10n('IP: %s', $_SERVER['REMOTE_ADDR']) . "\n" .
|
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||||
l10n('Browser: %s', $_SERVER['HTTP_USER_AGENT']);
|
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pwg_mail_admins(
|
return pwg_mail_admins(
|
||||||
|
|
|
@ -229,16 +229,16 @@ SELECT id
|
||||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
$admin_url = get_absolute_root_url().'admin.php?page=user_list&username='.$login;
|
$admin_url = get_absolute_root_url().'admin.php?page=user_list&username='.$login;
|
||||||
|
|
||||||
$content = array(
|
$keyargs_content = array(
|
||||||
l10n('User: %s', stripslashes($login) ),
|
get_l10n_args('User: %s', stripslashes($login) ),
|
||||||
l10n('Email: %s', $_POST['mail_address']),
|
get_l10n_args('Email: %s', $_POST['mail_address']),
|
||||||
'',
|
get_l10n_args(''),
|
||||||
l10n('Admin: %s', $admin_url),
|
get_l10n_args('Admin: %s', $admin_url),
|
||||||
);
|
);
|
||||||
|
|
||||||
pwg_mail_notification_admins(
|
pwg_mail_notification_admins(
|
||||||
l10n('Registration of %s', stripslashes($login) ),
|
get_l10n_args('Registration of %s', stripslashes($login) ),
|
||||||
implode("\n", $content)
|
$keyargs_content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
{if isset($TECHNICAL)}
|
{if isset($TECHNICAL)}
|
||||||
<p style="padding-top:10px;font-size:11px;">
|
<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>
|
</p>
|
||||||
{/if}
|
{/if}
|
|
@ -38,13 +38,13 @@
|
||||||
{/if}
|
{/if}
|
||||||
<p>{'See you soon,'|@translate}</p>
|
<p>{'See you soon,'|@translate}</p>
|
||||||
<p style="text-align:center">{$SEND_AS_NAME}</p>
|
<p style="text-align:center">{$SEND_AS_NAME}</p>
|
||||||
|
<hr>
|
||||||
<p>
|
<p>
|
||||||
<br><hr>
|
|
||||||
{'To unsubscribe'|@translate}{', click on'|@translate} <a href="{$UNSUBSCRIBE_LINK}">{$UNSUBSCRIBE_LINK}</a><br>
|
{'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>
|
{'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>
|
{'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>
|
</p>
|
||||||
|
<hr>
|
||||||
{if not empty($recent_posts)}
|
{if not empty($recent_posts)}
|
||||||
</div>
|
</div>
|
||||||
<div id="nbm_recent_post">
|
<div id="nbm_recent_post">
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
|
|
||||||
{if isset($TECHNICAL)}
|
{if isset($TECHNICAL)}
|
||||||
-----------------------------
|
-----------------------------
|
||||||
{$TECHNICAL}
|
{'Connected user: %s'|translate:$TECHNICAL.username}
|
||||||
|
{'IP: %s'|translate:$TECHNICAL.ip}
|
||||||
|
{'Browser: %s'|translate:$TECHNICAL.user_agent}
|
||||||
{/if}
|
{/if}
|
|
@ -567,12 +567,6 @@ array(
|
||||||
'vars' => array('string', 'username'),
|
'vars' => array('string', 'username'),
|
||||||
'files' => array('include\functions_user.inc.php (auto_login, try_log_user)'),
|
'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(
|
array(
|
||||||
'name' => 'nbm_event_handler_added',
|
'name' => 'nbm_event_handler_added',
|
||||||
'type' => 'trigger_action',
|
'type' => 'trigger_action',
|
||||||
|
@ -706,33 +700,15 @@ array(
|
||||||
'files' => array('profile.php (save_profile_from_post)'),
|
'files' => array('profile.php (save_profile_from_post)'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'send_mail',
|
'name' => 'before_send_mail',
|
||||||
'type' => 'trigger_event',
|
'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)'),
|
'files' => array('include\functions_mail.inc.php (pwg_mail)'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'send_mail_content',
|
'name' => 'before_parse_mail_template',
|
||||||
'type' => 'trigger_event',
|
'type' => 'trigger_action',
|
||||||
'vars' => array('string', 'content'),
|
'vars' => array('string', 'cache_key', 'string', 'content_type'),
|
||||||
'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'),
|
|
||||||
'files' => array('include\functions_mail.inc.php (pwg_mail)'),
|
'files' => array('include\functions_mail.inc.php (pwg_mail)'),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
|
|
Loading…
Add table
Reference in a new issue