From bc42334ba01a66b26563f32e806ae4fb5d786e0f Mon Sep 17 00:00:00 2001 From: Geoff Maddock Date: Fri, 20 Dec 2024 19:42:30 +0000 Subject: [PATCH] Placeholder PR for updating ical package. For some reason it is not working, will have to revisit. --- app/Http/Controllers/EventsController.php | 48 ++++++++++++++++++++--- composer.json | 4 +- composer.lock | 35 +++++++++++------ 3 files changed, 66 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php index 0568e945..b8359437 100644 --- a/app/Http/Controllers/EventsController.php +++ b/app/Http/Controllers/EventsController.php @@ -54,8 +54,15 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Route; use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Eluceo\iCal\Component\Calendar; -use Eluceo\iCal\Component\Event as iCalEvent; +use Eluceo\iCal\Domain\Entity\Calendar; +use Eluceo\iCal\Domain\Entity\Event as iCalEvent; +use Eluceo\iCal\Domain\ValueObject\Organizer; +use Eluceo\iCal\Domain\ValueObject\Uri; +use Eluceo\iCal\Domain\ValueObject\EmailAddress; +use Eluceo\iCal\Domain\ValueObject\DateTime; +use Eluceo\iCal\Domain\ValueObject\Location; +use Eluceo\iCal\Domain\ValueObject\UniqueIdentifier; +use Eluceo\iCal\Presentation\Factory\CalendarFactory; class EventsController extends Controller { @@ -193,7 +200,7 @@ public function index( /** - * Return all future events in iCal format. + * Return all future events in iCal format, used for calendar subscriptions. */ public function indexIcal( Request $request, @@ -241,12 +248,16 @@ public function indexIcal( define('ICAL_FORMAT', 'Ymd\THis\Z'); // create a calendar object - $vCalendar = new Calendar('Arcane City Calendar'); + $vCalendar = new Calendar([]); // loop over events foreach ($events as $event) { + // get the name for the venue or set to empty $venue = $event->venue ? $event->venue->name : ''; + // use the route for the event as the unique id + $uniqueId = route('events.show', ['event' => $event]); + $vEvent = new iCalEvent(); $vEvent ->setDtStart($event->start_at) @@ -254,11 +265,36 @@ public function indexIcal( ->setDtStamp($event->created_at) ->setSummary($event->name) ->setDescription($event->description) - ->setUniqueId($event->id) + ->setUniqueId($uniqueId) ->setLocation($venue) ->setModified($event->updated_at) ->setStatus('CONFIRMED') - ->setUrl($event->primary_link); + ->setUrl($event->primary_link ? $event->primary_link : $uniqueId); + + // get the promoter to set organizer + + if ($event->promoter) { + // check for contacts on the promoter + if ($event->promoter->contacts->count() > 0) { + + // cycle through all contacts to find one with an email address + foreach ($event->promoter->contacts as $contact) { + if ($contact->email) { + + $organizer = new Organizer( + new EmailAddress('test@example.org'), + $event->promoter->name, + new Uri('ldap://example.com:6666/o=ABC%20Industries,c=US???(cn=Jim%20Dolittle)'), + new EmailAddress('sender@example.com') + ); + + $vEvent->setOrganizer($organizer); + + break; + } + } + } + } $vCalendar->addComponent($vEvent); } diff --git a/composer.json b/composer.json index a702e2e9..fe37d89f 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "laravel/socialite": "~5.0", "suin/php-rss-writer": "^1.5", "pusher/pusher-php-server": "^7.0", - "eluceo/ical": "^0.16.0", + "eluceo/ical": "^2.14.0", "bepsvpt/secure-headers": "^7.1", "facebook/php-business-sdk": "^12.0", "fakerphp/faker": "^1.18", @@ -100,4 +100,4 @@ } }, "minimum-stability": "stable" -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index f4961698..4bb2b3fa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f15f5124dc6a89074d0ca868bb2f4b8e", + "content-hash": "65eee495062def889f29da85c3710b40", "packages": [ { "name": "abraham/twitteroauth", @@ -1002,26 +1002,33 @@ }, { "name": "eluceo/ical", - "version": "0.16.1", + "version": "2.14.0", "source": { "type": "git", "url": "https://github.com/markuspoerschke/iCal.git", - "reference": "7043337feaeacbc016844e7e52ef41bba504ad8f" + "reference": "3123533f7ff0af015da1d788476204f936d18135" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/7043337feaeacbc016844e7e52ef41bba504ad8f", - "reference": "7043337feaeacbc016844e7e52ef41bba504ad8f", + "url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/3123533f7ff0af015da1d788476204f936d18135", + "reference": "3123533f7ff0af015da1d788476204f936d18135", "shasum": "" }, "require": { - "php": ">=7.1 || ~8.0.0" + "ext-mbstring": "*", + "php": ">=7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "symfony/deprecation-contracts": "^2.1 || ^3.0" }, - "require-dev": { - "phpunit/phpunit": "^7.0" + "conflict": { + "php": "7.4.6" }, - "suggest": { - "ext-mbstring": "Massive performance enhancement of line folding" + "require-dev": { + "ergebnis/composer-normalize": "^2.23.1", + "friendsofphp/php-cs-fixer": "^3.4", + "infection/infection": "^0.23 || ^0.26 || ^0.27", + "phpmd/phpmd": "^2.13", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.8 || ^5.0" }, "type": "library", "autoload": { @@ -1036,11 +1043,11 @@ "authors": [ { "name": "Markus Poerschke", - "email": "markus@eluceo.de", + "email": "markus@poerschke.nrw", "role": "Developer" } ], - "description": "The eluceo/iCal package offers a abstraction layer for creating iCalendars. You can easily create iCal files by using PHP object instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.", + "description": "The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.", "homepage": "https://github.com/markuspoerschke/iCal", "keywords": [ "calendar", @@ -1050,10 +1057,12 @@ "php calendar" ], "support": { + "docs": "https://ical.poerschke.nrw", + "forum": "https://github.com/markuspoerschke/iCal/discussions", "issues": "https://github.com/markuspoerschke/iCal/issues", "source": "https://github.com/markuspoerschke/iCal" }, - "time": "2020-10-04T17:41:11+00:00" + "time": "2024-07-11T22:33:13+00:00" }, { "name": "facebook/php-business-sdk",