Merge pull request #9664 from annando/delete-contacts
[friendica.git/.git] / mod / events.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  * The events module
21  */
22
23 use Friendica\App;
24 use Friendica\Content\Nav;
25 use Friendica\Content\Widget\CalendarExport;
26 use Friendica\Core\ACL;
27 use Friendica\Core\Logger;
28 use Friendica\Core\Renderer;
29 use Friendica\Core\Theme;
30 use Friendica\Core\Worker;
31 use Friendica\Database\DBA;
32 use Friendica\DI;
33 use Friendica\Model\Event;
34 use Friendica\Model\Item;
35 use Friendica\Model\User;
36 use Friendica\Module\BaseProfile;
37 use Friendica\Module\Security\Login;
38 use Friendica\Util\DateTimeFormat;
39 use Friendica\Util\Strings;
40 use Friendica\Util\Temporal;
41 use Friendica\Worker\Delivery;
42
43 function events_init(App $a)
44 {
45         if (!local_user()) {
46                 return;
47         }
48
49         // If it's a json request abort here because we don't
50         // need the widget data
51         if ($a->argc > 1 && $a->argv[1] === 'json') {
52                 return;
53         }
54
55         if (empty(DI::page()['aside'])) {
56                 DI::page()['aside'] = '';
57         }
58
59         $cal_widget = CalendarExport::getHTML();
60
61         DI::page()['aside'] .= $cal_widget;
62
63         return;
64 }
65
66 function events_post(App $a)
67 {
68
69         Logger::debug('post', ['request' => $_REQUEST]);
70
71         if (!local_user()) {
72                 return;
73         }
74
75         $event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
76         $cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
77         $uid = local_user();
78
79         $start_text  = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
80         $finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
81
82         $adjust   = intval($_POST['adjust'] ?? 0);
83         $nofinish = intval($_POST['nofinish'] ?? 0);
84
85         // The default setting for the `private` field in event_store() is false, so mirror that
86         $private_event = false;
87
88         $start  = DBA::NULL_DATETIME;
89         $finish = DBA::NULL_DATETIME;
90
91         if ($start_text) {
92                 $start = $start_text;
93         }
94
95         if ($finish_text) {
96                 $finish = $finish_text;
97         }
98
99         if ($adjust) {
100                 $start = DateTimeFormat::convert($start, 'UTC', date_default_timezone_get());
101                 if (!$nofinish) {
102                         $finish = DateTimeFormat::convert($finish, 'UTC', date_default_timezone_get());
103                 }
104         } else {
105                 $start = DateTimeFormat::utc($start);
106                 if (!$nofinish) {
107                         $finish = DateTimeFormat::utc($finish);
108                 }
109         }
110
111         // Don't allow the event to finish before it begins.
112         // It won't hurt anything, but somebody will file a bug report
113         // and we'll waste a bunch of time responding to it. Time that
114         // could've been spent doing something else.
115
116         $summary  = trim($_POST['summary']  ?? '');
117         $desc     = trim($_POST['desc']     ?? '');
118         $location = trim($_POST['location'] ?? '');
119         $type     = 'event';
120
121         $params = [
122                 'summary'     => $summary,
123                 'description' => $desc,
124                 'location'    => $location,
125                 'start'       => $start_text,
126                 'finish'      => $finish_text,
127                 'adjust'      => $adjust,
128                 'nofinish'    => $nofinish,
129         ];
130
131         $action = ($event_id == '') ? 'new' : 'event/' . $event_id;
132         $onerror_path = 'events/' . $action . '?' . http_build_query($params, null, null, PHP_QUERY_RFC3986);
133
134         if (strcmp($finish, $start) < 0 && !$nofinish) {
135                 notice(DI::l10n()->t('Event can not end before it has started.'));
136                 if (intval($_REQUEST['preview'])) {
137                         echo DI::l10n()->t('Event can not end before it has started.');
138                         exit();
139                 }
140                 DI::baseUrl()->redirect($onerror_path);
141         }
142
143         if (!$summary || ($start === DBA::NULL_DATETIME)) {
144                 notice(DI::l10n()->t('Event title and start time are required.'));
145                 if (intval($_REQUEST['preview'])) {
146                         echo DI::l10n()->t('Event title and start time are required.');
147                         exit();
148                 }
149                 DI::baseUrl()->redirect($onerror_path);
150         }
151
152         $share = intval($_POST['share'] ?? 0);
153
154         $c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
155                 intval(local_user())
156         );
157
158         if (DBA::isResult($c)) {
159                 $self = $c[0]['id'];
160         } else {
161                 $self = 0;
162         }
163
164
165         if ($share) {
166
167                 $aclFormatter = DI::aclFormatter();
168
169                 $str_group_allow   = $aclFormatter->toString($_POST['group_allow'] ?? '');
170                 $str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? '');
171                 $str_group_deny    = $aclFormatter->toString($_POST['group_deny'] ?? '');
172                 $str_contact_deny  = $aclFormatter->toString($_POST['contact_deny'] ?? '');
173
174                 // Undo the pseudo-contact of self, since there are real contacts now
175                 if (strpos($str_contact_allow, '<' . $self . '>') !== false) {
176                         $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
177                 }
178                 // Make sure to set the `private` field as true. This is necessary to
179                 // have the posts show up correctly in Diaspora if an event is created
180                 // as visible only to self at first, but then edited to display to others.
181                 if (strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) {
182                         $private_event = true;
183                 }
184         } else {
185                 // Note: do not set `private` field for self-only events. It will
186                 // keep even you from seeing them!
187                 $str_contact_allow = '<' . $self . '>';
188                 $str_group_allow = $str_contact_deny = $str_group_deny = '';
189         }
190
191
192         $datarray = [];
193         $datarray['start']     = $start;
194         $datarray['finish']    = $finish;
195         $datarray['summary']   = $summary;
196         $datarray['desc']      = $desc;
197         $datarray['location']  = $location;
198         $datarray['type']      = $type;
199         $datarray['adjust']    = $adjust;
200         $datarray['nofinish']  = $nofinish;
201         $datarray['uid']       = $uid;
202         $datarray['cid']       = $cid;
203         $datarray['allow_cid'] = $str_contact_allow;
204         $datarray['allow_gid'] = $str_group_allow;
205         $datarray['deny_cid']  = $str_contact_deny;
206         $datarray['deny_gid']  = $str_group_deny;
207         $datarray['private']   = $private_event;
208         $datarray['id']        = $event_id;
209
210         if (intval($_REQUEST['preview'])) {
211                 $html = Event::getHTML($datarray);
212                 echo $html;
213                 exit();
214         }
215
216         $item_id = Event::store($datarray);
217
218         if (!$cid) {
219                 Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id);
220         }
221
222         DI::baseUrl()->redirect('events');
223 }
224
225 function events_content(App $a)
226 {
227         if (!local_user()) {
228                 notice(DI::l10n()->t('Permission denied.'));
229                 return Login::form();
230         }
231
232         if ($a->argc == 1) {
233                 $_SESSION['return_path'] = DI::args()->getCommand();
234         }
235
236         if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
237                 q("UPDATE `event` SET `ignore` = 1 WHERE `id` = %d AND `uid` = %d",
238                         intval($a->argv[2]),
239                         intval(local_user())
240                 );
241         }
242
243         if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
244                 q("UPDATE `event` SET `ignore` = 0 WHERE `id` = %d AND `uid` = %d",
245                         intval($a->argv[2]),
246                         intval(local_user())
247                 );
248         }
249
250         if ($a->theme_events_in_profile) {
251                 Nav::setSelected('home');
252         } else {
253                 Nav::setSelected('events');
254         }
255
256         // get the translation strings for the callendar
257         $i18n = Event::getStrings();
258
259         DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
260         DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
261         DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
262         DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
263
264         $htpl = Renderer::getMarkupTemplate('event_head.tpl');
265         DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
266                 '$module_url' => '/events',
267                 '$modparams' => 1,
268                 '$i18n' => $i18n,
269         ]);
270
271         $o = '';
272         $tabs = '';
273         // tabs
274         if ($a->theme_events_in_profile) {
275                 $tabs = BaseProfile::getTabsHTML($a, 'events', true);
276         }
277
278         $mode = 'view';
279         $y = 0;
280         $m = 0;
281         $ignored = !empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0;
282
283         if ($a->argc > 1) {
284                 if ($a->argc > 2 && $a->argv[1] == 'event') {
285                         $mode = 'edit';
286                         $event_id = intval($a->argv[2]);
287                 }
288                 if ($a->argc > 2 && $a->argv[1] == 'drop') {
289                         $mode = 'drop';
290                         $event_id = intval($a->argv[2]);
291                 }
292                 if ($a->argc > 2 && $a->argv[1] == 'copy') {
293                         $mode = 'copy';
294                         $event_id = intval($a->argv[2]);
295                 }
296                 if ($a->argv[1] === 'new') {
297                         $mode = 'new';
298                         $event_id = 0;
299                 }
300                 if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
301                         $mode = 'view';
302                         $y = intval($a->argv[1]);
303                         $m = intval($a->argv[2]);
304                 }
305         }
306
307         // The view mode part is similiar to /mod/cal.php
308         if ($mode == 'view') {
309                 $thisyear  = DateTimeFormat::localNow('Y');
310                 $thismonth = DateTimeFormat::localNow('m');
311                 if (!$y) {
312                         $y = intval($thisyear);
313                 }
314                 if (!$m) {
315                         $m = intval($thismonth);
316                 }
317
318                 // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
319                 // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
320
321                 if ($y < 1901) {
322                         $y = 1900;
323                 }
324                 if ($y > 2099) {
325                         $y = 2100;
326                 }
327
328                 $dim    = Temporal::getDaysInMonth($y, $m);
329                 $start  = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
330                 $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
331
332                 if ($a->argc > 1 && $a->argv[1] === 'json') {
333                         if (!empty($_GET['start'])) {
334                                 $start = $_GET['start'];
335                         }
336                         if (!empty($_GET['end'])) {
337                                 $finish = $_GET['end'];
338                         }
339                 }
340
341                 $start  = DateTimeFormat::utc($start);
342                 $finish = DateTimeFormat::utc($finish);
343
344                 $adjust_start  = DateTimeFormat::local($start);
345                 $adjust_finish = DateTimeFormat::local($finish);
346
347                 // put the event parametes in an array so we can better transmit them
348                 $event_params = [
349                         'event_id'      => intval($_GET['id'] ?? 0),
350                         'start'         => $start,
351                         'finish'        => $finish,
352                         'adjust_start'  => $adjust_start,
353                         'adjust_finish' => $adjust_finish,
354                         'ignore'        => $ignored,
355                 ];
356
357                 // get events by id or by date
358                 if ($event_params['event_id']) {
359                         $r = Event::getListById(local_user(), $event_params['event_id']);
360                 } else {
361                         $r = Event::getListByDate(local_user(), $event_params);
362                 }
363
364                 $links = [];
365
366                 if (DBA::isResult($r)) {
367                         $r = Event::sortByDate($r);
368                         foreach ($r as $rr) {
369                                 $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
370                                 if (empty($links[$j])) {
371                                         $links[$j] = DI::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j;
372                                 }
373                         }
374                 }
375
376                 $events = [];
377
378                 // transform the event in a usable array
379                 if (DBA::isResult($r)) {
380                         $r = Event::sortByDate($r);
381                         $events = Event::prepareListForTemplate($r);
382                 }
383
384                 if ($a->argc > 1 && $a->argv[1] === 'json') {
385                         header('Content-Type: application/json');
386                         echo json_encode($events);
387                         exit();
388                 }
389
390                 if (!empty($_GET['id'])) {
391                         $tpl = Renderer::getMarkupTemplate("event.tpl");
392                 } else {
393                         $tpl = Renderer::getMarkupTemplate("events_js.tpl");
394                 }
395
396                 // Get rid of dashes in key names, Smarty3 can't handle them
397                 foreach ($events as $key => $event) {
398                         $event_item = [];
399                         foreach ($event['item'] as $k => $v) {
400                                 $k = str_replace('-', '_', $k);
401                                 $event_item[$k] = $v;
402                         }
403                         $events[$key]['item'] = $event_item;
404                 }
405
406                 // ACL blocks are loaded in modals in frio
407                 DI::page()->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));
408                 DI::page()->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js'));
409                 DI::page()->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
410                 DI::page()->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
411
412                 $o = Renderer::replaceMacros($tpl, [
413                         '$tabs'      => $tabs,
414                         '$title'     => DI::l10n()->t('Events'),
415                         '$view'      => DI::l10n()->t('View'),
416                         '$new_event' => [DI::baseUrl() . '/events/new', DI::l10n()->t('Create New Event'), '', ''],
417                         '$previous'  => [DI::baseUrl() . '/events/$prevyear/$prevmonth', DI::l10n()->t('Previous'), '', ''],
418                         '$next'      => [DI::baseUrl() . '/events/$nextyear/$nextmonth', DI::l10n()->t('Next'), '', ''],
419                         '$calendar'  => Temporal::getCalendarTable($y, $m, $links, ' eventcal'),
420
421                         '$events'    => $events,
422
423                         '$today' => DI::l10n()->t('today'),
424                         '$month' => DI::l10n()->t('month'),
425                         '$week'  => DI::l10n()->t('week'),
426                         '$day'   => DI::l10n()->t('day'),
427                         '$list'  => DI::l10n()->t('list'),
428                 ]);
429
430                 if (!empty($_GET['id'])) {
431                         echo $o;
432                         exit();
433                 }
434
435                 return $o;
436         }
437
438         if (($mode === 'edit' || $mode === 'copy') && $event_id) {
439                 $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
440                         intval($event_id),
441                         intval(local_user())
442                 );
443                 if (DBA::isResult($r)) {
444                         $orig_event = $r[0];
445                 }
446         }
447
448         // Passed parameters overrides anything found in the DB
449         if (in_array($mode, ['edit', 'new', 'copy'])) {
450                 $share_checked = '';
451                 $share_disabled = '';
452
453                 if (empty($orig_event)) {
454                         $orig_event = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
455                 } elseif ($orig_event['allow_cid'] !== '<' . local_user() . '>'
456                         || $orig_event['allow_gid']
457                         || $orig_event['deny_cid']
458                         || $orig_event['deny_gid']) {
459                         $share_checked = ' checked="checked" ';
460                 }
461
462                 // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
463                 if (!empty($_REQUEST['nofinish']))    {$orig_event['nofinish']    = $_REQUEST['nofinish'];}
464                 if (!empty($_REQUEST['adjust']))      {$orig_event['adjust']      = $_REQUEST['adjust'];}
465                 if (!empty($_REQUEST['summary']))     {$orig_event['summary']     = $_REQUEST['summary'];}
466                 if (!empty($_REQUEST['desc']))        {$orig_event['desc']        = $_REQUEST['desc'];}
467                 if (!empty($_REQUEST['location']))    {$orig_event['location']    = $_REQUEST['location'];}
468                 if (!empty($_REQUEST['start']))       {$orig_event['start']       = $_REQUEST['start'];}
469                 if (!empty($_REQUEST['finish']))      {$orig_event['finish']      = $_REQUEST['finish'];}
470
471                 $n_checked = (!empty($orig_event['nofinish']) ? ' checked="checked" ' : '');
472                 $a_checked = (!empty($orig_event['adjust'])   ? ' checked="checked" ' : '');
473
474                 $t_orig = $orig_event['summary']  ?? '';
475                 $d_orig = $orig_event['desc']     ?? '';
476                 $l_orig = $orig_event['location'] ?? '';
477                 $eid = $orig_event['id'] ?? 0;
478                 $cid = $orig_event['cid'] ?? 0;
479                 $uri = $orig_event['uri'] ?? '';
480
481                 if ($cid || $mode === 'edit') {
482                         $share_disabled = 'disabled="disabled"';
483                 }
484
485                 $sdt = $orig_event['start'] ?? 'now';
486                 $fdt = $orig_event['finish'] ?? 'now';
487
488                 $tz = date_default_timezone_get();
489                 if (!empty($orig_event)) {
490                         $tz = ($orig_event['adjust'] ? date_default_timezone_get() : 'UTC');
491                 }
492
493                 $syear  = DateTimeFormat::convert($sdt, $tz, 'UTC', 'Y');
494                 $smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm');
495                 $sday   = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd');
496
497                 $shour   = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00';
498                 $sminute = !empty($orig_event) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00';
499
500                 $fyear  = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y');
501                 $fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm');
502                 $fday   = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd');
503
504                 $fhour   = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00';
505                 $fminute = !empty($orig_event) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00';
506
507                 if (!$cid && in_array($mode, ['new', 'copy'])) {
508                         $acl = ACL::getFullSelectorHTML(DI::page(), $a->user, false, ACL::getDefaultUserPermissions($orig_event));
509                 } else {
510                         $acl = '';
511                 }
512
513                 // If we copy an old event, we need to remove the ID and URI
514                 // from the original event.
515                 if ($mode === 'copy') {
516                         $eid = 0;
517                         $uri = '';
518                 }
519
520                 $tpl = Renderer::getMarkupTemplate('event_form.tpl');
521
522                 $o .= Renderer::replaceMacros($tpl, [
523                         '$post' => DI::baseUrl() . '/events',
524                         '$eid'  => $eid,
525                         '$cid'  => $cid,
526                         '$uri'  => $uri,
527
528                         '$title' => DI::l10n()->t('Event details'),
529                         '$desc' => DI::l10n()->t('Starting date and Title are required.'),
530                         '$s_text' => DI::l10n()->t('Event Starts:') . ' <span class="required" title="' . DI::l10n()->t('Required') . '">*</span>',
531                         '$s_dsel' => Temporal::getDateTimeField(
532                                 new DateTime(),
533                                 DateTime::createFromFormat('Y', intval($syear) + 5),
534                                 DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"),
535                                 DI::l10n()->t('Event Starts:'),
536                                 'start_text',
537                                 true,
538                                 true,
539                                 '',
540                                 '',
541                                 true
542                         ),
543                         '$n_text' => DI::l10n()->t('Finish date/time is not known or not relevant'),
544                         '$n_checked' => $n_checked,
545                         '$f_text' => DI::l10n()->t('Event Finishes:'),
546                         '$f_dsel' => Temporal::getDateTimeField(
547                                 new DateTime(),
548                                 DateTime::createFromFormat('Y', intval($fyear) + 5),
549                                 DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"),
550                                 DI::l10n()->t('Event Finishes:'),
551                                 'finish_text',
552                                 true,
553                                 true,
554                                 'start_text'
555                         ),
556                         '$a_text' => DI::l10n()->t('Adjust for viewer timezone'),
557                         '$a_checked' => $a_checked,
558                         '$d_text' => DI::l10n()->t('Description:'),
559                         '$d_orig' => $d_orig,
560                         '$l_text' => DI::l10n()->t('Location:'),
561                         '$l_orig' => $l_orig,
562                         '$t_text' => DI::l10n()->t('Title:') . ' <span class="required" title="' . DI::l10n()->t('Required') . '">*</span>',
563                         '$t_orig' => $t_orig,
564                         '$summary' => ['summary', DI::l10n()->t('Title:'), $t_orig, '', '*'],
565                         '$sh_text' => DI::l10n()->t('Share this event'),
566                         '$share' => ['share', DI::l10n()->t('Share this event'), $share_checked, '', $share_disabled],
567                         '$sh_checked' => $share_checked,
568                         '$nofinish' => ['nofinish', DI::l10n()->t('Finish date/time is not known or not relevant'), $n_checked],
569                         '$adjust' => ['adjust', DI::l10n()->t('Adjust for viewer timezone'), $a_checked],
570                         '$preview' => DI::l10n()->t('Preview'),
571                         '$acl' => $acl,
572                         '$submit' => DI::l10n()->t('Submit'),
573                         '$basic' => DI::l10n()->t('Basic'),
574                         '$advanced' => DI::l10n()->t('Advanced'),
575                         '$permissions' => DI::l10n()->t('Permissions'),
576                 ]);
577
578                 return $o;
579         }
580
581         // Remove an event from the calendar and its related items
582         if ($mode === 'drop' && $event_id) {
583                 $ev = Event::getListById(local_user(), $event_id);
584
585                 // Delete only real events (no birthdays)
586                 if (DBA::isResult($ev) && $ev[0]['type'] == 'event') {
587                         Item::deleteForUser(['id' => $ev[0]['itemid']], local_user());
588                 }
589
590                 if (Item::exists(['id' => $ev[0]['itemid']])) {
591                         notice(DI::l10n()->t('Failed to remove event'));
592                 }
593
594                 DI::baseUrl()->redirect('events');
595         }
596 }