feature 2995: New email template
rewrite pwg_mail_group() and pwg_mail_notification_admins() new function pwg_mail_admins() add complete template management in pwg_mail() TODO : font-size problem in Thunderbird git-svn-id: http://piwigo.org/svn/trunk@25357 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
b768047019
commit
7a5e31e401
9 changed files with 267 additions and 251 deletions
|
|
@ -80,28 +80,29 @@ SELECT id, file, path, representative_ext
|
||||||
$img_url = '';
|
$img_url = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Mettre un array pour traduction subjet
|
|
||||||
pwg_mail_group(
|
pwg_mail_group(
|
||||||
$_POST['group'],
|
$_POST['group'],
|
||||||
get_str_email_format(true), /* TODO add a checkbox in order to choose format*/
|
array(
|
||||||
get_l10n_args('[%s] Visit album %s',
|
'subject' => l10n('[%s] Visit album %s', $conf['gallery_title'], $category['name']),
|
||||||
array($conf['gallery_title'], $category['name'])),
|
// TODO : change this language variable to 'Visit album %s'
|
||||||
'cat_group_info',
|
// TODO : 'language_selected' => ....
|
||||||
array
|
),
|
||||||
(
|
array(
|
||||||
'IMG_URL' => $img_url,
|
'filename' => 'cat_group_info',
|
||||||
'CAT_NAME' => $category['name'],
|
'assign' => array(
|
||||||
'LINK' => make_index_url(
|
'IMG_URL' => $img_url,
|
||||||
array(
|
'CAT_NAME' => $category['name'],
|
||||||
|
'LINK' => make_index_url(array(
|
||||||
'category' => array(
|
'category' => array(
|
||||||
'id' => $category['id'],
|
'id' => $category['id'],
|
||||||
'name' => $category['name'],
|
'name' => $category['name'],
|
||||||
'permalink' => $category['permalink']
|
'permalink' => $category['permalink']
|
||||||
))),
|
)
|
||||||
'CPL_CONTENT' => empty($_POST['mail_content'])
|
)),
|
||||||
? '' : stripslashes($_POST['mail_content'])
|
'CPL_CONTENT' => empty($_POST['mail_content']) ? '' : stripslashes($_POST['mail_content']),
|
||||||
),
|
)
|
||||||
'' /* TODO Add listbox in order to choose Language selected */);
|
)
|
||||||
|
);
|
||||||
|
|
||||||
unset_make_full_url();
|
unset_make_full_url();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ $conf['mail_sender_name'] = '';
|
||||||
$conf['mail_sender_email'] = '';
|
$conf['mail_sender_email'] = '';
|
||||||
|
|
||||||
// set true to allow text/html emails
|
// set true to allow text/html emails
|
||||||
$conf['allow_html_email'] = true;
|
$conf['mail_allow_html'] = true;
|
||||||
|
|
||||||
// 'clear' or 'dark'
|
// 'clear' or 'dark'
|
||||||
$conf['mail_theme'] = 'clear';
|
$conf['mail_theme'] = 'clear';
|
||||||
|
|
|
||||||
|
|
@ -232,25 +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'];
|
||||||
|
|
||||||
$keyargs_content = array
|
$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)
|
||||||
{
|
{
|
||||||
$keyargs_content[] = get_l10n_args('', '');
|
$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
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -376,20 +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'];
|
||||||
|
|
||||||
$keyargs_content = array
|
$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('', ''),
|
|
||||||
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
|
||||||
|
|
@ -416,24 +410,24 @@ 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');
|
||||||
|
|
||||||
$keyargs_content = array();
|
$content = array(
|
||||||
$keyargs_content[] = get_l10n_args('Author: %s', $comment['author']);
|
l10n('Author: %s', $comment['author']),
|
||||||
|
);
|
||||||
|
|
||||||
if ($action=='delete')
|
if ($action=='delete')
|
||||||
{
|
{
|
||||||
$keyargs_content[] = get_l10n_args('This author removed the comment with id %d',
|
$content[] = l10n('This author removed the comment with id %d', $comment['comment_id']);
|
||||||
$comment['comment_id']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$keyargs_content[] = get_l10n_args('This author modified following comment:', '');
|
$content[] = l10n('This author modified following comment:');
|
||||||
$keyargs_content[] = get_l10n_args('Comment: %s', $comment['content']);
|
$content[] = l10n('Comment: %s', $comment['content']);
|
||||||
}
|
}
|
||||||
|
|
||||||
pwg_mail_notification_admins(get_l10n_args('Comment by %s',
|
pwg_mail_notification_admins(
|
||||||
$comment['author']),
|
l10n('Comment by %s', $comment['author']),
|
||||||
$keyargs_content
|
implode("\n", $content)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_comment_author_id($comment_id, $die_on_error=true)
|
function get_comment_author_id($comment_id, $die_on_error=true)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ function get_mail_sender_email()
|
||||||
/**
|
/**
|
||||||
* Returns an array of mail configuration parameters :
|
* Returns an array of mail configuration parameters :
|
||||||
* - send_bcc_mail_webmaster
|
* - send_bcc_mail_webmaster
|
||||||
* - allow_html_email
|
* - mail_allow_html
|
||||||
* - use_smtp
|
* - use_smtp
|
||||||
* - smtp_host
|
* - smtp_host
|
||||||
* - smtp_user
|
* - smtp_user
|
||||||
|
|
@ -64,7 +64,7 @@ function get_mail_configuration()
|
||||||
|
|
||||||
$conf_mail = array(
|
$conf_mail = array(
|
||||||
'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
|
'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
|
||||||
'allow_html_email' => $conf['allow_html_email'],
|
'mail_allow_html' => $conf['mail_allow_html'],
|
||||||
'mail_theme' => $conf['mail_theme'],
|
'mail_theme' => $conf['mail_theme'],
|
||||||
'use_smtp' => !empty($conf['smtp_host']),
|
'use_smtp' => !empty($conf['smtp_host']),
|
||||||
'smtp_host' => $conf['smtp_host'],
|
'smtp_host' => $conf['smtp_host'],
|
||||||
|
|
@ -253,118 +253,117 @@ function switch_lang_back()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns email of all administrator
|
* Send a notification email to all administrators
|
||||||
*
|
* current user (if admin) is not notified
|
||||||
* @return string
|
* @param string $subject
|
||||||
|
* @param string $content
|
||||||
|
* @param boolean $send_technical_details - send user IP and browser
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
/*
|
function pwg_mail_notification_admins($subject, $content, $send_technical_details=true)
|
||||||
* send en notification email to all administrators
|
|
||||||
* if a administrator is doing action,
|
|
||||||
* he's be removed to email list
|
|
||||||
*
|
|
||||||
* @param:
|
|
||||||
* - keyargs_subject: mail subject on l10n_args format
|
|
||||||
* - keyargs_content: mail content on l10n_args format
|
|
||||||
* - send_technical_details: send user IP and browser
|
|
||||||
*
|
|
||||||
* @return boolean (Ok or not)
|
|
||||||
*/
|
|
||||||
function pwg_mail_notification_admins($keyargs_subject, $keyargs_content, $send_technical_details=true)
|
|
||||||
{
|
{
|
||||||
global $conf, $user;
|
if (empty($subject) or empty($content))
|
||||||
|
|
||||||
// Check arguments
|
|
||||||
if (empty($keyargs_subject) or empty($keyargs_content))
|
|
||||||
{
|
{
|
||||||
return false;
|
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;
|
||||||
|
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pwg_mail_admins(
|
||||||
|
array(
|
||||||
|
'subject' => '['. $conf['gallery_title'] .'] '. $subject,
|
||||||
|
'mail_title' => $conf['gallery_title'],
|
||||||
|
'mail_subtitle' => $subject,
|
||||||
|
'content' => $content,
|
||||||
|
'content_format' => 'text/plain',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'filename' => 'notification_admin',
|
||||||
|
'assign' => $tpl_vars,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a email to all administrators
|
||||||
|
* current user (if admin) is excluded
|
||||||
|
* @see pwg_mail()
|
||||||
|
*
|
||||||
|
* @param array $args - as in pwg_mail()
|
||||||
|
* @param array $tpl - as in pwg_mail()
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function pwg_mail_admins($args=array(), $tpl=array())
|
||||||
|
{
|
||||||
|
if (empty($args['content']) and empty($tpl))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $conf, $user;
|
||||||
$return = true;
|
$return = true;
|
||||||
|
|
||||||
$admins = array();
|
// get admins (except ourself)
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
SELECT
|
SELECT
|
||||||
u.'.$conf['user_fields']['username'].' AS username,
|
u.'.$conf['user_fields']['username'].' AS name,
|
||||||
u.'.$conf['user_fields']['email'].' AS mail_address
|
u.'.$conf['user_fields']['email'].' AS email
|
||||||
FROM '.USERS_TABLE.' AS u
|
FROM '.USERS_TABLE.' AS u
|
||||||
JOIN '.USER_INFOS_TABLE.' AS i ON i.user_id = u.'.$conf['user_fields']['id'].'
|
JOIN '.USER_INFOS_TABLE.' AS i
|
||||||
|
ON i.user_id = u.'.$conf['user_fields']['id'].'
|
||||||
WHERE i.status in (\'webmaster\', \'admin\')
|
WHERE i.status in (\'webmaster\', \'admin\')
|
||||||
AND '.$conf['user_fields']['email'].' IS NOT NULL
|
AND u.'.$conf['user_fields']['email'].' IS NOT NULL
|
||||||
AND i.user_id <> '.$user['id'].'
|
AND i.user_id <> '.$user['id'].'
|
||||||
ORDER BY username
|
ORDER BY username
|
||||||
;';
|
;';
|
||||||
|
$admins = array_from_query($query);
|
||||||
|
|
||||||
$datas = pwg_query($query);
|
if (empty($admins))
|
||||||
if (!empty($datas))
|
|
||||||
{
|
{
|
||||||
while ($admin = pwg_db_fetch_assoc($datas))
|
return $return;
|
||||||
{
|
|
||||||
if (!empty($admin['mail_address']))
|
|
||||||
{
|
|
||||||
$admins[] = format_email($admin['username'], $admin['mail_address']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($admins) > 0)
|
switch_lang_to(get_default_language());
|
||||||
{
|
|
||||||
switch_lang_to(get_default_language());
|
|
||||||
|
|
||||||
$content = l10n_args($keyargs_content)."\n";
|
$return = pwg_mail($admins, $args, $tpl);
|
||||||
if ($send_technical_details)
|
|
||||||
{
|
|
||||||
$keyargs_content_admin_info = array(
|
|
||||||
get_l10n_args('Connected user: %s', stripslashes($user['username'])),
|
|
||||||
get_l10n_args('IP: %s', $_SERVER['REMOTE_ADDR']),
|
|
||||||
get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT'])
|
|
||||||
);
|
|
||||||
|
|
||||||
$content.= "\n".l10n_args($keyargs_content_admin_info)."\n";
|
switch_lang_back();
|
||||||
}
|
|
||||||
|
|
||||||
$return = pwg_mail(
|
|
||||||
implode(', ', $admins),
|
|
||||||
array(
|
|
||||||
'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
|
|
||||||
'content' => $content,
|
|
||||||
'content_format' => 'text/plain',
|
|
||||||
'email_format' => 'text/html',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
switch_lang_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* send en email to user's group
|
* Send an email to a group
|
||||||
|
* @see pwg_mail()
|
||||||
*
|
*
|
||||||
* @param:
|
* @param int $group_id
|
||||||
* - group_id: mail are sent to group with this Id
|
* @param array $args - as in pwg_mail()
|
||||||
* - email_format: mail format
|
* @option string language_selected - filters users of the group by language
|
||||||
* - keyargs_subject: mail subject on l10n_args format
|
* @param array $tpl - as in pwg_mail()
|
||||||
* - tpl_shortname: short template name without extension
|
* @return boolean
|
||||||
* - assign_vars: array used to assign_vars to mail template
|
|
||||||
* - language_selected: send mail only to user with this selected language
|
|
||||||
*
|
|
||||||
* @return boolean (Ok or not)
|
|
||||||
*/
|
*/
|
||||||
function pwg_mail_group(
|
function pwg_mail_group($group_id, $args=array(), $tpl=array())
|
||||||
$group_id, $email_format, $keyargs_subject,
|
|
||||||
$tpl_shortname,
|
|
||||||
$assign_vars = array(), $language_selected = '')
|
|
||||||
{
|
{
|
||||||
// Check arguments
|
if (empty($group_id) or ( empty($args['content']) and empty($tpl) ))
|
||||||
if
|
|
||||||
(
|
|
||||||
empty($group_id) or
|
|
||||||
empty($email_format) or
|
|
||||||
empty($keyargs_subject) or
|
|
||||||
empty($tpl_shortname)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -372,94 +371,65 @@ function pwg_mail_group(
|
||||||
global $conf;
|
global $conf;
|
||||||
$return = true;
|
$return = true;
|
||||||
|
|
||||||
|
// get distinct languages of targeted users
|
||||||
$query = '
|
$query = '
|
||||||
SELECT
|
SELECT DISTINCT language
|
||||||
distinct language, theme
|
FROM '.USER_GROUP_TABLE.' AS ug
|
||||||
FROM
|
INNER JOIN '.USERS_TABLE.' AS u
|
||||||
'.USER_GROUP_TABLE.' as ug
|
ON '.$conf['user_fields']['id'].' = ug.user_id
|
||||||
INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id
|
INNER JOIN '.USER_INFOS_TABLE.' AS ui
|
||||||
INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id
|
ON ui.user_id = ug.user_id
|
||||||
WHERE
|
WHERE group_id = '.$group_id.'
|
||||||
'.$conf['user_fields']['email'].' IS NOT NULL
|
AND '.$conf['user_fields']['email'].' <> ""';
|
||||||
AND group_id = '.$group_id;
|
if (!empty($args['language_selected']))
|
||||||
|
|
||||||
if (!empty($language_selected))
|
|
||||||
{
|
{
|
||||||
$query .= '
|
$query .= '
|
||||||
AND language = \''.$language_selected.'\'';
|
AND language = \''.$args['language_selected'].'\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query .= '
|
$query .= '
|
||||||
;';
|
;';
|
||||||
|
$languages = array_from_query($query, 'language');
|
||||||
|
|
||||||
$result = pwg_query($query);
|
if (empty($languages))
|
||||||
|
|
||||||
if (pwg_db_num_rows($result) > 0)
|
|
||||||
{
|
{
|
||||||
$list = array();
|
return $return;
|
||||||
while ($row = pwg_db_fetch_assoc($result))
|
}
|
||||||
{
|
|
||||||
$list[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($list as $elem)
|
foreach ($languages as $language)
|
||||||
{
|
{
|
||||||
$query = '
|
// get subset of users in this group for a specific language
|
||||||
|
$query = '
|
||||||
SELECT
|
SELECT
|
||||||
u.'.$conf['user_fields']['username'].' as username,
|
u.'.$conf['user_fields']['username'].' AS name,
|
||||||
u.'.$conf['user_fields']['email'].' as mail_address
|
u.'.$conf['user_fields']['email'].' AS email
|
||||||
FROM
|
FROM '.USER_GROUP_TABLE.' AS ug
|
||||||
'.USER_GROUP_TABLE.' as ug
|
INNER JOIN '.USERS_TABLE.' AS u
|
||||||
INNER JOIN '.USERS_TABLE.' as u ON '.$conf['user_fields']['id'].' = ug.user_id
|
ON '.$conf['user_fields']['id'].' = ug.user_id
|
||||||
INNER JOIN '.USER_INFOS_TABLE.' as ui ON ui.user_id = ug.user_id
|
INNER JOIN '.USER_INFOS_TABLE.' AS ui
|
||||||
WHERE
|
ON ui.user_id = ug.user_id
|
||||||
'.$conf['user_fields']['email'].' IS NOT NULL
|
WHERE group_id = '.$group_id.'
|
||||||
AND group_id = '.$group_id.'
|
AND '.$conf['user_fields']['email'].' <> ""
|
||||||
AND language = \''.$elem['language'].'\'
|
AND language = \''.$language.'\'
|
||||||
AND theme = \''.$elem['theme'].'\'
|
|
||||||
;';
|
;';
|
||||||
|
$users = array_from_query($query);
|
||||||
|
|
||||||
$result = pwg_query($query);
|
if (empty($users))
|
||||||
|
{
|
||||||
if (pwg_db_num_rows($result) > 0)
|
continue;
|
||||||
{
|
|
||||||
$Bcc = array();
|
|
||||||
while ($row = pwg_db_fetch_assoc($result))
|
|
||||||
{
|
|
||||||
if (!empty($row['mail_address']))
|
|
||||||
{
|
|
||||||
$Bcc[] = format_email(stripslashes($row['username']), $row['mail_address']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($Bcc) > 0)
|
|
||||||
{
|
|
||||||
switch_lang_to($elem['language']);
|
|
||||||
|
|
||||||
$mail_template = get_mail_template($email_format, $elem['theme']);
|
|
||||||
$mail_template->set_filename($tpl_shortname, $tpl_shortname.'.tpl');
|
|
||||||
|
|
||||||
$mail_template->assign(
|
|
||||||
trigger_event('mail_group_assign_vars', $assign_vars));
|
|
||||||
|
|
||||||
$return = pwg_mail
|
|
||||||
(
|
|
||||||
'',
|
|
||||||
array
|
|
||||||
(
|
|
||||||
'Bcc' => $Bcc,
|
|
||||||
'subject' => l10n_args($keyargs_subject),
|
|
||||||
'email_format' => $email_format,
|
|
||||||
'content' => $mail_template->parse($tpl_shortname, true),
|
|
||||||
'content_format' => $email_format,
|
|
||||||
'theme' => $elem['theme']
|
|
||||||
)
|
|
||||||
) and $return;
|
|
||||||
|
|
||||||
switch_lang_back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_lang_to($language);
|
||||||
|
|
||||||
|
$return&= pwg_mail(null,
|
||||||
|
array_merge(
|
||||||
|
$args,
|
||||||
|
array('Bcc' => $users)
|
||||||
|
),
|
||||||
|
$tpl
|
||||||
|
);
|
||||||
|
|
||||||
|
switch_lang_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
@ -473,17 +443,21 @@ WHERE
|
||||||
* o from: sender [default value webmaster email]
|
* o from: sender [default value webmaster email]
|
||||||
* o Cc: array of carbon copy receivers of the mail. [default value empty]
|
* o Cc: array of carbon copy receivers of the mail. [default value empty]
|
||||||
* o Bcc: array of blind carbon copy receivers of the mail. [default value empty]
|
* o Bcc: array of blind carbon copy receivers of the mail. [default value empty]
|
||||||
* o subject [default value 'Piwigo']
|
* o subject [default value 'Piwigo']
|
||||||
* o content: content of mail [default value '']
|
* o content: content of mail [default value '']
|
||||||
* o content_format: format of mail content [default value 'text/plain']
|
* o content_format: format of mail content [default value 'text/plain']
|
||||||
* o email_format: global mail format [default value $conf_mail['default_email_format']]
|
* o email_format: global mail format [default value $conf_mail['default_email_format']]
|
||||||
* o theme: theme to use [default value $conf_mail['mail_theme']]
|
* o theme: theme to use [default value $conf_mail['mail_theme']]
|
||||||
* o mail_title: main title of the mail [default value $conf['gallery_title']]
|
* o mail_title: main title of the mail [default value $conf['gallery_title']]
|
||||||
* o mail_subtitle: subtitle of the mail [default value subject]
|
* o mail_subtitle: subtitle of the mail [default value subject]
|
||||||
|
* @param array $tpl - use these options to define a custom content template file
|
||||||
|
* o filename
|
||||||
|
* o dirname (optional)
|
||||||
|
* o assign (optional)
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function pwg_mail($to, $args = array())
|
function pwg_mail($to, $args=array(), $tpl=array())
|
||||||
{
|
{
|
||||||
global $conf, $conf_mail, $lang_info, $page;
|
global $conf, $conf_mail, $lang_info, $page;
|
||||||
|
|
||||||
|
|
@ -571,6 +545,16 @@ function pwg_mail($to, $args = array())
|
||||||
{
|
{
|
||||||
$args['content'] = '';
|
$args['content'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to decompose subject like "[....] ...."
|
||||||
|
if (!isset($args['mail_title']) and !isset($args['mail_subtitle']))
|
||||||
|
{
|
||||||
|
if (preg_match('#^\[(.*)\](.*)$#', $args['subject'], $matches))
|
||||||
|
{
|
||||||
|
$args['mail_title'] = $matches[1];
|
||||||
|
$args['mail_subtitle'] = $matches[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!isset($args['mail_title']))
|
if (!isset($args['mail_title']))
|
||||||
{
|
{
|
||||||
$args['mail_title'] = $conf['gallery_title'];
|
$args['mail_title'] = $conf['gallery_title'];
|
||||||
|
|
@ -587,7 +571,7 @@ function pwg_mail($to, $args = array())
|
||||||
}
|
}
|
||||||
|
|
||||||
$content_type_list = array();
|
$content_type_list = array();
|
||||||
if ($conf_mail['allow_html_email'] and @$args['email_format'] != 'text/plain')
|
if ($conf_mail['mail_allow_html'] and @$args['email_format'] != 'text/plain')
|
||||||
{
|
{
|
||||||
$content_type_list[] = 'text/html';
|
$content_type_list[] = 'text/html';
|
||||||
}
|
}
|
||||||
|
|
@ -598,7 +582,7 @@ function pwg_mail($to, $args = array())
|
||||||
{
|
{
|
||||||
// key compose of indexes witch allow to cache mail data
|
// key compose of indexes witch allow to cache mail data
|
||||||
$cache_key = $content_type.'-'.$lang_info['code'];
|
$cache_key = $content_type.'-'.$lang_info['code'];
|
||||||
$cache_key.= '-'.crc32(@$args['mail_title'] . @$args['mail_subtitle']);
|
$cache_key.= '-'.crc32(@$args['mail_title'] . @$args['mail_subtitle']); // TODO: find a way to not cache by mail_title
|
||||||
|
|
||||||
if (!isset($conf_mail[$cache_key]))
|
if (!isset($conf_mail[$cache_key]))
|
||||||
{
|
{
|
||||||
|
|
@ -608,11 +592,12 @@ function pwg_mail($to, $args = array())
|
||||||
$conf_mail[$cache_key]['theme'] = get_mail_template($content_type);
|
$conf_mail[$cache_key]['theme'] = get_mail_template($content_type);
|
||||||
trigger_action('before_parse_mail_template', $cache_key, $content_type);
|
trigger_action('before_parse_mail_template', $cache_key, $content_type);
|
||||||
}
|
}
|
||||||
|
$template = &$conf_mail[$cache_key]['theme'];
|
||||||
|
|
||||||
$conf_mail[$cache_key]['theme']->set_filename('mail_header', 'header.tpl');
|
$template->set_filename('mail_header', 'header.tpl');
|
||||||
$conf_mail[$cache_key]['theme']->set_filename('mail_footer', 'footer.tpl');
|
$template->set_filename('mail_footer', 'footer.tpl');
|
||||||
|
|
||||||
$conf_mail[$cache_key]['theme']->assign(
|
$template->assign(
|
||||||
array(
|
array(
|
||||||
'GALLERY_URL' => get_gallery_home_url(),
|
'GALLERY_URL' => get_gallery_home_url(),
|
||||||
'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'],
|
'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'],
|
||||||
|
|
@ -627,31 +612,33 @@ function pwg_mail($to, $args = array())
|
||||||
|
|
||||||
if ($content_type == 'text/html')
|
if ($content_type == 'text/html')
|
||||||
{
|
{
|
||||||
if ($conf_mail[$cache_key]['theme']->smarty->template_exists('global-mail-css.tpl'))
|
if ($template->smarty->template_exists('global-mail-css.tpl'))
|
||||||
{
|
{
|
||||||
$conf_mail[$cache_key]['theme']->set_filename('css', 'global-mail-css.tpl');
|
$template->set_filename('css', 'global-mail-css.tpl');
|
||||||
$conf_mail[$cache_key]['theme']->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
|
$template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf_mail[$cache_key]['theme']->smarty->template_exists('mail-css-'. $args['theme'] .'.tpl'))
|
if ($template->smarty->template_exists('mail-css-'. $args['theme'] .'.tpl'))
|
||||||
{
|
{
|
||||||
$conf_mail[$cache_key]['theme']->set_filename('css', 'mail-css-'. $args['theme'] .'.tpl');
|
$template->set_filename('css', 'mail-css-'. $args['theme'] .'.tpl');
|
||||||
$conf_mail[$cache_key]['theme']->assign_var_from_handle('MAIL_CSS', 'css');
|
$template->assign_var_from_handle('MAIL_CSS', 'css');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$conf_mail[$cache_key]['header'] = $conf_mail[$cache_key]['theme']->parse('mail_header', true);
|
$conf_mail[$cache_key]['header'] = $template->parse('mail_header', true);
|
||||||
$conf_mail[$cache_key]['footer'] = $conf_mail[$cache_key]['theme']->parse('mail_footer', true);
|
$conf_mail[$cache_key]['footer'] = $template->parse('mail_footer', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
$contents[$content_type] = $conf_mail[$cache_key]['header'];
|
$contents[$content_type] = $conf_mail[$cache_key]['header'];
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
|
// Stored in a temp variable, if a content template is used it will be assigned
|
||||||
|
// to the $CONTENT template variable, otherwise it will be appened to the mail
|
||||||
if ($args['content_format'] == 'text/plain' and $content_type == 'text/html')
|
if ($args['content_format'] == 'text/plain' and $content_type == 'text/html')
|
||||||
{
|
{
|
||||||
// convert plain text to html
|
// convert plain text to html
|
||||||
$contents[$content_type].=
|
$mail_content =
|
||||||
'<p>'.
|
'<p>'.
|
||||||
nl2br(
|
nl2br(
|
||||||
preg_replace(
|
preg_replace(
|
||||||
|
|
@ -665,11 +652,39 @@ function pwg_mail($to, $args = array())
|
||||||
else if ($args['content_format'] == 'text/html' and $content_type == 'text/plain')
|
else if ($args['content_format'] == 'text/html' and $content_type == 'text/plain')
|
||||||
{
|
{
|
||||||
// convert html text to plain text
|
// convert html text to plain text
|
||||||
$contents[$content_type].= strip_tags($args['content']);
|
$mail_content = strip_tags($args['content']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$contents[$content_type].= $args['content'];
|
$mail_content = $args['content'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runtime template
|
||||||
|
if (isset($tpl['filename']))
|
||||||
|
{
|
||||||
|
$template = &$conf_mail[$cache_key]['theme'];
|
||||||
|
if (isset($tpl['dirname']))
|
||||||
|
{
|
||||||
|
$template->set_template_dir($tpl['dirname'] .'/'. $content_type);
|
||||||
|
}
|
||||||
|
if ($template->smarty->template_exists($tpl['filename'] .'.tpl'))
|
||||||
|
{
|
||||||
|
$template->set_filename($tpl['filename'], $tpl['filename'] .'.tpl');
|
||||||
|
if (!empty($tpl['assign']))
|
||||||
|
{
|
||||||
|
$template->assign($tpl['assign']);
|
||||||
|
}
|
||||||
|
$template->assign('CONTENT', $mail_content);
|
||||||
|
$contents[$content_type].= $template->parse($tpl['filename'], true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$contents[$content_type].= $mail_content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$contents[$content_type].= $mail_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
|
|
@ -750,7 +765,10 @@ function pwg_mail($to, $args = array())
|
||||||
*/
|
*/
|
||||||
function pwg_send_mail($result, $to, $subject, $content, $headers)
|
function pwg_send_mail($result, $to, $subject, $content, $headers)
|
||||||
{
|
{
|
||||||
trigger_error('pwg_send_mail function is deprecated', E_USER_NOTICE);
|
if (is_admin())
|
||||||
|
{
|
||||||
|
trigger_error('pwg_send_mail function is deprecated', E_USER_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
|
|
@ -765,16 +783,6 @@ function pwg_send_mail($result, $to, $subject, $content, $headers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated 2.6
|
|
||||||
*/
|
|
||||||
function move_ccs_rules_to_body($content)
|
|
||||||
{
|
|
||||||
trigger_error('move_ccs_rules_to_body function is deprecated, use move_css_to_body', E_USER_NOTICE);
|
|
||||||
|
|
||||||
return move_css_to_body($content);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves CSS rules contained in the <style> tag to inline CSS
|
* Moves CSS rules contained in the <style> tag to inline CSS
|
||||||
* (for compatibility with Gmail and such clients)
|
* (for compatibility with Gmail and such clients)
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
$keyargs_content = array(
|
$content = array(
|
||||||
get_l10n_args('User: %s', stripslashes($login)),
|
l10n('User: %s', stripslashes($login) ),
|
||||||
get_l10n_args('Email: %s', $_POST['mail_address']),
|
l10n('Email: %s', $_POST['mail_address']),
|
||||||
get_l10n_args('', ''),
|
'',
|
||||||
get_l10n_args('Admin: %s', $admin_url)
|
l10n('Admin: %s', $admin_url),
|
||||||
);
|
);
|
||||||
|
|
||||||
pwg_mail_notification_admins(
|
pwg_mail_notification_admins(
|
||||||
get_l10n_args('Registration of %s', stripslashes($login)),
|
l10n('Registration of %s', stripslashes($login) ),
|
||||||
$keyargs_content
|
implode("\n", $content)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ html, body, #bodyTable {
|
||||||
/* main block */
|
/* main block */
|
||||||
#header {
|
#header {
|
||||||
background:#eee;
|
background:#eee;
|
||||||
background:radial-gradient(ellipse at center, #fefefe, #e5e5e5);
|
background-image:radial-gradient(ellipse at center, #fefefe, #e5e5e5);
|
||||||
border-top:4px solid #f70;
|
border-top:4px solid #f70;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
text-shadow:1px 1px 0px #fff;
|
text-shadow:1px 1px 0px #fff;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ html, body, #bodyTable {
|
||||||
/* main block */
|
/* main block */
|
||||||
#header {
|
#header {
|
||||||
background:#444;
|
background:#444;
|
||||||
background:radial-gradient(ellipse at center, #555, #333);
|
background-image:radial-gradient(ellipse at center, #555, #333);
|
||||||
border:1px solid #000;
|
border:1px solid #000;
|
||||||
border-top:4px solid #f70;
|
border-top:4px solid #f70;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{$CONTENT}
|
||||||
|
|
||||||
|
{if isset($TECHNICAL)}
|
||||||
|
<p style="margin-top:10px;font-size:10px;">
|
||||||
|
{$TECHNICAL|nl2br}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{$CONTENT}
|
||||||
|
|
||||||
|
{if isset($TECHNICAL)}
|
||||||
|
-----------------------------
|
||||||
|
{$TECHNICAL}
|
||||||
|
{/if}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue