2020-01-26 20:23:58 +01:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2020-01-26 20:23:58 +01:00
|
|
|
|
|
|
|
namespace Friendica\Object\EMail;
|
|
|
|
|
|
|
|
use Friendica\App;
|
|
|
|
use Friendica\App\BaseURL;
|
|
|
|
use Friendica\Content\Text\HTML;
|
|
|
|
use Friendica\Core\L10n;
|
|
|
|
use Friendica\Model\Item;
|
2020-01-26 23:47:16 +01:00
|
|
|
use Friendica\Object\Email;
|
2020-02-01 20:11:09 +01:00
|
|
|
use Friendica\Protocol\Email as EmailProtocol;
|
2020-01-26 20:23:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for creating CC emails based on a received item
|
|
|
|
*/
|
2020-01-26 23:47:16 +01:00
|
|
|
class ItemCCEMail extends Email
|
2020-01-26 20:23:58 +01:00
|
|
|
{
|
2020-01-27 00:01:17 +01:00
|
|
|
public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
|
2020-01-26 20:23:58 +01:00
|
|
|
{
|
|
|
|
$disclaimer = '<hr />' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $a->user['username'])
|
|
|
|
. '<br />';
|
|
|
|
$disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->user['nickname']) . EOL;
|
|
|
|
$disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
|
|
|
|
if (!$item['title'] == '') {
|
2020-02-01 20:11:09 +01:00
|
|
|
$subject = EmailProtocol::encodeHeader($item['title'], 'UTF-8');
|
2020-01-26 20:23:58 +01:00
|
|
|
} else {
|
2020-02-01 20:11:09 +01:00
|
|
|
$subject = EmailProtocol::encodeHeader('[Friendica]' . ' ' . $l10n->t('%s posted an update.', $a->user['username']), 'UTF-8');
|
2020-01-26 20:23:58 +01:00
|
|
|
}
|
|
|
|
$link = '<a href="' . $baseUrl . '/profile/' . $a->user['nickname'] . '"><img src="' . $authorThumb . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
|
|
|
|
$html = Item::prepareBody($item);
|
|
|
|
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';;
|
|
|
|
|
2020-01-27 00:01:17 +01:00
|
|
|
parent::__construct($a->user['username'], $a->user['email'], $a->user['email'], $toAddress,
|
2020-01-26 20:23:58 +01:00
|
|
|
$subject, $message, HTML::toPlaintext($html . $disclaimer));
|
|
|
|
}
|
|
|
|
}
|