add config option for safe addressbooks to use when checking known senders

pull/6062/head
PhilW 7 years ago
parent 4fee0b22d8
commit 687802f27f

@ -1007,6 +1007,11 @@ $config['autocomplete_threads'] = 0;
// Max. numer of entries in autocomplete popup. Default: 15.
$config['autocomplete_max'] = 15;
// An ordered array of the ids of the addressbooks that should be searched
// when checking if remote resources should be displayed ex: array('sql','Verisign');
// Default: null, the default_addressbook will be used
$config['safe_addressbooks'] = null;
// show address fields in this order
// available placeholders: {street}, {locality}, {zipcode}, {country}, {region}
$config['address_template'] = '{street}<br/>{locality} {zipcode}<br/>{country} {region}';
@ -1067,7 +1072,7 @@ $config['prefer_html'] = true;
// display remote resources (inline images, styles)
// 0 - Never, always ask
// 1 - Ask if sender is not in address book
// 1 - Ask if sender is not in address book (see also safe_addressbooks)
// 2 - Always allow
$config['show_images'] = 0;

@ -815,13 +815,18 @@ function rcmail_check_safe($message)
) {
switch ($show_images) {
case 1: // known senders only
// get default addressbook, like in addcontact.inc
$CONTACTS = $RCMAIL->get_address_book(-1, true);
// get list of safe address books
$book_types = (array) $RCMAIL->config->get('safe_addressbooks', -1);
if ($CONTACTS && $message->sender['mailto']) {
$result = $CONTACTS->search('email', $message->sender['mailto'], 1, false);
if ($result->count) {
$message->set_safe(true);
foreach ($book_types as $abook_id) {
$CONTACTS = $RCMAIL->get_address_book($abook_id);
if ($CONTACTS && $message->sender['mailto']) {
$result = $CONTACTS->search('email', $message->sender['mailto'], 1, false);
if ($result->count) {
$message->set_safe(true);
break;
}
}
}

Loading…
Cancel
Save