X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fevents.php;h=008cf643ceac1a670814ff90f15bfb85cea3b742;hb=b6000b3395167283fddee3fe9286f99c73f629d1;hp=f147e005459ab85f1b7c21710007c368a833254e;hpb=d4a02dc31408210ab9f67ecac1948dc22b95b8da;p=friendica.git diff --git a/mod/events.php b/mod/events.php index f147e00545..008cf643ce 100644 --- a/mod/events.php +++ b/mod/events.php @@ -22,8 +22,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/items.php'; - function events_init(App $a) { if (!local_user()) { @@ -97,19 +95,29 @@ 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'; - $action = ($event_id == '') ? 'new' : "event/" . $event_id; - $onerror_path = "events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; + $params = [ + 'summary' => $summary, + 'description' => $desc, + 'location' => $location, + 'start' => $start_text, + 'finish' => $finish_text, + 'adjust' => $adjust, + 'nofinish' => $nofinish, + ]; + + $action = ($event_id == '') ? 'new' : 'event/' . $event_id; + $onerror_path = 'events/' . $action . '?' . http_build_query($params, null, null, PHP_QUERY_RFC3986); if (strcmp($finish, $start) < 0 && !$nofinish) { 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); } @@ -118,7 +126,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); } @@ -137,10 +145,10 @@ function events_post(App $a) if ($share) { - $str_group_allow = !empty($_POST['group_allow']) ? perms2str($_POST['group_allow']) : ''; - $str_contact_allow = !empty($_POST['contact_allow']) ? perms2str($_POST['contact_allow']) : ''; - $str_group_deny = !empty($_POST['group_deny']) ? perms2str($_POST['group_deny']) : ''; - $str_contact_deny = !empty($_POST['contact_deny']) ? perms2str($_POST['contact_deny']) : ''; + $str_group_allow = perms2str(defaults($_POST, 'group_allow' , '')); + $str_contact_allow = perms2str(defaults($_POST, 'contact_allow', '')); + $str_group_deny = perms2str(defaults($_POST, 'group_deny' , '')); + $str_contact_deny = perms2str(defaults($_POST, 'contact_deny' , '')); // Undo the pseudo-contact of self, since there are real contacts now if (strpos($str_contact_allow, '<' . $self . '>') !== false) { @@ -181,7 +189,7 @@ function events_post(App $a) if (intval($_REQUEST['preview'])) { $html = Event::getHTML($datarray); echo $html; - killme(); + exit(); } $item_id = Event::store($datarray); @@ -205,14 +213,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()) ); @@ -292,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); @@ -364,8 +357,9 @@ function events_content(App $a) } if ($a->argc > 1 && $a->argv[1] === 'json') { + header('Content-Type: application/json'); echo json_encode($events); - killme(); + exit(); } if (!empty($_GET['id'])) { @@ -405,7 +399,7 @@ function events_content(App $a) if (!empty($_GET['id'])) { echo $o; - killme(); + exit(); } return $o; @@ -517,7 +511,7 @@ function events_content(App $a) '$s_text' => L10n::t('Event Starts:') . ' *', '$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', @@ -532,7 +526,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',