Add extra email banner (including setting)

This commit is contained in:
nupplaPhil 2020-02-02 22:40:30 +01:00
parent 262c94f12f
commit 7fb913eb86
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
4 changed files with 24 additions and 4 deletions

View file

@ -13,6 +13,7 @@ use Friendica\Module\BaseAdmin;
use Friendica\Module\Register;
use Friendica\Protocol\PortableContact;
use Friendica\Util\BasePath;
use Friendica\Util\EMailer\MailBuilder;
use Friendica\Util\Strings;
use Friendica\Worker\Delivery;
@ -110,6 +111,7 @@ class Site extends BaseAdmin
$sitename = (!empty($_POST['sitename']) ? Strings::escapeTags(trim($_POST['sitename'])) : '');
$sender_email = (!empty($_POST['sender_email']) ? Strings::escapeTags(trim($_POST['sender_email'])) : '');
$banner = (!empty($_POST['banner']) ? trim($_POST['banner']) : false);
$email_banner = (!empty($_POST['email_banner']) ? trim($_POST['email_banner']) : false);
$shortcut_icon = (!empty($_POST['shortcut_icon']) ? Strings::escapeTags(trim($_POST['shortcut_icon'])) : '');
$touch_icon = (!empty($_POST['touch_icon']) ? Strings::escapeTags(trim($_POST['touch_icon'])) : '');
$additional_info = (!empty($_POST['additional_info']) ? trim($_POST['additional_info']) : '');
@ -301,6 +303,12 @@ class Site extends BaseAdmin
DI::config()->set('system', 'banner', $banner);
}
if (empty($email_banner)) {
DI::config()->delete('system', 'email_banner');
} else {
DI::config()->set('system', 'email_banner', $email_banner);
}
if (empty($additional_info)) {
DI::config()->delete('config', 'info');
} else {
@ -489,6 +497,12 @@ class Site extends BaseAdmin
$banner = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
}
$email_banner = DI::config()->get('system', 'email_banner');
if ($email_banner == false) {
$email_banner = MailBuilder::DEFAULT_EMAIL_BANNER;
}
$additional_info = DI::config()->get('config', 'info');
// Automatically create temporary paths
@ -571,6 +585,7 @@ class Site extends BaseAdmin
'$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), ''],
'$sender_email' => ['sender_email', DI::l10n()->t('Sender Email'), DI::config()->get('config', 'sender_email'), DI::l10n()->t('The email address your server shall use to send notification emails from.'), '', '', 'email'],
'$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''],
'$email_banner' => ['email_banner', DI::l10n()->t('Email Banner/Logo'), $email_banner, ''],
'$shortcut_icon' => ['shortcut_icon', DI::l10n()->t('Shortcut icon'), DI::config()->get('system', 'shortcut_icon'), DI::l10n()->t('Link to an icon that will be used for browsers.')],
'$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')],
'$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())],

View file

@ -17,6 +17,9 @@ use Friendica\Object\EMail\IEmail;
*/
abstract class MailBuilder
{
/** @var string The default email banner in case nothing else is defined */
const DEFAULT_EMAIL_BANNER = 'images/friendica-32.png';
/** @var L10n */
protected $l10n;
/** @var IConfig */
@ -163,11 +166,12 @@ abstract class MailBuilder
// load the template for private message notifications
$tpl = Renderer::getMarkupTemplate('email/html.tpl');
$msgHtml = Renderer::replaceMacros($tpl, [
'$banner' => $this->l10n->t('Friendica Notification'),
'$title' => $this->l10n->t('Friendica Notification'),
'$product' => FRIENDICA_PLATFORM,
'$htmlversion' => $msgHtml,
'$sitename' => $this->config->get('config', 'sitename'),
'$siteurl' => $this->baseUrl->get(true),
'$banner' => $this->config->get('system', 'email_banner',
$this->baseUrl->get(true) . DIRECTORY_SEPARATOR . self::DEFAULT_EMAIL_BANNER),
]);
}

View file

@ -15,6 +15,7 @@
{{include file="field_input.tpl" field=$sitename}}
{{include file="field_input.tpl" field=$sender_email}}
{{include file="field_textarea.tpl" field=$banner}}
{{include file="field_input.tpl" field=$email_banner}}
{{include file="field_input.tpl" field=$shortcut_icon}}
{{include file="field_input.tpl" field=$touch_icon}}
{{include file="field_textarea.tpl" field=$additional_info}}

View file

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional //EN">
<html>
<head>
<title>{{$banner}}</title>
<title>{{$title}}</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
@ -9,7 +9,7 @@
<tbody>
<tr>
<td colspan="2" style="background:#084769; color:#FFFFFF; font-weight:bold; font-family:'lucida grande', tahoma, verdana,arial, sans-serif; padding: 4px 8px; vertical-align: middle; font-size:16px; letter-spacing: -0.03em; text-align: left;">
<img style="width:32px;height:32px; float:left;" src='{{$siteurl}}/images/friendica-32.png'>
<img style="width:32px;height:32px; float:left;" src='{{$banner}}'>
<div style="padding:7px; margin-left: 5px; float:left; font-size:18px;letter-spacing:1px;">{{$product}}</div>
<div style="clear: both;"></div>
</td>