]> git.mxchange.org Git - friendica.git/blob - src/Object/EMail/ItemCCEMail.php
Merge pull request #9397 from vinzv/9238-red-color-unread-messages-faded
[friendica.git] / src / Object / EMail / ItemCCEMail.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Object\EMail;
23
24 use Friendica\App;
25 use Friendica\App\BaseURL;
26 use Friendica\Content\Text\HTML;
27 use Friendica\Core\L10n;
28 use Friendica\Model\Item;
29 use Friendica\Object\Email;
30 use Friendica\Protocol\Email as EmailProtocol;
31
32 /**
33  * Class for creating CC emails based on a received item
34  */
35 class ItemCCEMail extends Email
36 {
37         public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
38         {
39                 $disclaimer = '<hr />' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $a->user['username'])
40                               . '<br />';
41                 $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->user['nickname']) . EOL;
42                 $disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
43                 if (!$item['title'] == '') {
44                         $subject = EmailProtocol::encodeHeader($item['title'], 'UTF-8');
45                 } else {
46                         $subject = EmailProtocol::encodeHeader('[Friendica]' . ' ' . $l10n->t('%s posted an update.', $a->user['username']), 'UTF-8');
47                 }
48                 $link    = '<a href="' . $baseUrl . '/profile/' . $a->user['nickname'] . '"><img src="' . $authorThumb . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
49                 $html    = Item::prepareBody($item);
50                 $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';;
51
52                 parent::__construct($a->user['username'], $a->user['email'], $a->user['email'], $toAddress,
53                         $subject, $message, HTML::toPlaintext($html . $disclaimer));
54         }
55 }