]> git.mxchange.org Git - friendica.git/commitdiff
Add extra email banner (including setting)
authornupplaPhil <admin+github@philipp.info>
Sun, 2 Feb 2020 21:40:30 +0000 (22:40 +0100)
committernupplaPhil <admin+github@philipp.info>
Sun, 2 Feb 2020 21:43:44 +0000 (22:43 +0100)
src/Module/Admin/Site.php
src/Util/EMailer/MailBuilder.php
view/templates/admin/site.tpl
view/templates/email/html.tpl

index 7cb3a9b8f7f07443d2d4c1cd3cde855eaf726d27..50a9c9d22e1bb41bec17e48835814a49762c7925 100644 (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())],
index 389874efde37630f1024e74ced969ca61a7e3408..2f8c199a50946528644371bc623130d1ab68b0a6 100644 (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),
                        ]);
                }
 
index 19774b42553cd07ab800e1dfe0b19369d15999c6..9ccda33eeb34bf54e1ccbd31f3ef40c133b31587 100644 (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}}
index 65af182c5578ba000e7af0c6438514b4baa153f3..94e7271b9088cc15b17bbcc6627c5fa91ea50fe5 100644 (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>