aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_mail.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2015-12-31 19:59:08 +0100
committerplegall <plg@piwigo.org>2015-12-31 19:59:08 +0100
commit4aeedb5a2ea455c503721de29a35e8a3c1fa0a9d (patch)
tree1e5892d3f32f1491d85067cc9def93270649c8c6 /include/functions_mail.inc.php
parenteee57a5d2ece31f9b99485f82a310b80d8fa3935 (diff)
feature #392, authentication keys, album notification
* On album notification (for a group), sends one distinct email for each user with a new authentication key. * When someone clicks the link with auth=<key> in URL, if the user is not already connected, Piwigo will automatically connect the user.
Diffstat (limited to 'include/functions_mail.inc.php')
-rw-r--r--include/functions_mail.inc.php30
1 files changed, 23 insertions, 7 deletions
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index ed1081713..529f2da0d 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -514,6 +514,8 @@ SELECT DISTINCT language
// get subset of users in this group for a specific language
$query = '
SELECT
+ ui.user_id,
+ ui.status,
u.'.$conf['user_fields']['username'].' AS name,
u.'.$conf['user_fields']['email'].' AS email
FROM '.USER_GROUP_TABLE.' AS ug
@@ -534,13 +536,27 @@ SELECT
switch_lang_to($language);
- $return&= pwg_mail(null,
- array_merge(
- $args,
- array('Bcc' => $users)
- ),
- $tpl
- );
+ foreach ($users as $u)
+ {
+ $authkey = create_user_auth_key($u['user_id'], $u['status']);
+
+ $user_tpl = $tpl;
+
+ if ($authkey !== false)
+ {
+ $user_tpl['assign']['LINK'] = add_url_params($tpl['assign']['LINK'], array('auth' => $authkey['auth_key']));
+
+ if (isset($user_tpl['assign']['IMG']['link']))
+ {
+ $user_tpl['assign']['IMG']['link'] = add_url_params(
+ $user_tpl['assign']['IMG']['link'],
+ array('auth' => $authkey['auth_key'])
+ );
+ }
+ }
+
+ $return &= pwg_mail($u['email'], $args, $user_tpl);
+ }
switch_lang_back();
}