2015-12-18 13:56:25 +03:00
|
|
|
<?php
|
2016-01-12 17:02:16 +03:00
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2017-06-08 12:50:17 +03:00
|
|
|
* @copyright Copyright (c) 2017, Georg Ehrke
|
2016-07-21 17:49:16 +03:00
|
|
|
*
|
2020-09-07 15:37:44 +03:00
|
|
|
* @author brad2014 <brad2014@users.noreply.github.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Brad Rubenstein <brad@wbr.tech>
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2017-11-06 22:15:27 +03:00
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author Leon Klingele <leon@struktur.de>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author rakekniven <mark.ziegler@rakekniven.de>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Thomas Citharel <nextcloud@tcit.fr>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-01-12 17:02:16 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2015-12-18 13:56:25 +03:00
|
|
|
namespace OCA\DAV\CalDAV\Schedule;
|
|
|
|
|
2017-06-08 12:50:17 +03:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
2017-11-14 17:01:53 +03:00
|
|
|
use OCP\Defaults;
|
2017-09-07 17:33:45 +03:00
|
|
|
use OCP\IConfig;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCP\IDBConnection;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\IL10N;
|
2015-12-18 13:56:25 +03:00
|
|
|
use OCP\ILogger;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\IURLGenerator;
|
2019-11-27 13:54:42 +03:00
|
|
|
use OCP\IUserManager;
|
2017-09-07 17:33:45 +03:00
|
|
|
use OCP\L10N\IFactory as L10NFactory;
|
2017-11-02 18:38:16 +03:00
|
|
|
use OCP\Mail\IEMailTemplate;
|
2015-12-18 13:56:25 +03:00
|
|
|
use OCP\Mail\IMailer;
|
2018-06-19 22:01:14 +03:00
|
|
|
use OCP\Security\ISecureRandom;
|
2020-03-26 20:32:09 +03:00
|
|
|
use OCP\Util;
|
2017-09-07 17:33:45 +03:00
|
|
|
use Sabre\CalDAV\Schedule\IMipPlugin as SabreIMipPlugin;
|
2017-06-08 12:50:17 +03:00
|
|
|
use Sabre\VObject\Component\VCalendar;
|
2017-10-31 17:05:26 +03:00
|
|
|
use Sabre\VObject\Component\VEvent;
|
2017-06-08 12:50:17 +03:00
|
|
|
use Sabre\VObject\DateTimeParser;
|
2017-10-31 17:05:26 +03:00
|
|
|
use Sabre\VObject\ITip\Message;
|
2017-09-07 17:33:45 +03:00
|
|
|
use Sabre\VObject\Parameter;
|
2017-10-31 17:05:26 +03:00
|
|
|
use Sabre\VObject\Property;
|
2017-06-08 12:50:17 +03:00
|
|
|
use Sabre\VObject\Recur\EventIterator;
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2015-12-18 13:56:25 +03:00
|
|
|
/**
|
|
|
|
* iMIP handler.
|
|
|
|
*
|
|
|
|
* This class is responsible for sending out iMIP messages. iMIP is the
|
|
|
|
* email-based transport for iTIP. iTIP deals with scheduling operations for
|
|
|
|
* iCalendar objects.
|
|
|
|
*
|
|
|
|
* If you want to customize the email that gets sent out, you can do so by
|
|
|
|
* extending this class and overriding the sendMessage method.
|
|
|
|
*
|
|
|
|
* @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
|
|
|
|
* @author Evert Pot (http://evertpot.com/)
|
|
|
|
* @license http://sabre.io/license/ Modified BSD License
|
|
|
|
*/
|
|
|
|
class IMipPlugin extends SabreIMipPlugin {
|
|
|
|
|
2017-09-07 17:33:45 +03:00
|
|
|
/** @var string */
|
|
|
|
private $userId;
|
|
|
|
|
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
|
|
|
|
2015-12-18 13:56:25 +03:00
|
|
|
/** @var IMailer */
|
|
|
|
private $mailer;
|
|
|
|
|
|
|
|
/** @var ILogger */
|
|
|
|
private $logger;
|
|
|
|
|
2017-06-08 12:50:17 +03:00
|
|
|
/** @var ITimeFactory */
|
|
|
|
private $timeFactory;
|
|
|
|
|
2017-09-07 17:33:45 +03:00
|
|
|
/** @var L10NFactory */
|
|
|
|
private $l10nFactory;
|
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
/** @var IURLGenerator */
|
|
|
|
private $urlGenerator;
|
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
/** @var ISecureRandom */
|
|
|
|
private $random;
|
|
|
|
|
|
|
|
/** @var IDBConnection */
|
|
|
|
private $db;
|
|
|
|
|
2017-11-14 17:01:53 +03:00
|
|
|
/** @var Defaults */
|
|
|
|
private $defaults;
|
|
|
|
|
2019-11-27 13:54:42 +03:00
|
|
|
/** @var IUserManager */
|
|
|
|
private $userManager;
|
|
|
|
|
2020-04-10 17:54:27 +03:00
|
|
|
public const MAX_DATE = '2038-01-01';
|
2017-06-08 12:50:17 +03:00
|
|
|
|
2020-04-10 17:54:27 +03:00
|
|
|
public const METHOD_REQUEST = 'request';
|
|
|
|
public const METHOD_REPLY = 'reply';
|
|
|
|
public const METHOD_CANCEL = 'cancel';
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
public const IMIP_INDENT = 15; // Enough for the length of all body bullet items, in all languages
|
2017-09-07 17:33:45 +03:00
|
|
|
|
2015-12-18 13:56:25 +03:00
|
|
|
/**
|
2017-09-07 17:33:45 +03:00
|
|
|
* @param IConfig $config
|
2015-12-18 13:56:25 +03:00
|
|
|
* @param IMailer $mailer
|
2017-06-08 12:50:17 +03:00
|
|
|
* @param ILogger $logger
|
|
|
|
* @param ITimeFactory $timeFactory
|
2017-09-07 17:33:45 +03:00
|
|
|
* @param L10NFactory $l10nFactory
|
2017-11-02 18:38:16 +03:00
|
|
|
* @param IUrlGenerator $urlGenerator
|
2017-11-14 17:01:53 +03:00
|
|
|
* @param Defaults $defaults
|
2018-06-19 22:01:14 +03:00
|
|
|
* @param ISecureRandom $random
|
|
|
|
* @param IDBConnection $db
|
2017-10-31 17:05:26 +03:00
|
|
|
* @param string $userId
|
2015-12-18 13:56:25 +03:00
|
|
|
*/
|
2018-06-19 22:01:14 +03:00
|
|
|
public function __construct(IConfig $config, IMailer $mailer, ILogger $logger,
|
|
|
|
ITimeFactory $timeFactory, L10NFactory $l10nFactory,
|
|
|
|
IURLGenerator $urlGenerator, Defaults $defaults,
|
2019-11-27 13:54:42 +03:00
|
|
|
ISecureRandom $random, IDBConnection $db, IUserManager $userManager,
|
|
|
|
$userId) {
|
2015-12-18 13:56:25 +03:00
|
|
|
parent::__construct('');
|
2017-09-07 17:33:45 +03:00
|
|
|
$this->userId = $userId;
|
|
|
|
$this->config = $config;
|
2015-12-18 13:56:25 +03:00
|
|
|
$this->mailer = $mailer;
|
|
|
|
$this->logger = $logger;
|
2017-06-08 12:50:17 +03:00
|
|
|
$this->timeFactory = $timeFactory;
|
2017-09-07 17:33:45 +03:00
|
|
|
$this->l10nFactory = $l10nFactory;
|
2017-11-02 18:38:16 +03:00
|
|
|
$this->urlGenerator = $urlGenerator;
|
2018-06-19 22:01:14 +03:00
|
|
|
$this->random = $random;
|
|
|
|
$this->db = $db;
|
2017-11-14 17:01:53 +03:00
|
|
|
$this->defaults = $defaults;
|
2019-11-27 13:54:42 +03:00
|
|
|
$this->userManager = $userManager;
|
2015-12-18 13:56:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for the 'schedule' event.
|
|
|
|
*
|
2017-10-31 17:05:26 +03:00
|
|
|
* @param Message $iTipMessage
|
2015-12-18 13:56:25 +03:00
|
|
|
* @return void
|
|
|
|
*/
|
2017-10-31 17:05:26 +03:00
|
|
|
public function schedule(Message $iTipMessage) {
|
2015-12-18 13:56:25 +03:00
|
|
|
|
|
|
|
// Not sending any emails if the system considers the update
|
|
|
|
// insignificant.
|
|
|
|
if (!$iTipMessage->significantChange) {
|
|
|
|
if (!$iTipMessage->scheduleStatus) {
|
|
|
|
$iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email';
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$summary = $iTipMessage->message->VEVENT->SUMMARY;
|
|
|
|
|
2018-11-12 23:59:12 +03:00
|
|
|
if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') {
|
2015-12-18 13:56:25 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-12 23:59:12 +03:00
|
|
|
if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto') {
|
2015-12-18 13:56:25 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-08 12:50:17 +03:00
|
|
|
// don't send out mails for events that already took place
|
2018-06-19 22:01:14 +03:00
|
|
|
$lastOccurrence = $this->getLastOccurrence($iTipMessage->message);
|
|
|
|
$currentTime = $this->timeFactory->getTime();
|
|
|
|
if ($lastOccurrence < $currentTime) {
|
2017-06-08 12:50:17 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-31 17:05:26 +03:00
|
|
|
// Strip off mailto:
|
2015-12-18 13:56:25 +03:00
|
|
|
$sender = substr($iTipMessage->sender, 7);
|
|
|
|
$recipient = substr($iTipMessage->recipient, 7);
|
|
|
|
|
2017-10-31 17:05:26 +03:00
|
|
|
$senderName = $iTipMessage->senderName ?: null;
|
|
|
|
$recipientName = $iTipMessage->recipientName ?: null;
|
2015-12-18 13:56:25 +03:00
|
|
|
|
2019-11-27 13:54:42 +03:00
|
|
|
if ($senderName === null || empty(trim($senderName))) {
|
|
|
|
$user = $this->userManager->get($this->userId);
|
|
|
|
if ($user) {
|
|
|
|
// getDisplayName automatically uses the uid
|
|
|
|
// if no display-name is set
|
|
|
|
$senderName = $user->getDisplayName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-31 17:05:26 +03:00
|
|
|
/** @var VEvent $vevent */
|
2017-09-07 17:33:45 +03:00
|
|
|
$vevent = $iTipMessage->message->VEVENT;
|
|
|
|
|
|
|
|
$attendee = $this->getCurrentAttendee($iTipMessage);
|
2018-10-24 19:39:30 +03:00
|
|
|
$defaultLang = $this->l10nFactory->findLanguage();
|
2017-10-31 17:05:26 +03:00
|
|
|
$lang = $this->getAttendeeLangOrDefault($defaultLang, $attendee);
|
|
|
|
$l10n = $this->l10nFactory->get('dav', $lang);
|
2017-09-07 17:33:45 +03:00
|
|
|
|
2017-10-31 17:05:26 +03:00
|
|
|
$meetingAttendeeName = $recipientName ?: $recipient;
|
|
|
|
$meetingInviteeName = $senderName ?: $sender;
|
2015-12-18 13:56:25 +03:00
|
|
|
|
2017-09-07 17:33:45 +03:00
|
|
|
$meetingTitle = $vevent->SUMMARY;
|
|
|
|
$meetingDescription = $vevent->DESCRIPTION;
|
2015-12-18 13:56:25 +03:00
|
|
|
|
2017-09-07 17:33:45 +03:00
|
|
|
|
|
|
|
$meetingUrl = $vevent->URL;
|
2017-11-02 18:38:16 +03:00
|
|
|
$meetingLocation = $vevent->LOCATION;
|
2017-09-07 17:33:45 +03:00
|
|
|
|
|
|
|
$defaultVal = '--';
|
2017-10-31 17:47:51 +03:00
|
|
|
|
|
|
|
$method = self::METHOD_REQUEST;
|
|
|
|
switch (strtolower($iTipMessage->method)) {
|
|
|
|
case self::METHOD_REPLY:
|
|
|
|
$method = self::METHOD_REPLY;
|
|
|
|
break;
|
|
|
|
case self::METHOD_CANCEL:
|
|
|
|
$method = self::METHOD_CANCEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-03-26 11:30:18 +03:00
|
|
|
$data = [
|
2017-09-07 17:33:45 +03:00
|
|
|
'attendee_name' => (string)$meetingAttendeeName ?: $defaultVal,
|
|
|
|
'invitee_name' => (string)$meetingInviteeName ?: $defaultVal,
|
|
|
|
'meeting_title' => (string)$meetingTitle ?: $defaultVal,
|
|
|
|
'meeting_description' => (string)$meetingDescription ?: $defaultVal,
|
|
|
|
'meeting_url' => (string)$meetingUrl ?: $defaultVal,
|
2020-03-26 11:30:18 +03:00
|
|
|
];
|
2017-09-07 17:33:45 +03:00
|
|
|
|
2020-03-26 20:32:09 +03:00
|
|
|
$fromEMail = Util::getDefaultEmailAddress('invitations-noreply');
|
2018-10-09 15:32:14 +03:00
|
|
|
$fromName = $l10n->t('%1$s via %2$s', [$senderName, $this->defaults->getName()]);
|
2017-11-14 17:01:53 +03:00
|
|
|
|
2017-09-07 17:33:45 +03:00
|
|
|
$message = $this->mailer->createMessage()
|
2017-11-14 17:01:53 +03:00
|
|
|
->setFrom([$fromEMail => $fromName])
|
2017-09-07 17:33:45 +03:00
|
|
|
->setReplyTo([$sender => $senderName])
|
2017-11-02 18:38:16 +03:00
|
|
|
->setTo([$recipient => $recipientName]);
|
2017-10-31 17:47:51 +03:00
|
|
|
|
|
|
|
$template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data);
|
|
|
|
$template->addHeader();
|
|
|
|
|
2020-03-26 20:32:09 +03:00
|
|
|
$summary = ((string) $summary !== '') ? (string) $summary : $l10n->t('Untitled event');
|
|
|
|
|
2020-09-02 18:16:24 +03:00
|
|
|
$this->addSubjectAndHeading($template, $l10n, $method, $summary);
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$this->addBulletList($template, $l10n, $vevent);
|
2018-11-10 13:35:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
// Only add response buttons to invitation requests: Fix Issue #11230
|
2018-11-12 23:11:47 +03:00
|
|
|
if (($method == self::METHOD_REQUEST) && $this->getAttendeeRSVP($attendee)) {
|
2018-11-10 13:35:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Only offer invitation accept/reject buttons, which link back to the
|
|
|
|
** nextcloud server, to recipients who can access the nextcloud server via
|
|
|
|
** their internet/intranet. Issue #12156
|
|
|
|
**
|
2019-07-18 02:47:15 +03:00
|
|
|
** The app setting is stored in the appconfig database table.
|
|
|
|
**
|
2018-11-10 13:35:42 +03:00
|
|
|
** For nextcloud servers accessible to the public internet, the default
|
2019-07-18 02:47:15 +03:00
|
|
|
** "invitation_link_recipients" value "yes" (all recipients) is appropriate.
|
2018-11-10 13:35:42 +03:00
|
|
|
**
|
|
|
|
** When the nextcloud server is restricted behind a firewall, accessible
|
|
|
|
** only via an internal network or via vpn, you can set "dav.invitation_link_recipients"
|
2019-07-18 02:47:15 +03:00
|
|
|
** to the email address or email domain, or comma separated list of addresses or domains,
|
2018-11-10 13:35:42 +03:00
|
|
|
** of recipients who can access the server.
|
|
|
|
**
|
2019-07-18 02:47:15 +03:00
|
|
|
** To always deliver URLs, set invitation_link_recipients to "yes".
|
|
|
|
** To suppress URLs entirely, set invitation_link_recipients to boolean "no".
|
2018-11-10 13:35:42 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
$recipientDomain = substr(strrchr($recipient, "@"), 1);
|
2019-07-18 02:47:15 +03:00
|
|
|
$invitationLinkRecipients = explode(',', preg_replace('/\s+/', '', strtolower($this->config->getAppValue('dav', 'invitation_link_recipients', 'yes'))));
|
|
|
|
|
|
|
|
if (strcmp('yes', $invitationLinkRecipients[0]) === 0
|
|
|
|
|| in_array(strtolower($recipient), $invitationLinkRecipients)
|
|
|
|
|| in_array(strtolower($recipientDomain), $invitationLinkRecipients)) {
|
2018-11-10 13:35:42 +03:00
|
|
|
$this->addResponseButtons($template, $l10n, $iTipMessage, $lastOccurrence);
|
|
|
|
}
|
|
|
|
}
|
2017-10-31 17:47:51 +03:00
|
|
|
|
|
|
|
$template->addFooter();
|
2018-11-10 13:35:42 +03:00
|
|
|
|
2017-10-31 17:47:51 +03:00
|
|
|
$message->useTemplate($template);
|
|
|
|
|
|
|
|
$attachment = $this->mailer->createAttachment(
|
|
|
|
$iTipMessage->message->serialize(),
|
|
|
|
'event.ics',// TODO(leon): Make file name unique, e.g. add event id
|
|
|
|
'text/calendar; method=' . $iTipMessage->method
|
|
|
|
);
|
|
|
|
$message->attach($attachment);
|
2017-09-07 17:33:45 +03:00
|
|
|
|
2015-12-18 13:56:25 +03:00
|
|
|
try {
|
|
|
|
$failed = $this->mailer->send($message);
|
2017-10-31 17:05:26 +03:00
|
|
|
$iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip';
|
2015-12-18 13:56:25 +03:00
|
|
|
if ($failed) {
|
2020-10-05 16:12:57 +03:00
|
|
|
$this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]);
|
2015-12-18 13:56:25 +03:00
|
|
|
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
|
|
|
|
}
|
2020-04-10 15:19:56 +03:00
|
|
|
} catch (\Exception $ex) {
|
2015-12-18 13:56:25 +03:00
|
|
|
$this->logger->logException($ex, ['app' => 'dav']);
|
|
|
|
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 12:50:17 +03:00
|
|
|
/**
|
|
|
|
* check if event took place in the past already
|
|
|
|
* @param VCalendar $vObject
|
2018-06-19 22:01:14 +03:00
|
|
|
* @return int
|
2017-06-08 12:50:17 +03:00
|
|
|
*/
|
2018-06-19 22:01:14 +03:00
|
|
|
private function getLastOccurrence(VCalendar $vObject) {
|
2017-10-31 17:05:26 +03:00
|
|
|
/** @var VEvent $component */
|
2017-06-08 12:50:17 +03:00
|
|
|
$component = $vObject->VEVENT;
|
|
|
|
|
|
|
|
$firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp();
|
|
|
|
// Finding the last occurrence is a bit harder
|
|
|
|
if (!isset($component->RRULE)) {
|
|
|
|
if (isset($component->DTEND)) {
|
|
|
|
$lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp();
|
|
|
|
} elseif (isset($component->DURATION)) {
|
2017-10-31 17:05:26 +03:00
|
|
|
/** @var \DateTime $endDate */
|
2017-06-08 12:50:17 +03:00
|
|
|
$endDate = clone $component->DTSTART->getDateTime();
|
2017-06-09 13:13:02 +03:00
|
|
|
// $component->DTEND->getDateTime() returns DateTimeImmutable
|
|
|
|
$endDate = $endDate->add(DateTimeParser::parse($component->DURATION->getValue()));
|
2017-10-31 17:05:26 +03:00
|
|
|
$lastOccurrence = $endDate->getTimestamp();
|
2017-06-08 12:50:17 +03:00
|
|
|
} elseif (!$component->DTSTART->hasTime()) {
|
2017-10-31 17:05:26 +03:00
|
|
|
/** @var \DateTime $endDate */
|
2017-06-08 12:50:17 +03:00
|
|
|
$endDate = clone $component->DTSTART->getDateTime();
|
2017-06-09 13:13:02 +03:00
|
|
|
// $component->DTSTART->getDateTime() returns DateTimeImmutable
|
|
|
|
$endDate = $endDate->modify('+1 day');
|
2017-10-31 17:05:26 +03:00
|
|
|
$lastOccurrence = $endDate->getTimestamp();
|
2017-06-08 12:50:17 +03:00
|
|
|
} else {
|
|
|
|
$lastOccurrence = $firstOccurrence;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$it = new EventIterator($vObject, (string)$component->UID);
|
|
|
|
$maxDate = new \DateTime(self::MAX_DATE);
|
|
|
|
if ($it->isInfinite()) {
|
|
|
|
$lastOccurrence = $maxDate->getTimestamp();
|
|
|
|
} else {
|
|
|
|
$end = $it->getDtEnd();
|
2020-04-10 15:19:56 +03:00
|
|
|
while ($it->valid() && $end < $maxDate) {
|
2017-06-08 12:50:17 +03:00
|
|
|
$end = $it->getDtEnd();
|
|
|
|
$it->next();
|
|
|
|
}
|
|
|
|
$lastOccurrence = $end->getTimestamp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
return $lastOccurrence;
|
2017-06-08 12:50:17 +03:00
|
|
|
}
|
2017-09-07 17:33:45 +03:00
|
|
|
|
2017-10-31 17:05:26 +03:00
|
|
|
/**
|
|
|
|
* @param Message $iTipMessage
|
|
|
|
* @return null|Property
|
|
|
|
*/
|
|
|
|
private function getCurrentAttendee(Message $iTipMessage) {
|
|
|
|
/** @var VEvent $vevent */
|
2017-09-07 17:33:45 +03:00
|
|
|
$vevent = $iTipMessage->message->VEVENT;
|
|
|
|
$attendees = $vevent->select('ATTENDEE');
|
|
|
|
foreach ($attendees as $attendee) {
|
2017-10-31 17:05:26 +03:00
|
|
|
/** @var Property $attendee */
|
2017-09-07 17:33:45 +03:00
|
|
|
if (strcasecmp($attendee->getValue(), $iTipMessage->recipient) === 0) {
|
|
|
|
return $attendee;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-10-31 17:05:26 +03:00
|
|
|
/**
|
|
|
|
* @param string $default
|
|
|
|
* @param Property|null $attendee
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getAttendeeLangOrDefault($default, Property $attendee = null) {
|
|
|
|
if ($attendee !== null) {
|
2017-09-07 17:33:45 +03:00
|
|
|
$lang = $attendee->offsetGet('LANGUAGE');
|
|
|
|
if ($lang instanceof Parameter) {
|
|
|
|
return $lang->getValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
|
2018-11-12 23:11:47 +03:00
|
|
|
/**
|
|
|
|
* @param Property|null $attendee
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function getAttendeeRSVP(Property $attendee = null) {
|
|
|
|
if ($attendee !== null) {
|
|
|
|
$rsvp = $attendee->offsetGet('RSVP');
|
|
|
|
if (($rsvp instanceof Parameter) && (strcasecmp($rsvp->getValue(), 'TRUE') === 0)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// RFC 5545 3.2.17: default RSVP is false
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
/**
|
|
|
|
* @param IL10N $l10n
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
* @param VEvent $vevent
|
2017-11-02 18:38:16 +03:00
|
|
|
*/
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
private function generateWhenString(IL10N $l10n, VEvent $vevent) {
|
|
|
|
$dtstart = $vevent->DTSTART;
|
|
|
|
if (isset($vevent->DTEND)) {
|
|
|
|
$dtend = $vevent->DTEND;
|
|
|
|
} elseif (isset($vevent->DURATION)) {
|
|
|
|
$isFloating = $vevent->DTSTART->isFloating();
|
|
|
|
$dtend = clone $vevent->DTSTART;
|
2020-09-02 18:16:24 +03:00
|
|
|
$endDateTime = $dtend->getDateTime();
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$endDateTime = $endDateTime->add(DateTimeParser::parse($vevent->DURATION->getValue()));
|
|
|
|
$dtend->setDateTime($endDateTime, $isFloating);
|
|
|
|
} elseif (!$vevent->DTSTART->hasTime()) {
|
|
|
|
$isFloating = $vevent->DTSTART->isFloating();
|
|
|
|
$dtend = clone $vevent->DTSTART;
|
2020-09-02 18:16:24 +03:00
|
|
|
$endDateTime = $dtend->getDateTime();
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$endDateTime = $endDateTime->modify('+1 day');
|
|
|
|
$dtend->setDateTime($endDateTime, $isFloating);
|
|
|
|
} else {
|
|
|
|
$dtend = clone $vevent->DTSTART;
|
|
|
|
}
|
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
$isAllDay = $dtstart instanceof Property\ICalendar\Date;
|
|
|
|
|
|
|
|
/** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtstart */
|
|
|
|
/** @var Property\ICalendar\Date | Property\ICalendar\DateTime $dtend */
|
|
|
|
/** @var \DateTimeImmutable $dtstartDt */
|
|
|
|
$dtstartDt = $dtstart->getDateTime();
|
|
|
|
/** @var \DateTimeImmutable $dtendDt */
|
|
|
|
$dtendDt = $dtend->getDateTime();
|
|
|
|
|
|
|
|
$diff = $dtstartDt->diff($dtendDt);
|
|
|
|
|
|
|
|
$dtstartDt = new \DateTime($dtstartDt->format(\DateTime::ATOM));
|
|
|
|
$dtendDt = new \DateTime($dtendDt->format(\DateTime::ATOM));
|
|
|
|
|
|
|
|
if ($isAllDay) {
|
|
|
|
// One day event
|
|
|
|
if ($diff->days === 1) {
|
|
|
|
return $l10n->l('date', $dtstartDt, ['width' => 'medium']);
|
|
|
|
}
|
|
|
|
|
2020-01-30 17:02:16 +03:00
|
|
|
// DTEND is exclusive, so if the ics data says 2020-01-01 to 2020-01-05,
|
|
|
|
// the email should show 2020-01-01 to 2020-01-04.
|
|
|
|
$dtendDt->modify('-1 day');
|
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
//event that spans over multiple days
|
|
|
|
$localeStart = $l10n->l('date', $dtstartDt, ['width' => 'medium']);
|
|
|
|
$localeEnd = $l10n->l('date', $dtendDt, ['width' => 'medium']);
|
|
|
|
|
|
|
|
return $localeStart . ' - ' . $localeEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var Property\ICalendar\DateTime $dtstart */
|
|
|
|
/** @var Property\ICalendar\DateTime $dtend */
|
|
|
|
$isFloating = $dtstart->isFloating();
|
|
|
|
$startTimezone = $endTimezone = null;
|
|
|
|
if (!$isFloating) {
|
|
|
|
$prop = $dtstart->offsetGet('TZID');
|
|
|
|
if ($prop instanceof Parameter) {
|
|
|
|
$startTimezone = $prop->getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
$prop = $dtend->offsetGet('TZID');
|
|
|
|
if ($prop instanceof Parameter) {
|
|
|
|
$endTimezone = $prop->getValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-16 12:09:25 +03:00
|
|
|
$localeStart = $l10n->l('weekdayName', $dtstartDt, ['width' => 'abbreviated']) . ', ' .
|
|
|
|
$l10n->l('datetime', $dtstartDt, ['width' => 'medium|short']);
|
2017-11-02 18:38:16 +03:00
|
|
|
|
|
|
|
// always show full date with timezone if timezones are different
|
|
|
|
if ($startTimezone !== $endTimezone) {
|
2017-11-16 12:09:25 +03:00
|
|
|
$localeEnd = $l10n->l('datetime', $dtendDt, ['width' => 'medium|short']);
|
2017-11-02 18:38:16 +03:00
|
|
|
|
|
|
|
return $localeStart . ' (' . $startTimezone . ') - ' .
|
|
|
|
$localeEnd . ' (' . $endTimezone . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
// show only end time if date is the same
|
|
|
|
if ($this->isDayEqual($dtstartDt, $dtendDt)) {
|
2017-11-16 12:09:25 +03:00
|
|
|
$localeEnd = $l10n->l('time', $dtendDt, ['width' => 'short']);
|
2017-11-02 18:38:16 +03:00
|
|
|
} else {
|
2017-11-16 12:09:25 +03:00
|
|
|
$localeEnd = $l10n->l('weekdayName', $dtendDt, ['width' => 'abbreviated']) . ', ' .
|
|
|
|
$l10n->l('datetime', $dtendDt, ['width' => 'medium|short']);
|
2017-11-02 18:38:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $localeStart . ' - ' . $localeEnd . ' (' . $startTimezone . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \DateTime $dtStart
|
|
|
|
* @param \DateTime $dtEnd
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function isDayEqual(\DateTime $dtStart, \DateTime $dtEnd) {
|
|
|
|
return $dtStart->format('Y-m-d') === $dtEnd->format('Y-m-d');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IEMailTemplate $template
|
|
|
|
* @param IL10N $l10n
|
|
|
|
* @param string $method
|
|
|
|
* @param string $summary
|
|
|
|
*/
|
|
|
|
private function addSubjectAndHeading(IEMailTemplate $template, IL10N $l10n,
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$method, $summary) {
|
2017-11-02 18:38:16 +03:00
|
|
|
if ($method === self::METHOD_CANCEL) {
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$template->setSubject('Canceled: ' . $summary);
|
|
|
|
$template->addHeading($l10n->t('Invitation canceled'));
|
2020-04-10 11:35:09 +03:00
|
|
|
} elseif ($method === self::METHOD_REPLY) {
|
2017-11-02 18:38:16 +03:00
|
|
|
$template->setSubject('Re: ' . $summary);
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$template->addHeading($l10n->t('Invitation updated'));
|
2017-11-02 18:38:16 +03:00
|
|
|
} else {
|
|
|
|
$template->setSubject('Invitation: ' . $summary);
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$template->addHeading($l10n->t('Invitation'));
|
2017-11-02 18:38:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IEMailTemplate $template
|
|
|
|
* @param IL10N $l10n
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
* @param VEVENT $vevent
|
2017-11-02 18:38:16 +03:00
|
|
|
*/
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
private function addBulletList(IEMailTemplate $template, IL10N $l10n, $vevent) {
|
|
|
|
if ($vevent->SUMMARY) {
|
|
|
|
$template->addBodyListItem($vevent->SUMMARY, $l10n->t('Title:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/title.svg'),'','',self::IMIP_INDENT);
|
2017-11-02 18:38:16 +03:00
|
|
|
}
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$meetingWhen = $this->generateWhenString($l10n, $vevent);
|
|
|
|
if ($meetingWhen) {
|
|
|
|
$template->addBodyListItem($meetingWhen, $l10n->t('Time:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/time.svg'),'','',self::IMIP_INDENT);
|
2017-11-02 18:38:16 +03:00
|
|
|
}
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
if ($vevent->LOCATION) {
|
|
|
|
$template->addBodyListItem($vevent->LOCATION, $l10n->t('Location:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/location.svg'),'','',self::IMIP_INDENT);
|
2017-11-02 18:38:16 +03:00
|
|
|
}
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
if ($vevent->URL) {
|
2020-09-02 18:16:24 +03:00
|
|
|
$url = $vevent->URL->getValue();
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$template->addBodyListItem(sprintf('<a href="%s">%s</a>',
|
2020-09-02 18:16:24 +03:00
|
|
|
htmlspecialchars($url),
|
|
|
|
htmlspecialchars($url)),
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$l10n->t('Link:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/link.svg'),
|
2020-09-02 18:16:24 +03:00
|
|
|
$url,'',self::IMIP_INDENT);
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->addAttendees($template, $l10n, $vevent);
|
|
|
|
|
|
|
|
/* Put description last, like an email body, since it can be arbitrarily long */
|
|
|
|
if ($vevent->DESCRIPTION) {
|
2020-09-02 18:16:24 +03:00
|
|
|
$template->addBodyListItem($vevent->DESCRIPTION->getValue(), $l10n->t('Description:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/description.svg'),'','',self::IMIP_INDENT);
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* addAttendees: add organizer and attendee names/emails to iMip mail.
|
|
|
|
*
|
|
|
|
* Enable with DAV setting: invitation_list_attendees (default: no)
|
|
|
|
*
|
|
|
|
* The default is 'no', which matches old behavior, and is privacy preserving.
|
|
|
|
*
|
|
|
|
* To enable including attendees in invitation emails:
|
|
|
|
* % php occ config:app:set dav invitation_list_attendees --value yes
|
|
|
|
*
|
|
|
|
* @param IEMailTemplate $template
|
|
|
|
* @param IL10N $l10n
|
|
|
|
* @param Message $iTipMessage
|
|
|
|
* @param int $lastOccurrence
|
|
|
|
* @author brad2014 on github.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
private function addAttendees(IEMailTemplate $template, IL10N $l10n, VEvent $vevent) {
|
|
|
|
if ($this->config->getAppValue('dav', 'invitation_list_attendees', 'no') === 'no') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($vevent->ORGANIZER)) {
|
2020-09-02 18:16:24 +03:00
|
|
|
/** @var Property\ICalendar\CalAddress $organizer */
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$organizer = $vevent->ORGANIZER;
|
|
|
|
$organizerURI = $organizer->getNormalizedValue();
|
|
|
|
list($scheme,$organizerEmail) = explode(':',$organizerURI,2); # strip off scheme mailto:
|
2020-09-02 18:16:24 +03:00
|
|
|
/** @var string|null $organizerName */
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$organizerName = isset($organizer['CN']) ? $organizer['CN'] : null;
|
|
|
|
$organizerHTML = sprintf('<a href="%s">%s</a>',
|
|
|
|
htmlspecialchars($organizerURI),
|
|
|
|
htmlspecialchars($organizerName ?: $organizerEmail));
|
|
|
|
$organizerText = sprintf('%s <%s>', $organizerName, $organizerEmail);
|
2020-09-02 18:16:24 +03:00
|
|
|
if (isset($organizer['PARTSTAT'])) {
|
|
|
|
/** @var Parameter $partstat */
|
|
|
|
$partstat = $organizer['PARTSTAT'];
|
|
|
|
if (strcasecmp($partstat->getValue(), 'ACCEPTED') === 0) {
|
|
|
|
$organizerHTML .= ' ✔︎';
|
|
|
|
$organizerText .= ' ✔︎';
|
|
|
|
}
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
}
|
|
|
|
$template->addBodyListItem($organizerHTML, $l10n->t('Organizer:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/organizer.svg'),
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
$organizerText,'',self::IMIP_INDENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
$attendees = $vevent->select('ATTENDEE');
|
|
|
|
if (count($attendees) === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$attendeesHTML = [];
|
|
|
|
$attendeesText = [];
|
|
|
|
foreach ($attendees as $attendee) {
|
|
|
|
$attendeeURI = $attendee->getNormalizedValue();
|
|
|
|
list($scheme,$attendeeEmail) = explode(':',$attendeeURI,2); # strip off scheme mailto:
|
|
|
|
$attendeeName = isset($attendee['CN']) ? $attendee['CN'] : null;
|
|
|
|
$attendeeHTML = sprintf('<a href="%s">%s</a>',
|
|
|
|
htmlspecialchars($attendeeURI),
|
|
|
|
htmlspecialchars($attendeeName ?: $attendeeEmail));
|
|
|
|
$attendeeText = sprintf('%s <%s>', $attendeeName, $attendeeEmail);
|
|
|
|
if (isset($attendee['PARTSTAT'])
|
|
|
|
&& strcasecmp($attendee['PARTSTAT'], 'ACCEPTED') === 0) {
|
|
|
|
$attendeeHTML .= ' ✔︎';
|
|
|
|
$attendeeText .= ' ✔︎';
|
|
|
|
}
|
|
|
|
array_push($attendeesHTML, $attendeeHTML);
|
|
|
|
array_push($attendeesText, $attendeeText);
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->addBodyListItem(implode('<br/>',$attendeesHTML), $l10n->t('Attendees:'),
|
2019-10-11 00:35:28 +03:00
|
|
|
$this->getAbsoluteImagePath('caldav/attendees.svg'),
|
iMIP email improvements (take 2)
This PR is a replacement for PR #17195. It is intended to be simpler
to review and approve, with fewer changes, some disabled by default.
It addresses issues #12391 and #13555, with the following changes:
- The plainText of iMIP emails has been upgraded as described in
issue #12391. The HTML design style has not been changed.
- Some of the HTML and plainText content has been rearranged
(simplified header language, moving the event title to from text
body to the first item in the bullet list, spelling corrections,
moving the description to the end of the list), per issue #12391.
- The interface for EMailTemplate has been extended: addBodyListItem
now takes an optional `plainIndent` parameter. Existing callers
see no change. Where new calls set the new parameter >0, the list
item label (metaInfo) is put in column 1, and the value is indented
into column 2 (properly accounting for multiple lines, if any).
- An optional dav config setting has been added,
`invitation_list_attendees`. It defaults to 'no', leaving emails
unchanged. If set by the site admin to 'yes', then iMIP emails
include, for the organizer and each attendee, their name, email,
and a ✔︎ if they have accepted the invitation.
- Minor refactoring.
Notes:
- The labels for organizers and attendees list items are new, and
require translation/localization.
- Dav config settings are documented in the code, but not in the
Administrator's Guide.
Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
2019-10-08 10:23:26 +03:00
|
|
|
implode("\n",$attendeesText),'',self::IMIP_INDENT);
|
2017-11-02 18:38:16 +03:00
|
|
|
}
|
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
/**
|
|
|
|
* @param IEMailTemplate $template
|
|
|
|
* @param IL10N $l10n
|
|
|
|
* @param Message $iTipMessage
|
|
|
|
* @param int $lastOccurrence
|
|
|
|
*/
|
|
|
|
private function addResponseButtons(IEMailTemplate $template, IL10N $l10n,
|
|
|
|
Message $iTipMessage, $lastOccurrence) {
|
|
|
|
$token = $this->createInvitationToken($iTipMessage, $lastOccurrence);
|
|
|
|
|
|
|
|
$template->addBodyButtonGroup(
|
|
|
|
$l10n->t('Accept'),
|
|
|
|
$this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.accept', [
|
|
|
|
'token' => $token,
|
|
|
|
]),
|
|
|
|
$l10n->t('Decline'),
|
|
|
|
$this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.decline', [
|
|
|
|
'token' => $token,
|
|
|
|
])
|
|
|
|
);
|
|
|
|
|
|
|
|
$moreOptionsURL = $this->urlGenerator->linkToRouteAbsolute('dav.invitation_response.options', [
|
|
|
|
'token' => $token,
|
|
|
|
]);
|
|
|
|
$html = vsprintf('<small><a href="%s">%s</a></small>', [
|
2018-07-30 16:05:55 +03:00
|
|
|
$moreOptionsURL, $l10n->t('More options …')
|
2018-06-19 22:01:14 +03:00
|
|
|
]);
|
|
|
|
$text = $l10n->t('More options at %s', [$moreOptionsURL]);
|
2018-11-12 23:11:47 +03:00
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
$template->addBodyText($html, $text);
|
|
|
|
}
|
|
|
|
|
2017-11-02 18:38:16 +03:00
|
|
|
/**
|
|
|
|
* @param string $path
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getAbsoluteImagePath($path) {
|
|
|
|
return $this->urlGenerator->getAbsoluteURL(
|
|
|
|
$this->urlGenerator->imagePath('core', $path)
|
|
|
|
);
|
|
|
|
}
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Message $iTipMessage
|
|
|
|
* @param int $lastOccurrence
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function createInvitationToken(Message $iTipMessage, $lastOccurrence):string {
|
|
|
|
$token = $this->random->generate(60, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
|
|
|
|
|
|
|
|
/** @var VEvent $vevent */
|
|
|
|
$vevent = $iTipMessage->message->VEVENT;
|
|
|
|
$attendee = $iTipMessage->recipient;
|
|
|
|
$organizer = $iTipMessage->sender;
|
|
|
|
$sequence = $iTipMessage->sequence;
|
|
|
|
$recurrenceId = isset($vevent->{'RECURRENCE-ID'}) ?
|
|
|
|
$vevent->{'RECURRENCE-ID'}->serialize() : null;
|
|
|
|
$uid = $vevent->{'UID'};
|
|
|
|
|
|
|
|
$query = $this->db->getQueryBuilder();
|
2018-07-12 13:11:11 +03:00
|
|
|
$query->insert('calendar_invitations')
|
2018-06-19 22:01:14 +03:00
|
|
|
->values([
|
|
|
|
'token' => $query->createNamedParameter($token),
|
|
|
|
'attendee' => $query->createNamedParameter($attendee),
|
|
|
|
'organizer' => $query->createNamedParameter($organizer),
|
|
|
|
'sequence' => $query->createNamedParameter($sequence),
|
|
|
|
'recurrenceid' => $query->createNamedParameter($recurrenceId),
|
|
|
|
'expiration' => $query->createNamedParameter($lastOccurrence),
|
|
|
|
'uid' => $query->createNamedParameter($uid)
|
|
|
|
])
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
return $token;
|
|
|
|
}
|
2015-12-18 13:56:25 +03:00
|
|
|
}
|