diff --git a/l10n/de.js b/l10n/de.js index c126b0e7dfe9f49eb45720b746b0324048a80919..94b4682bd197c4e97af51f41ca8284150b415584 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -584,6 +584,14 @@ OC.L10N.register( "Dinner" : "Abendessen", "Lunch" : "Mittagessen", "Appointment not found" : "Termin nicht gefunden", - "User not found" : "Benutzer nicht gefunden" + "User not found" : "Benutzer nicht gefunden", + "Open Link" : "Link öffnen", + "Invitation Tentatively Accepted: %s": "Einladung Vorläufig Angenommen: %s", + "Tentatively Accepted": "Vorläufig Angenommen", + "Accepted": "Angenommen", + "Declined": "Abgelehnt", + "%s has declined your invitation to %s on %s" : "%s hat Ihre Einladung zu %s am %s abgelehnt", + "%s has accepted your invitation to %s on %s" : "%s hat Ihre Einladung zu %s am %s angenommen", + "%s has tentatively accepted your invitation to %s on %s" : "%s hat Ihre Einladung zu %s am %s vorläufig angenommen" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de.json b/l10n/de.json index a6ed5dfed26de72ee843864dba149e9f70ed799f..644db5b2fcdfda918154dca9ba02a79b66a7e0d9 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -582,6 +582,14 @@ "Dinner" : "Abendessen", "Lunch" : "Mittagessen", "Appointment not found" : "Termin nicht gefunden", - "User not found" : "Benutzer nicht gefunden" -},"pluralForm" :"nplurals=2; plural=n != 1;" + "User not found" : "Benutzer nicht gefunden", + "Open Link" : "Link öffnen", + "Invitation Tentatively Accepted: %s": "Einladung Vorläufig Angenommen: %s", + "Tentatively Accepted": "Vorläufig Angenommen", + "Accepted": "Angenommen", + "Declined": "Abgelehnt", + "%s has declined your invitation to %s on %s" : "%s hat Ihre Einladung zu %s am %s abgelehnt", + "%s has accepted your invitation to %s on %s" : "%s hat Ihre Einladung zu %s am %s angenommen", + "%s has tentatively accepted your invitation to %s on %s" : "%s hat Ihre Einladung zu %s am %s vorläufig angenommen" +},"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/de_DE.js b/l10n/de_DE.js index 22a8034cd308a2369265d6dc6278b377447c8fca..16a7c59dcba0d8edc1bec9026da59895fceccb9d 100644 --- a/l10n/de_DE.js +++ b/l10n/de_DE.js @@ -584,6 +584,14 @@ OC.L10N.register( "Dinner" : "Abendessen", "Lunch" : "Mittagessen", "Appointment not found" : "Termin nicht gefunden", - "User not found" : "Benutzer nicht gefunden" + "User not found" : "Benutzer nicht gefunden", + "Open Link" : "Link öffnen", + "Invitation Tentatively Accepted: %s": "Einladung Vorläufig Angenommen: %s", + "Tentatively Accepted": "Vorläufig Angenommen", + "Accepted": "Angenommen", + "Declined": "Abgelehnt", + "%s has declined your invitation to %s on %s" : "%s hat deine Einladung zu %s am %s abgelehnt", + "%s has accepted your invitation to %s on %s" : "%s hat deine Einladung zu %s am %s angenommen", + "%s has tentatively accepted your invitation to %s on %s" : "%s hat deine Einladung zu %s am %s vorläufig angenommen" }, "nplurals=2; plural=n != 1;"); diff --git a/l10n/de_DE.json b/l10n/de_DE.json index 58d02fa72a5d59b5c935ece0fe60be542d9ed8a4..ff70df984248702e260540435de729191ed7141c 100644 --- a/l10n/de_DE.json +++ b/l10n/de_DE.json @@ -582,6 +582,14 @@ "Dinner" : "Abendessen", "Lunch" : "Mittagessen", "Appointment not found" : "Termin nicht gefunden", - "User not found" : "Benutzer nicht gefunden" -},"pluralForm" :"nplurals=2; plural=n != 1;" + "User not found" : "Benutzer nicht gefunden", + "Open Link" : "Link öffnen", + "Invitation Tentatively Accepted: %s": "Einladung Vorläufig Angenommen: %s", + "Tentatively Accepted": "Vorläufig Angenommen", + "Accepted": "Angenommen", + "Declined": "Abgelehnt", + "%s has declined your invitation to %s on %s" : "%s hat deine Einladung zu %s am %s abgelehnt", + "%s has accepted your invitation to %s on %s" : "%s hat deine Einladung zu %s am %s angenommen", + "%s has tentatively accepted your invitation to %s on %s" : "%s hat deine Einladung zu %s am %s vorläufig angenommen" +},"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/en_GB.js b/l10n/en_GB.js index 1037c903bfbe06fed21413073c3de701280e6f38..6367cfbe14c4149bf0671cb526cc710a93e15bf5 100644 --- a/l10n/en_GB.js +++ b/l10n/en_GB.js @@ -80,6 +80,13 @@ OC.L10N.register( "Presentation" : "Presentation", "Review" : "Review", "Office" : "Office", - "Mail" : "Mail" + "Mail" : "Mail", + "Invitation Tentatively Accepted: %s": "Invitation Tentatively Accepted: %s", + "Tentatively Accepted": "Tentatively Accepted", + "Accepted": "Accepted", + "Declined": "Declined", + "%s has declined your invitation to %s on %s" : "%s has declined your invitation to %s on %s", + "%s has accepted your invitation to %s on %s" : "%s has accepted your invitation to %s on %s", + "%s has tentatively accepted your invitation to %s on %s" : "%s has tentatively accepted your invitation to %s on %s" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en_GB.json b/l10n/en_GB.json index 458687762b8bde8c6b3bb38d675e5e8a61488952..7c863649e8cc0554fb645e822ec5c0dcdfc36da3 100644 --- a/l10n/en_GB.json +++ b/l10n/en_GB.json @@ -1,83 +1,90 @@ { "translations": { - "Provided email-address is not valid" : "Provided email address is not valid", - "%s has published the calendar »%s«" : "%s has published the calendar »%s«", - "Unexpected error sending email. Please contact your administrator." : "Unexpected error sending email. Please contact your administrator.", - "Successfully sent email to %1$s" : "Successfully sent email to %1$s", - "Hello," : "Hello,", - "We wanted to inform you that %s has published the calendar »%s«." : "We wanted to inform you that %s has published the calendar »%s«.", - "Open »%s«" : "Open »%s«", - "Cheers!" : "Cheers!", - "Upcoming events" : "Upcoming events", - "Calendar" : "Calendar", - "A Calendar app for Nextcloud" : "A Calendar app for Nextcloud", - "The Calendar app is a user interface for Nextcloud's CalDAV server. Easily sync events from various devices with your Nextcloud and edit them online.\n\n* 🚀 **Integration with other Nextcloud apps!** Currently Contacts - more to come.\n* 🌐 **WebCal Support!** Want to see your favorite team’s matchdays in your calendar? No problem!\n* 🙋 **Attendees!** Invite people to your events\n* ⌚️ **Free/Busy!** See when your attendees are available to meet\n* ⏰ **Reminders!** Get alarms for events inside your browser and via email\n* 🔍 Search! Find your events at ease\n* ☑️ Tasks! See tasks with a due date directly in the calendar\n* 🙈 **We’re not reinventing the wheel!** Based on the great [c-dav library](https://github.com/nextcloud/cdav-library), [ical.js](https://github.com/mozilla-comm/ical.js) and [fullcalendar](https://github.com/fullcalendar/fullcalendar) libraries." : "The Calendar app is a user interface for Nextcloud's CalDAV server. Easily sync events from various devices with your Nextcloud and edit them online.\n\n* 🚀 **Integration with other Nextcloud apps!** Currently Contacts - more to come.\n* 🌐 **WebCal Support!** Want to see your favorite team’s match days in your calendar? No problem!\n* 🙋 **Attendees!** Invite people to your events.\n* ⌚️ **Free/Busy!** See when your attendees are available to meet.\n* ⏰ **Reminders!** Get alarms for events inside your browser and via email.\n* 🔍 Search! Find your events at ease.\n* ☑️ Tasks! See tasks with a due date directly in the calendar.\n* 🙈 **We’re not reinventing the wheel!** Based on the great [c-dav library](https://github.com/nextcloud/cdav-library), [ical.js](https://github.com/mozilla-comm/ical.js) and [fullcalendar](https://github.com/fullcalendar/fullcalendar) libraries.", - "Previous day" : "Previous day", - "Previous week" : "Previous week", - "Previous month" : "Previous month", - "Next day" : "Next day", - "Next week" : "Next week", - "Next month" : "Next month", - "Today" : "Today", - "Day" : "Day", - "Week" : "Week", - "Month" : "Month", - "List" : "List", - "Delete" : "Delete", - "Untitled calendar" : "Untitled calendar", - "Edit color" : "Edit colour", - "Copy private link" : "Copy private link", - "An error occurred, unable to change visibility of the calendar." : "An error occurred, unable to change visibility of the calendar.", - "An error occurred, unable to delete the calendar." : "An error occurred, unable to delete the calendar.", - "Calendar link copied to clipboard." : "Calendar link copied to clipboard.", - "Calendar link could not be copied to clipboard." : "Calendar link could not be copied to clipboard.", - "An error occurred, unable to change the calendar's color." : "An error occurred, unable to change the calendar's colour.", - "Share link" : "Share link", - "Publish calendar" : "Publish calendar", - "Publishing calendar" : "Publishing calendar", - "Share with users or groups" : "Share with users or groups", - "can edit" : "can edit", - "New calendar" : "New calendar", - "Filename" : "Filename", - "Cancel" : "Cancel", - "Automatic" : "Automatic", - "or" : "or", - "Actions" : "Actions", - "Show week numbers" : "Show week numbers", - "Settings & import" : "Settings & import", - "Location" : "Location", - "Description" : "Description", - "Monday" : "Monday", - "Save" : "Save", - "Update" : "Update", - "Notification" : "Notification", - "Email" : "Email", - "Busy" : "Busy", - "Unknown" : "Unknown", - "Tentative" : "Tentative", - "All day" : "All day", - "Repeat" : "Repeat", - "never" : "never", - "after" : "after", - "More" : "More", - "Global" : "Global", - "Personal" : "Personal", - "Details" : "Details", - "Attendees" : "Attendees", - "Close" : "Close", - "Anniversary" : "Anniversary", - "Week {number} of {year}" : "Week {number} of {year}", - "Daily" : "Daily", - "Weekly" : "Weekly", - "When shared show full event" : "When shared show full event", - "When shared show only busy" : "When shared show only busy", - "When shared hide this event" : "When shared hide this event", - "Status" : "Status", - "Confirmed" : "Confirmed", - "Categories" : "Categories", - "Custom color" : "Custom colour", - "Presentation" : "Presentation", - "Review" : "Review", - "Office" : "Office", - "Mail" : "Mail" + "Provided email-address is not valid" : "Provided email address is not valid", + "%s has published the calendar »%s«" : "%s has published the calendar »%s«", + "Unexpected error sending email. Please contact your administrator." : "Unexpected error sending email. Please contact your administrator.", + "Successfully sent email to %1$s" : "Successfully sent email to %1$s", + "Hello," : "Hello,", + "We wanted to inform you that %s has published the calendar »%s«." : "We wanted to inform you that %s has published the calendar »%s«.", + "Open »%s«" : "Open »%s«", + "Cheers!" : "Cheers!", + "Upcoming events" : "Upcoming events", + "Calendar" : "Calendar", + "A Calendar app for Nextcloud" : "A Calendar app for Nextcloud", + "The Calendar app is a user interface for Nextcloud's CalDAV server. Easily sync events from various devices with your Nextcloud and edit them online.\n\n* 🚀 **Integration with other Nextcloud apps!** Currently Contacts - more to come.\n* 🌐 **WebCal Support!** Want to see your favorite team’s matchdays in your calendar? No problem!\n* 🙋 **Attendees!** Invite people to your events\n* ⌚️ **Free/Busy!** See when your attendees are available to meet\n* ⏰ **Reminders!** Get alarms for events inside your browser and via email\n* 🔍 Search! Find your events at ease\n* ☑️ Tasks! See tasks with a due date directly in the calendar\n* 🙈 **We’re not reinventing the wheel!** Based on the great [c-dav library](https://github.com/nextcloud/cdav-library), [ical.js](https://github.com/mozilla-comm/ical.js) and [fullcalendar](https://github.com/fullcalendar/fullcalendar) libraries." : "The Calendar app is a user interface for Nextcloud's CalDAV server. Easily sync events from various devices with your Nextcloud and edit them online.\n\n* 🚀 **Integration with other Nextcloud apps!** Currently Contacts - more to come.\n* 🌐 **WebCal Support!** Want to see your favorite team’s match days in your calendar? No problem!\n* 🙋 **Attendees!** Invite people to your events.\n* ⌚️ **Free/Busy!** See when your attendees are available to meet.\n* ⏰ **Reminders!** Get alarms for events inside your browser and via email.\n* 🔍 Search! Find your events at ease.\n* ☑️ Tasks! See tasks with a due date directly in the calendar.\n* 🙈 **We’re not reinventing the wheel!** Based on the great [c-dav library](https://github.com/nextcloud/cdav-library), [ical.js](https://github.com/mozilla-comm/ical.js) and [fullcalendar](https://github.com/fullcalendar/fullcalendar) libraries.", + "Previous day" : "Previous day", + "Previous week" : "Previous week", + "Previous month" : "Previous month", + "Next day" : "Next day", + "Next week" : "Next week", + "Next month" : "Next month", + "Today" : "Today", + "Day" : "Day", + "Week" : "Week", + "Month" : "Month", + "List" : "List", + "Delete" : "Delete", + "Untitled calendar" : "Untitled calendar", + "Edit color" : "Edit colour", + "Copy private link" : "Copy private link", + "An error occurred, unable to change visibility of the calendar." : "An error occurred, unable to change visibility of the calendar.", + "An error occurred, unable to delete the calendar." : "An error occurred, unable to delete the calendar.", + "Calendar link copied to clipboard." : "Calendar link copied to clipboard.", + "Calendar link could not be copied to clipboard." : "Calendar link could not be copied to clipboard.", + "An error occurred, unable to change the calendar's color." : "An error occurred, unable to change the calendar's colour.", + "Share link" : "Share link", + "Publish calendar" : "Publish calendar", + "Publishing calendar" : "Publishing calendar", + "Share with users or groups" : "Share with users or groups", + "can edit" : "can edit", + "New calendar" : "New calendar", + "Filename" : "Filename", + "Cancel" : "Cancel", + "Automatic" : "Automatic", + "or" : "or", + "Actions" : "Actions", + "Show week numbers" : "Show week numbers", + "Settings & import" : "Settings & import", + "Location" : "Location", + "Description" : "Description", + "Monday" : "Monday", + "Save" : "Save", + "Update" : "Update", + "Notification" : "Notification", + "Email" : "Email", + "Busy" : "Busy", + "Unknown" : "Unknown", + "Tentative" : "Tentative", + "All day" : "All day", + "Repeat" : "Repeat", + "never" : "never", + "after" : "after", + "More" : "More", + "Global" : "Global", + "Personal" : "Personal", + "Details" : "Details", + "Attendees" : "Attendees", + "Close" : "Close", + "Anniversary" : "Anniversary", + "Week {number} of {year}" : "Week {number} of {year}", + "Daily" : "Daily", + "Weekly" : "Weekly", + "When shared show full event" : "When shared show full event", + "When shared show only busy" : "When shared show only busy", + "When shared hide this event" : "When shared hide this event", + "Status" : "Status", + "Confirmed" : "Confirmed", + "Categories" : "Categories", + "Custom color" : "Custom colour", + "Presentation" : "Presentation", + "Review" : "Review", + "Office" : "Office", + "Mail" : "Mail", + "Invitation Tentatively Accepted: %s": "Invitation Tentatively Accepted: %s", + "Tentatively Accepted": "Tentatively Accepted", + "Accepted": "Accepted", + "Declined": "Declined", + "%s has declined your invitation to %s on %s" : "%s has declined your invitation to %s on %s", + "%s has accepted your invitation to %s on %s" : "%s has accepted your invitation to %s on %s", + "%s has tentatively accepted your invitation to %s on %s" : "%s has tentatively accepted your invitation to %s on %s" },"pluralForm" :"nplurals=2; plural=(n != 1);" -} \ No newline at end of file +} diff --git a/l10n/es.js b/l10n/es.js index a79db1b69e88ea6041d195c4615739e53251c8bf..cd83d1e757b6e359bbf7fa28f8d064691a0c11c6 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -567,6 +567,14 @@ OC.L10N.register( "Dinner" : "Cena", "Lunch" : "Almuerzo", "Appointment not found" : "Cita no encontrada", - "User not found" : "Usuario no encontrado" + "User not found" : "Usuario no encontrado", + "Open Link" : "Abrir el enlace", + "Invitation Tentatively Accepted: %s": "Invitación Provisionalmente Aceptado: %s", + "Tentatively Accepted": "Aceptado Provisionalmente", + "Accepted": "Aceptado", + "Declined": "Rechazado", + "%s has declined your invitation to %s on %s" : "%s ha rechazado tu invitación a %s el %s", + "%s has accepted your invitation to %s on %s" : "%s ha aceptado tu invitación a %s el %s", + "%s has tentatively accepted your invitation to %s on %s" : "%s ha provisionalmente aceptado tu invitación a %s el %s" }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/es.json b/l10n/es.json index 06f4711def478dfc27e9fcd744c21255fc9200bd..7b69fd4ba9caea648347945abe89a985943ca607 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -565,6 +565,14 @@ "Dinner" : "Cena", "Lunch" : "Almuerzo", "Appointment not found" : "Cita no encontrada", - "User not found" : "Usuario no encontrado" + "User not found" : "Usuario no encontrado", + "Open Link" : "Abrir el enlace", + "Invitation Tentatively Accepted: %s": "Invitación Provisionalmente Aceptado : %s", + "Tentatively Accepted": "Aceptado Provisionalmente", + "Accepted": "Aceptado", + "Declined": "Rechazado", + "%s has declined your invitation to %s on %s" : "%s ha rechazado tu invitación a %s el %s", + "%s has accepted your invitation to %s on %s" : "%s ha aceptado tu invitación a %s el %s", + "%s has tentatively accepted your invitation to %s on %s" : "%s ha provisionalmente aceptado tu invitación a %s el %s" },"pluralForm" :"nplurals=2; plural=(n != 1);" } \ No newline at end of file diff --git a/l10n/fr.js b/l10n/fr.js index 5571e69f0ce76f0ae46e8ee670e0d4001b2ebe2e..8d300e97c34c0ad5112ca0e6f08481dd078d7ce2 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -571,6 +571,14 @@ OC.L10N.register( "Dinner" : "Diner", "Lunch" : "Repas", "Appointment not found" : "Rendez-vous non trouvé", - "User not found" : "Utilisateur non trouvé" + "User not found" : "Utilisateur non trouvé", + "Open Link" : "Ouvrir le lien", + "Invitation Tentatively Accepted: %s": "Invitation Accepté Provisoirement: %s", + "Tentatively Accepted": "Accepté Provisoirement", + "Accepted": "Accepté", + "Declined": "Refusé", + "%s has declined your invitation to %s on %s" : "%s a refusé votre invitation %s du %s", + "%s has accepted your invitation to %s on %s" : "%s a accepté votre invitation %s du %s", + "%s has tentatively accepted your invitation to %s on %s" : "%s a provisoirement accepté votre invitation %s du %s" }, "nplurals=2; plural=(n > 1);"); diff --git a/l10n/fr.json b/l10n/fr.json index 5a0f64f87f3930875aa0eb42bfbfc31a680af4f8..a6d40db2d9f6fa984ec0aad9dde36cca8d86d557 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -569,6 +569,14 @@ "Dinner" : "Diner", "Lunch" : "Repas", "Appointment not found" : "Rendez-vous non trouvé", - "User not found" : "Utilisateur non trouvé" + "User not found" : "Utilisateur non trouvé", + "Open Link" : "Ouvrir le lien", + "Invitation Tentatively Accepted: %s": "Invitation Accepté Provisoirement: %s", + "Tentatively Accepted": "Accepté Provisoirement", + "Accepted": "Accepté", + "Declined": "Refusé", + "%s has declined your invitation to %s on %s" : "%s a refusé votre invitation %s du %s", + "%s has accepted your invitation to %s on %s" : "%s a accepté votre invitation %s du %s", + "%s has tentatively accepted your invitation to %s on %s" : "%s a provisoirement accepté votre invitation %s du %s" },"pluralForm" :"nplurals=2; plural=(n > 1);" } \ No newline at end of file diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index e41f2bfacb74646b2db607b9a541ee308330b761..bd2438753f82077a525061986aad7b9f31543b60 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -32,6 +32,20 @@ use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\User\Events\UserDeletedEvent; use function method_exists; +use OCA\Calendar\Middleware\InvitationMiddleware; +use OCP\IRequest; +use OCP\IConfig; +use \OCP\IDBConnection; +use \OC\Core\Application as CoreApplication; +use OCP\Http\Client\IResponse; +use OCP\Calendar\IManager; +use OCP\Mail\IMailer; +use OCP\IL10N; +use OCP\L10N\IFactory as L10NFactory; +use OCP\Defaults; +use OCP\ILogger; +use OCP\IUserManager; + class Application extends App implements IBootstrap { @@ -43,6 +57,53 @@ class Application extends App implements IBootstrap { */ public function __construct(array $params = []) { parent::__construct(self::APP_ID, $params); + //$app = new \OCP\AppFramework\App('ecloud-theme-helper'); + //$containerinvite = $app->getContainer() ; + $container = $this->getContainer(); + /** + * Middleware + */ + $container->registerService('InvitationMiddleware', function($c){ + return new InvitationMiddleware( + $c->get(IRequest::class), + $c->get(IConfig::class), + $c->get(IDBConnection::class), + $c->get(IManager::class), + $c->get(IMailer::class), + $c->get(IL10N::class), + $c->get(Defaults::class), + $c->get(ILogger::class), + $c->get(IUserManager::class), + $c->get(L10NFactory::class), + ); + }); + + // executed in the order that it is registered + $container->registerMiddleware('InvitationMiddleware'); + + $app = new \OCP\AppFramework\App('dav'); + $containerinvite = $app->getContainer() ; + + /** + * Middleware + */ + $containerinvite->registerService('InvitationMiddleware', function($c){ + return new InvitationMiddleware( + $c->get(IRequest::class), + $c->get(IConfig::class), + $c->get(IDBConnection::class), + $c->get(IManager::class), + $c->get(IMailer::class), + $c->get(IL10N::class), + $c->get(Defaults::class), + $c->get(ILogger::class), + $c->get(IUserManager::class), + $c->get(L10NFactory::class), + ); + }); + + // executed in the order that it is registered + $containerinvite->registerMiddleware('InvitationMiddleware'); } /** @@ -57,11 +118,15 @@ class Application extends App implements IBootstrap { } $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); + + } /** * @inheritDoc */ public function boot(IBootContext $context): void { + + } -} +} \ No newline at end of file diff --git a/lib/Middleware/InvitationMiddleware.php b/lib/Middleware/InvitationMiddleware.php new file mode 100644 index 0000000000000000000000000000000000000000..a5058c7087b972c2043c982a17e5c0560bd7f2be --- /dev/null +++ b/lib/Middleware/InvitationMiddleware.php @@ -0,0 +1,229 @@ +request = $request; + $this->config = $config; + $this->db = $db; + $this->calendarManager = $calendarManager; + $this->mailer = $mailer; + $this->l10n = $l10n; + $this->defaults = $defaults; + $this->logger = $logger; + $this->iusermanager = $iusermanager; + $this->languageFactory = $languageFactory; + } + + public function afterController( + $controller, + $methodName, + Response $response + ) { + if ( + ($controller instanceof InvitationMaybeController && + $methodName === "tentative") || + ($controller instanceof InvitationResponseController && + ($methodName === "accept" || $methodName === "decline") && + $response->getStatus() == 200 && + $response->getTemplateName() == "schedule-response-success") + ) { + $token = $this->request->getParam("token"); + $query = $this->db->getQueryBuilder(); + $query + ->select("*") + ->from("calendar_invitations") + ->where( + $query + ->expr() + ->eq("token", $query->createNamedParameter($token)) + ); + $stmt = $query->execute(); + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + + $uid = $row["uid"]; + $sender = substr($row["attendee"], 7); + $recipient = substr($row["organizer"], 7); + + $query2 = $this->db->getQueryBuilder(); + $query2 + ->select("*") + ->from("calendarobjects") + ->where( + $query + ->expr() + ->eq("uid", $query2->createNamedParameter($uid)) + ); + $stmt2 = $query2->execute(); + $row2 = $stmt2->fetch(\PDO::FETCH_ASSOC); + $calendarobjectid = $row2["id"]; + + $query3 = $this->db->getQueryBuilder(); + $query3 + ->select("*") + ->from("calendarobjects_props") + ->where( + $query3 + ->expr() + ->eq( + "objectid", + $query3->createNamedParameter($calendarobjectid) + ) + ); + $stmt3 = $query3->execute(); + $row3 = $stmt3->fetchAll(\PDO::FETCH_ASSOC); + foreach ($row3 as $calendarobj1) { + if ( + $calendarobj1["parameter"] == "CN" && + $calendarobj1["name"] == "ATTENDEE" + ) { + $attendeename = $calendarobj1["value"]; + } + if ( + $calendarobj1["parameter"] == "CN" && + $calendarobj1["name"] == "ORGANIZER" + ) { + $organizername = $calendarobj1["value"]; + } + } + + $vObject = Reader::read($row2["calendardata"]); + $SUMMARY = $vObject->VEVENT->SUMMARY; + $datestart = (string) $vObject->VEVENT->DTSTART; + if (str_contains($datestart, "T")) { + $eventdate = date("F d, Y h:i", strtotime($datestart)); + } else { + $eventdate = date("F d, Y", strtotime($datestart)); + } + + if ($attendeename == "") { + $attendeename = $sender; + } + + if ($organizername == "") { + $organizername = $recipient; + } + + $userdata = $this->iusermanager->getByEmail($recipient); + $username = $userdata[0]->getUID(); + $userlang = $this->languageFactory->getUserLanguage($userdata[0]); + + if ($methodName === "tentative") { + $meetingTitle = $this->l10n->t("Invitation Tentatively Accepted: %s", [$SUMMARY] ); + + $data = [ + "attendee_name" => (string) $sender ?: $defaultVal, + "invitee_name" => (string) $recipient ?: $defaultVal, + "meeting_title" => (string) $meetingTitle ?: $defaultVal, + ]; + $method = "reply"; + $emailTemplate = $this->mailer->createEMailTemplate( + "dav.calendarInvite." . $method, + $data + ); + $emailTemplate->setSubject($this->l10n->t("Invitation Tentatively Accepted: %s",[$SUMMARY])); + $emailTemplate->addHeader(); + $emailTemplate->addHeading( + $this->l10n->t("Tentatively Accepted") + ); + $mailbodytext = $this->l10n->t( + "%s has tentatively accepted your invitation to %s on %s", + [$attendeename, $SUMMARY, $eventdate] + ); + } + + if ($methodName === "accept") { + $meetingTitle = $this->l10n->t("Invitation Accepted: %s", [$SUMMARY]); + $data = [ + "attendee_name" => (string) $sender ?: $defaultVal, + "invitee_name" => (string) $recipient ?: $defaultVal, + "meeting_title" => (string) $meetingTitle ?: $defaultVal, + ]; + $method = "reply"; + $emailTemplate = $this->mailer->createEMailTemplate( + $recipient, + $data + ); + $emailTemplate->setSubject($this->l10n->t("Invitation Accepted: %s", [$SUMMARY])); + $emailTemplate->addHeader(); + $emailTemplate->addHeading($this->l10n->t("Accepted")); + $mailbodytext = $this->l10n->t( + "%s has accepted your invitation to %s on %s", + [$attendeename, $SUMMARY, $eventdate] + ); + } + + if ($methodName === "decline") { + $meetingTitle = $this->l10n->t("Invitation Declined: %s", [$SUMMARY]); + $data = [ + "attendee_name" => (string) $sender ?: $defaultVal, + "invitee_name" => (string) $recipient ?: $defaultVal, + "meeting_title" => (string) $meetingTitle ?: $defaultVal, + ]; + $method = "reply"; + $emailTemplate = $this->mailer->createEMailTemplate( + "dav.calendarInvite." . $method, + $data + ); + $emailTemplate->setSubject($this->l10n->t("Invitation Declined: %s", [$SUMMARY])); + $emailTemplate->addHeader(); + $emailTemplate->addHeading($this->l10n->t("Declined")); + $mailbodytext = $this->l10n->t( + "%s has declined your invitation to %s on %s", + [$attendeename, $SUMMARY, $eventdate] + ); + } + + $emailTemplate->addBodyText( + htmlspecialchars($mailbodytext), + $mailbodytext + ); + $emailTemplate->addFooter(); + try { + $message = $this->mailer->createMessage(); + $message->setTo([$recipient => $organizername]); + $message->useTemplate($emailTemplate); + $this->mailer->send($message); + } catch (\Exception $e) { + // Log the exception and continue + $this->logger->logException($e); + } + } + + return $response; + } +}