]> git.mxchange.org Git - friendica.git/blobdiff - mod/events.php
Ensure *toArray returns an array
[friendica.git] / mod / events.php
index a788cc157cf9be977f73ae3ee02d5a742a019a3f..86cec9a7d4130edfdafb31a6bd66f10e594bf6b0 100644 (file)
@@ -21,8 +21,7 @@ use Friendica\Module\Login;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
-
-require_once 'include/items.php';
+use Friendica\Worker\Delivery;
 
 function events_init(App $a)
 {
@@ -97,9 +96,9 @@ function events_post(App $a)
        // and we'll waste a bunch of time responding to it. Time that
        // could've been spent doing something else.
 
-       $summary  = Strings::escapeHtml(trim(defaults($_POST, 'summary', '')));
-       $desc     = Strings::escapeHtml(trim(defaults($_POST, 'desc', '')));
-       $location = Strings::escapeHtml(trim(defaults($_POST, 'location', '')));
+       $summary  = trim(defaults($_POST, 'summary' , ''));
+       $desc     = trim(defaults($_POST, 'desc'    , ''));
+       $location = trim(defaults($_POST, 'location', ''));
        $type     = 'event';
 
        $params = [
@@ -119,7 +118,7 @@ function events_post(App $a)
                notice(L10n::t('Event can not end before it has started.') . EOL);
                if (intval($_REQUEST['preview'])) {
                        echo L10n::t('Event can not end before it has started.');
-                       killme();
+                       exit();
                }
                $a->internalRedirect($onerror_path);
        }
@@ -128,7 +127,7 @@ function events_post(App $a)
                notice(L10n::t('Event title and start time are required.') . EOL);
                if (intval($_REQUEST['preview'])) {
                        echo L10n::t('Event title and start time are required.');
-                       killme();
+                       exit();
                }
                $a->internalRedirect($onerror_path);
        }
@@ -197,7 +196,7 @@ function events_post(App $a)
        $item_id = Event::store($datarray);
 
        if (!$cid) {
-               Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
+               Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id);
        }
 
        $a->internalRedirect('events');
@@ -215,14 +214,14 @@ function events_content(App $a)
        }
 
        if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
-               $r = q("UPDATE `event` SET `ignore` = 1 WHERE `id` = %d AND `uid` = %d",
+               q("UPDATE `event` SET `ignore` = 1 WHERE `id` = %d AND `uid` = %d",
                        intval($a->argv[2]),
                        intval(local_user())
                );
        }
 
        if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
-               $r = q("UPDATE `event` SET `ignore` = 0 WHERE `id` = %d AND `uid` = %d",
+               q("UPDATE `event` SET `ignore` = 0 WHERE `id` = %d AND `uid` = %d",
                        intval($a->argv[2]),
                        intval(local_user())
                );
@@ -239,7 +238,6 @@ function events_content(App $a)
 
        $htpl = Renderer::getMarkupTemplate('event_head.tpl');
        $a->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
-               '$baseurl' => System::baseUrl(),
                '$module_url' => '/events',
                '$modparams' => 1,
                '$i18n' => $i18n,
@@ -249,7 +247,7 @@ function events_content(App $a)
        $tabs = '';
        // tabs
        if ($a->theme_events_in_profile) {
-               $tabs = Profile::getTabs($a, true);
+               $tabs = Profile::getTabs($a, 'events', true);
        }
 
        $mode = 'view';
@@ -302,21 +300,6 @@ function events_content(App $a)
                        $y = 2100;
                }
 
-               $nextyear = $y;
-               $nextmonth = $m + 1;
-               if ($nextmonth > 12) {
-                       $nextmonth = 1;
-                       $nextyear ++;
-               }
-
-               $prevyear = $y;
-               if ($m > 1) {
-                       $prevmonth = $m - 1;
-               } else {
-                       $prevmonth = 12;
-                       $prevyear --;
-               }
-
                $dim    = Temporal::getDaysInMonth($y, $m);
                $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);
@@ -396,7 +379,6 @@ function events_content(App $a)
                }
 
                $o = Renderer::replaceMacros($tpl, [
-                       '$baseurl'   => System::baseUrl(),
                        '$tabs'      => $tabs,
                        '$title'     => L10n::t('Events'),
                        '$view'      => L10n::t('View'),
@@ -416,7 +398,7 @@ function events_content(App $a)
 
                if (!empty($_GET['id'])) {
                        echo $o;
-                       killme();
+                       exit();
                }
 
                return $o;
@@ -528,7 +510,7 @@ function events_content(App $a)
                        '$s_text' => L10n::t('Event Starts:') . ' <span class="required" title="' . L10n::t('Required') . '">*</span>',
                        '$s_dsel' => Temporal::getDateTimeField(
                                new DateTime(),
-                               DateTime::createFromFormat('Y', $syear+5),
+                               DateTime::createFromFormat('Y', intval($syear) + 5),
                                DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"),
                                L10n::t('Event Starts:'),
                                'start_text',
@@ -543,7 +525,7 @@ function events_content(App $a)
                        '$f_text' => L10n::t('Event Finishes:'),
                        '$f_dsel' => Temporal::getDateTimeField(
                                new DateTime(),
-                               DateTime::createFromFormat('Y', $fyear+5),
+                               DateTime::createFromFormat('Y', intval($fyear) + 5),
                                DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"),
                                L10n::t('Event Finishes:'),
                                'finish_text',