Skip to content

Commit df875dc

Browse files
committed
Add setting: show sender's email when receiving email notifications.
Setting: $_configuration['show_user_email_in_notification'] = false; BT#13672
1 parent 07a989c commit df875dc

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

main/inc/lib/api.lib.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,10 +1353,14 @@ function _api_format_user($user, $add_password = false, $loadAvatars = true)
13531353
}
13541354

13551355
$showEmail = api_get_setting('show_email_addresses') === 'true';
1356-
if (!empty($user['email']) && $showEmail) {
1357-
$result['complete_name_with_email'] = $result['complete_name'].' ('.$user['email'].')';
1356+
if (!empty($user['email'])) {
1357+
$result['complete_name_with_email_forced'] = $result['complete_name'].' ('.$user['email'].')';
1358+
if ($showEmail) {
1359+
$result['complete_name_with_email'] = $result['complete_name'].' ('.$user['email'].')';
1360+
}
13581361
} else {
13591362
$result['complete_name_with_email'] = $result['complete_name'];
1363+
$result['complete_name_with_email_forced'] = $result['complete_name'];
13601364
}
13611365

13621366
// Kept for historical reasons

main/inc/lib/notification.lib.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,14 @@ public function formatContent($content, $senderInfo)
365365
}
366366

367367
$newMessageText = $linkToNewMessage = '';
368+
$showEmail = api_get_configuration_value('show_user_email_in_notification');
369+
$senderInfoName = '';
370+
if (!empty($senderInfo)) {
371+
$senderInfoName = $senderInfo['complete_name'];
372+
if ($showEmail) {
373+
$senderInfoName = $senderInfo['complete_name_with_email_forced'];
374+
}
375+
}
368376

369377
switch ($this->type) {
370378
case self::NOTIFICATION_TYPE_DIRECT_MESSAGE:
@@ -382,7 +390,7 @@ public function formatContent($content, $senderInfo)
382390
if (!empty($senderInfo)) {
383391
$newMessageText = sprintf(
384392
get_lang('YouHaveANewMessageFromX'),
385-
$senderInfo['complete_name_with_email']
393+
$senderInfoName
386394
);
387395
}
388396
$linkToNewMessage = Display::url(
@@ -394,7 +402,7 @@ public function formatContent($content, $senderInfo)
394402
if (!empty($senderInfo)) {
395403
$newMessageText = sprintf(
396404
get_lang('YouHaveANewInvitationFromX'),
397-
$senderInfo['complete_name_with_email']
405+
$senderInfoName
398406
);
399407
}
400408
$linkToNewMessage = Display::url(
@@ -408,7 +416,7 @@ public function formatContent($content, $senderInfo)
408416
$senderName = $senderInfo['group_info']['name'];
409417
$newMessageText = sprintf(get_lang('YouHaveReceivedANewMessageInTheGroupX'), $senderName);
410418
$senderName = Display::url(
411-
$senderInfo['complete_name_with_email'],
419+
$senderInfoName,
412420
api_get_path(WEB_CODE_PATH).'social/profile.php?'.$senderInfo['user_info']['user_id']
413421
);
414422
$newMessageText .= '<br />'.get_lang('User').': '.$senderName;

main/install/configuration.dist.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,3 +679,5 @@
679679
//$_configuration['session_multiple_subscription_students_list_avoid_emptying'] = false;
680680
// Disable the option to set course coach in session when editing course
681681
//$_configuration['disabled_edit_session_coaches_course_editing_course'] = false;
682+
// Show sender's email when receiving email notifications.
683+
//$_configuration['show_user_email_in_notification'] = false;

0 commit comments

Comments
 (0)