aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2011-02-23 10:44:07 +0000
committerplegall <plg@piwigo.org>2011-02-23 10:44:07 +0000
commit139360b952ff62f6a727a6b1f1e092c08b0b72d4 (patch)
tree3d4eb76f222608d4705fd99a66b46b564b19c002 /include
parentf409eb1c5d749c16622c31eb29f656f840ef9e16 (diff)
feature added: ability to avoid sending technical details with pwg_mail_notification_admins
change: pwg_mail_notification_admins forces the format to be text/plain git-svn-id: http://piwigo.org/svn/trunk@9360 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/functions_mail.inc.php68
1 files changed, 31 insertions, 37 deletions
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index 29704653a..76567ce40 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -277,38 +277,31 @@ function switch_lang_back()
*
* @return boolean (Ok or not)
*/
-function pwg_mail_notification_admins($keyargs_subject, $keyargs_content)
+function pwg_mail_notification_admins($keyargs_subject, $keyargs_content, $send_technical_details=true)
{
+ global $conf, $user;
+
// Check arguments
- if
- (
- empty($keyargs_subject) or
- empty($keyargs_content)
- )
+ if (empty($keyargs_subject) or empty($keyargs_content))
{
return false;
}
- global $conf, $user;
$return = true;
$admins = array();
$query = '
-select
- U.'.$conf['user_fields']['username'].' as username,
- U.'.$conf['user_fields']['email'].' as mail_address
-from
- '.USERS_TABLE.' as U,
- '.USER_INFOS_TABLE.' as I
-where
- I.user_id = U.'.$conf['user_fields']['id'].' and
- I.status in (\'webmaster\', \'admin\') and
- '.$conf['user_fields']['email'].' is not null and
- I.user_id <> '.$user['id'].'
-order by
- username
-';
+SELECT
+ u.'.$conf['user_fields']['username'].' AS username,
+ u.'.$conf['user_fields']['email'].' AS mail_address
+ FROM '.USERS_TABLE.' AS u
+ JOIN '.USER_INFOS_TABLE.' AS i ON i.user_id = u.'.$conf['user_fields']['id'].'
+ WHERE i.status in (\'webmaster\', \'admin\')
+ AND '.$conf['user_fields']['email'].' IS NOT NULL
+ AND i.user_id <> '.$user['id'].'
+ ORDER BY username
+;';
$datas = pwg_query($query);
if (!empty($datas))
@@ -324,29 +317,30 @@ order by
if (count($admins) > 0)
{
- $keyargs_content_admin_info = array
- (
+ $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'])
- );
+ );
switch_lang_to(get_default_language());
- $return = pwg_mail
- (
- '',
- array
- (
- 'Bcc' => $admins,
- 'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
- 'content' =>
- l10n_args($keyargs_content)."\n\n"
- .l10n_args($keyargs_content_admin_info)."\n",
- 'content_format' => 'text/plain'
- )
- ) and $return;
+ $content = l10n_args($keyargs_content)."\n";
+ if ($send_technical_details)
+ {
+ $content.= "\n".l10n_args($keyargs_content_admin_info)."\n";
+ }
+ $return = pwg_mail(
+ implode(', ', $admins),
+ array(
+ 'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
+ 'content' => $content,
+ 'content_format' => 'text/plain',
+ 'email_format' => 'text/plain',
+ )
+ );
+
switch_lang_back();
}