aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-11-06 17:57:53 +0000
committermistic100 <mistic@piwigo.org>2013-11-06 17:57:53 +0000
commitfc3b787b70ba83613990860c182e9d7cc20cf1c8 (patch)
tree279057c62bc5a7bd2cf915d51fa4a047b1583032 /include
parent68636067e98ab30914237ed28d5015cbf8dd6fe4 (diff)
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
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php2
-rw-r--r--include/functions_comment.inc.php50
-rw-r--r--include/functions_mail.inc.php49
-rw-r--r--include/functions_user.inc.php14
4 files changed, 66 insertions, 49 deletions
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
);
}