]> git.mxchange.org Git - friendica.git/blob - src/Object/EMail/ItemCCEMail.php
Continued:
[friendica.git] / src / Object / EMail / ItemCCEMail.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
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\Model\User;
30 use Friendica\Object\Email;
31 use Friendica\Protocol\Email as EmailProtocol;
32
33 /**
34  * Class for creating CC emails based on a received item
35  */
36 class ItemCCEMail extends Email
37 {
38         public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
39         {
40                 $user = User::getById($a->getLoggedInUserId());
41
42                 $disclaimer = '<hr />' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $user['username'])
43                               . '<br />';
44                 $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->getLoggedInUserNickname()) . '<br />';
45                 $disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . '<br />';
46                 if (!$item['title'] == '') {
47                         $subject = $item['title'];
48                 } else {
49                         $subject = '[Friendica]' . ' ' . $l10n->t('%s posted an update.', $user['username']);
50                 }
51                 $link    = '<a href="' . $baseUrl . '/profile/' . $a->getLoggedInUserNickname() . '"><img src="' . $authorThumb . '" alt="' . $user['username'] . '" /></a><br /><br />';
52                 $html    = Item::prepareBody($item);
53                 $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';;
54
55                 parent::__construct($user['username'], $user['email'], $user['email'], $toAddress,
56                         $subject, $message, HTML::toPlaintext($html . $disclaimer));
57         }
58 }