__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* @package DPCalendar
* @copyright Copyright (C) 2021 Digital Peak GmbH. <https://www.digital-peak.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
namespace DigitalPeak\Component\DPCalendar\Administrator\Booking\Stages;
defined('_JEXEC') or die();
use DigitalPeak\Component\DPCalendar\Administrator\Helper\DPCalendarHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Mail\Exception\MailDisabledException;
use Joomla\CMS\Mail\Mail;
use Joomla\CMS\Mail\MailerInterface;
use League\Pipeline\StageInterface;
class SendInviteMail implements StageInterface
{
public function __construct(private readonly MailerInterface $mailer)
{
}
public function __invoke($payload)
{
// Never send a mail when we have been invited before
if ($payload->oldItem && $payload->oldItem->state == 5) {
return $payload;
}
// Never send a mail when not invited state
if ($payload->item->state != 5) {
return $payload;
}
// Send a mail to the booker
$subject = DPCalendarHelper::renderEvents(
$payload->eventsWithTickets,
$payload->language->_('COM_DPCALENDAR_NOTIFICATION_EVENT_BOOK_USER_INVITE_SUBJECT'),
null,
$payload->mailVariables
);
$body = trim(
DPCalendarHelper::renderEvents(
$payload->eventsWithTickets,
$payload->language->_('COM_DPCALENDAR_NOTIFICATION_EVENT_BOOK_USER_INVITE_BODY'),
null,
$payload->mailVariables
)
);
if ($body !== '' && $body !== '0') {
$this->mailer->setSubject($subject);
$this->mailer->setBody($body);
$this->mailer->addRecipient($payload->item->email);
if ($this->mailer instanceof Mail) {
$this->mailer->IsHTML(true);
}
$files = [];
if ($payload->mailParams->get('booking_include_ics', 1)) {
$icsFile = JPATH_ROOT . '/tmp/' . $payload->item->uid . '.ics';
$content = Factory::getApplication()->bootComponent('dpcalendar')->getMVCFactory()->createModel('Ical', 'Administrator')->createIcalFromEvents($payload->eventsWithTickets, false, true);
$result = file_put_contents($icsFile, $content);
if (!$content || $result === 0 || $result === false) {
$icsFile = null;
} else {
$this->mailer->addAttachment($icsFile);
$files[] = $icsFile;
}
}
try {
$this->mailer->Send();
foreach ($files as $file) {
unlink($file);
}
} catch (\Exception $e) {
foreach ($files as $file) {
unlink($file);
}
if (!$e instanceof MailDisabledException) {
throw $e;
}
}
}
return $payload;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AdjustCustomFields.php | File | 1023 B | 0664 |
|
| AssignUserGroups.php | File | 1.15 KB | 0664 |
|
| CollectEventsAndTickets.php | File | 2.68 KB | 0664 |
|
| CreateOrUpdateTickets.php | File | 3.7 KB | 0664 |
|
| CreateUser.php | File | 2.13 KB | 0664 |
|
| FetchLocationData.php | File | 1.41 KB | 0664 |
|
| SendInviteMail.php | File | 2.45 KB | 0664 |
|
| SendNewBookingMail.php | File | 4.67 KB | 0664 |
|
| SendNotificationMail.php | File | 3.33 KB | 0664 |
|
| SendPaidBookingMail.php | File | 3.31 KB | 0664 |
|
| SendWaitingListMail.php | File | 3.03 KB | 0664 |
|
| SetupForMail.php | File | 3.17 KB | 0664 |
|
| SetupForNew.php | File | 11.61 KB | 0664 |
|
| SetupForUpdate.php | File | 1.82 KB | 0664 |
|
| SetupLanguage.php | File | 1.45 KB | 0664 |
|