]> git.mxchange.org Git - friendica.git/blobdiff - mod/events.php
Merge pull request #11973 from MrPetovan/task/test-fixDateFormat
[friendica.git] / mod / events.php
index 6ce322a4df4894ee767e5310c4ad460072986b74..082cdf55dd7ca5401b2bc9ae4c956c1ec0a365e1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -27,6 +27,7 @@ use Friendica\Core\ACL;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\Core\Theme;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -49,12 +50,6 @@ function events_init(App $a)
                return;
        }
 
-       // If it's a json request abort here because we don't
-       // need the widget data
-       if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] === 'json') {
-               return;
-       }
-
        if (empty(DI::page()['aside'])) {
                DI::page()['aside'] = '';
        }
@@ -128,8 +123,7 @@ function events_post(App $a)
        if (strcmp($finish, $start) < 0 && !$nofinish) {
                notice(DI::l10n()->t('Event can not end before it has started.'));
                if (intval($_REQUEST['preview'])) {
-                       echo DI::l10n()->t('Event can not end before it has started.');
-                       exit();
+                       System::httpExit(DI::l10n()->t('Event can not end before it has started.'));
                }
                DI::baseUrl()->redirect($onerror_path);
        }
@@ -137,8 +131,7 @@ function events_post(App $a)
        if (!$summary || ($start === DBA::NULL_DATETIME)) {
                notice(DI::l10n()->t('Event title and start time are required.'));
                if (intval($_REQUEST['preview'])) {
-                       echo DI::l10n()->t('Event title and start time are required.');
-                       exit();
+                       System::httpExit(DI::l10n()->t('Event title and start time are required.'));
                }
                DI::baseUrl()->redirect($onerror_path);
        }
@@ -198,9 +191,7 @@ function events_post(App $a)
        $datarray['id']        = $event_id;
 
        if (intval($_REQUEST['preview'])) {
-               $html = Event::getHTML($datarray);
-               echo $html;
-               exit();
+               System::httpExit(Event::getHTML($datarray));
        }
 
        $event_id = Event::store($datarray);
@@ -321,19 +312,6 @@ function events_content(App $a)
                $start  = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
                $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
 
-               if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] === 'json') {
-                       if (!empty($_GET['start'])) {
-                               $start = $_GET['start'];
-                       }
-                       if (!empty($_GET['end'])) {
-                               $finish = $_GET['end'];
-                       }
-               }
-
-               $start  = DateTimeFormat::utc($start);
-               $finish = DateTimeFormat::utc($finish);
-
-
                // put the event parametes in an array so we can better transmit them
                $event_params = [
                        'event_id'      => intval($_GET['id'] ?? 0),
@@ -369,12 +347,6 @@ function events_content(App $a)
                        $events = Event::prepareListForTemplate($r);
                }
 
-               if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] === 'json') {
-                       header('Content-Type: application/json');
-                       echo json_encode($events);
-                       exit();
-               }
-
                if (!empty($_GET['id'])) {
                        $tpl = Renderer::getMarkupTemplate("event.tpl");
                } else {
@@ -416,8 +388,7 @@ function events_content(App $a)
                ]);
 
                if (!empty($_GET['id'])) {
-                       echo $o;
-                       exit();
+                       System::httpExit($o);
                }
 
                return $o;