feat: First checkin for the ical direct features#189
feat: First checkin for the ical direct features#189dploeger wants to merge 5 commits intoColdTrick:masterfrom
Conversation
|
@jdalsem can you find some time checking this out? Thanks. |
|
i enabled the automated checks on this PR. You might want to fix them first. After that i will do a detailed review of the code. At first glance it looks ok (with some minor remarks). I was wondering how you see this working together with the AddThisEvent feature (which also supports ical downloads). Should users choose on or the other? Maybe you could squash all your commits into one.. we do not need all the development commits in our history |
Sure. Will do, thanks.
I've made it selectable in the code. AddThisEvent doesn't support iCal imports and is a US-based company so many people will favor a local embedded version (at least we would 😅)
Yes, of course. I usually do a rebase with fixups once everything is settled. |
|
lol 4 comments... something went wrong probably If this can provide the same feature as AddThisEvent, we might choose to drop that. It is just an 'easy' solution (from the past). No specific needs... maybe the links in the mail footer is special |
|
Shouldn't use the GitHub app on an unstable 5G connection apparently. 😂 Sure, the iCal export also works fine on mobile with direct import into the calendar app. Although users who use the AddThisEvent app already might want to keep it. |
82b58db to
18e497f
Compare
18e497f to
c0bbb1e
Compare
|
@jdalsem Could you please approve the workflow again. I've fixed some things. |
|
we also expect the composer.lock file to be present (and updated with your changes) |
Hm. Actually did a Was that wrong? |
|
Hm. Maybe I copied the wrong composer.lock. 😆 I'll take a look |
|
Ah. Found the right composer.lock. Sorry. |
|
best option is to reset the lock and composer.json and do:
best practice is to not do composer update as it will update all (unrelated) packages... composer update should be something that we do in a separate commit / PR... not a big issue / blocker for now, but it might introduce unrelated issues |
|
still not ok... |
|
Yeah, resetted the lock like you suggested now. |
|
Now it installs correctly... some views/actions seem to be assuming too much... or not casting input correctly.. i will have a look at the rest of the PR |
|
Thanks. I'll take a look at the unit test result. |
|
If I read the result correctly, it just having a problem with calling the import ical action without specifying a correct input file. So the fix would be to check for a proper file and exiting, right? |
jdalsem
left a comment
There was a problem hiding this comment.
It was a big review, but i think you are on the right track... do not let the amount of comments discourage you. I am merely trying to make sure it all works as expected.
Main concerns:
- forms (import/export) should not be part of a listing resource (next to all/mine)
- actions should do some more sanity checks and expect users to misbehave
- importing of attendees feels a privacy issue (as users might join events they did not subscribe for themselves)
- importing to random users/groups is possible. You might need to validate if that is possible / allowed
If we can get this PR merged, this will be added in a minor version of Event Manager as 'experimental'. If all works fine we might consider dropping AddEvent in the version for Elgg 7 and completely switch to this ical feature.
| $date_format = elgg_get_config('date_format', elgg_echo('input:date_format')); | ||
|
|
||
| $start_date = get_input('start_date', ''); | ||
| if ($start_date == '') { |
There was a problem hiding this comment.
loosely comparing is not recommended. use triple === if you know it is a string or just use empty($start_date)
There was a problem hiding this comment.
you do this everywhere... just commenting once about it
There was a problem hiding this comment.
Do you mean every double == comparison? Because I see that outside my changed files as well. Or just comparing empty strings?
There was a problem hiding this comment.
there might be some legacy code that still does check with ==, but === is better. See https://www.php.net/manual/en/language.operators.comparison.php#:~:text=Note%3A%20Be%20aware%20that%20PHP's,in%20most%20cases.
| $calendar_type = get_input('calendar_type', 'all'); | ||
| $date_format = elgg_get_config('date_format', elgg_echo('input:date_format')); | ||
|
|
||
| $start_date = get_input('start_date', ''); |
There was a problem hiding this comment.
defaulting to empty string is not recommended. If you need it to always be a string, better to cast it:
$start_date = (string) get_input('start_date');
There was a problem hiding this comment.
you do this everywhere... just commenting once about it
There was a problem hiding this comment.
I wanted to default to an empty string so I can later default to the current time. A better alternative would be probably to check, if the start_date input was given at all. Is there a "has_input" function or something?
There was a problem hiding this comment.
no nothing other than get_input... has_input is just as tricky as you do not know if the input is valid. Personally just cast and check the validity with empty() or elgg_is_empty() and then decide if you need a special default.
| ] | ||
| ]; | ||
|
|
||
| if ($region != '') { |
There was a problem hiding this comment.
also a loosely compared condition... use !empty($region)
| @@ -0,0 +1,27 @@ | |||
| <?php | |||
There was a problem hiding this comment.
i think the import/export resource could be replaced by utilizing ajax forms
replace the tabs in the filter menu by title menu buttons that popup with an ajax form (look at reported content for an example)
There was a problem hiding this comment.
What do you mean with "reported content"?
There was a problem hiding this comment.
Oh i meant... take a look at the reported_content plugin. That plugin also has ajax lightbox form for reporting content.. maybe you can get inspiration there
composer.json
Outdated
| "conflict": { | ||
| "elgg/elgg": "<6.3.1" | ||
| }, | ||
| "require-dev": { |
There was a problem hiding this comment.
please remove this, we do not want it in our code....
we have sniffs configured in Elgg (the base repo) and in our IDE... we do not want the administration in our plugins... might need to update your lock file (composer update --lock) if you touch this
There was a problem hiding this comment.
Oh whoops. Got in there while trying to simulate the lint checks.
| 'path' => '/event', | ||
| 'resource' => 'event/upcoming', | ||
| ], | ||
| 'collection:ical:export' => [ |
There was a problem hiding this comment.
remove this if you decided to switch to ajax forms... as mentioned before
dploeger
left a comment
There was a problem hiding this comment.
I've fixed the first batches of comments. I'll take a look at the rest.
| $calendar_type = get_input('calendar_type', 'all'); | ||
| $date_format = elgg_get_config('date_format', elgg_echo('input:date_format')); | ||
|
|
||
| $start_date = get_input('start_date', ''); |
| $date_format = elgg_get_config('date_format', elgg_echo('input:date_format')); | ||
|
|
||
| $start_date = get_input('start_date', ''); | ||
| if ($start_date == '') { |
| ] | ||
| ]; | ||
|
|
||
| if ($region != '') { |
| try { | ||
| $vcalendar->parse($file->getContent()); | ||
| } catch (Exception $e) { | ||
| return elgg_error_response('Error parsing calendar: ' . $e); |
| $event = Event::fromVEvent($component); | ||
|
|
||
| switch ($calendar_type) { | ||
| case 'group': |
classes/Event.php
Outdated
| foreach ($vevent->getAllAttendee() as $attendee) { | ||
| $attendee_object = elgg_get_user_by_email($attendee); | ||
| if (!is_null($attendee_object)) { | ||
| $event->addRelationship($attendee_object->guid, 'event_attending'); |
composer.json
Outdated
| "conflict": { | ||
| "elgg/elgg": "<6.3.1" | ||
| }, | ||
| "require-dev": { |
|
Ah yes, the missing file-upload check. Thank you, PHPUnit. 😆 |
Missing German error translations
|
@jdalsem Could you please approve the workflows again? I hope the test is fixed now. I tried to run them locally, but I get this problem: |
|
is your phpunit.xml configured correctly? did you copy it from elgg? |
Sorry, no. I just tried copying the phpunit.xml.dist to phpunit.xml, but it didn't work either. Do you have any hints on how to properly setup the test tools? I mainly tried to interpret your github workflow. 😄 (My PHP development skills are also rather rusted, so please bear with me 🙂 ) |
|
it depends probably on how you installed... my enviroments is a github pull of elgg/elgg into a folder (your_website). In the /mod folder i have pulled my individual projects (event_manager). If you start a phpunit make sure you start it in the root folder of your website. You can use |
|
I've used the composer-way of installing elgg, but other than that it's quite the same. Maybe the error is because of another plugin I've installed. |
|
But about the test suite error: I believe it's because the ical export only exists in the ics viewtype and not the default. Should I add a stub for the default view or can this test be controlled to ignore the default view? |
|
The test says the resource view is not found... which is true... the resource is configured for 'event/export', but you have the export resource in 'event/export/ical'... or is an obsolete route? As you also have 'collection:ical:export'... check if and why you need the route 'default:object:event:export' |
|
I'm using that route in Entity.php while providing the view type. Or should I use ical:object:event:export as the rouote name? |
i would suggest you use just one ('collection:ical:export' makes the most sense)... but if you decide to move to ajax views... these would both become obsolete (no routes needed anymore) |
|
Okay. I'll check out that path then first. |
This implements a feature I called "ical direct" offering ical export and import features without the need of an external provider.
Features: