X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fcal.php;h=3f249da0aca21c457146fd4243eebc669ea06430;hb=28e2eab7aee3ab5dac11fcc62be595b9a1c2df8b;hp=d4830842bb05159a2d015d1a655cc24668c1cc8c;hpb=69c75daf4f9173573bcfece08a1040612de88c1d;p=friendica.git diff --git a/mod/cal.php b/mod/cal.php index d4830842bb..3f249da0ac 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -1,6 +1,6 @@ t('Access denied.')); } - if ($a->argc < 2) { + if (DI::args()->getArgc() < 2) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); } @@ -52,11 +54,11 @@ function cal_init(App $a) // if it's a json request abort here becaus we don't // need the widget data - if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) { + if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) { return; } - $owner = User::getOwnerDataByNick($a->argv[1]); + $owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]); if (empty($owner)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } @@ -73,7 +75,7 @@ function cal_init(App $a) function cal_content(App $a) { - $owner = User::getOwnerDataByNick($a->argv[1]); + $owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]); if (empty($owner)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } @@ -101,9 +103,9 @@ function cal_content(App $a) $ignored = (!empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0); $format = 'ical'; - if ($a->argc == 4 && $a->argv[2] == 'export') { + if (DI::args()->getArgc() == 4 && DI::args()->getArgv()[2] == 'export') { $mode = 'export'; - $format = $a->argv[3]; + $format = DI::args()->getArgv()[3]; } // Setup permissions structures @@ -127,7 +129,7 @@ function cal_content(App $a) $sql_extra = " AND `event`.`cid` = 0 " . $sql_perms; // get the tab navigation bar - $tabs = BaseProfile::getTabsHTML($a, 'cal', false, $owner); + $tabs = BaseProfile::getTabsHTML($a, 'cal', false, $owner['nickname'], $owner['hide-friends']); // The view mode part is similiar to /mod/events.php if ($mode == 'view') { @@ -172,7 +174,7 @@ function cal_content(App $a) $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59); - if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) { + if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) { if (!empty($_GET['start'])) { $start = $_GET['start']; } @@ -185,16 +187,11 @@ function cal_content(App $a) $start = DateTimeFormat::utc($start); $finish = DateTimeFormat::utc($finish); - $adjust_start = DateTimeFormat::local($start); - $adjust_finish = DateTimeFormat::local($finish); - // put the event parametes in an array so we can better transmit them $event_params = [ 'event_id' => intval($_GET['id'] ?? 0), 'start' => $start, 'finish' => $finish, - 'adjust_start' => $adjust_start, - 'adjust_finish' => $adjust_finish, 'ignore' => $ignored, ]; @@ -210,7 +207,7 @@ function cal_content(App $a) if (DBA::isResult($r)) { $r = Event::sortByDate($r); foreach ($r as $rr) { - $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j'); + $j = DateTimeFormat::local($rr['start'], 'j'); if (empty($links[$j])) { $links[$j] = DI::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j; } @@ -220,20 +217,15 @@ function cal_content(App $a) // transform the event in a usable array $events = Event::prepareListForTemplate($r); - if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) { - echo json_encode($events); - exit(); + if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) { + System::jsonExit($events); } // links: array('href', 'text', 'extra css classes', 'title') if (!empty($_GET['id'])) { $tpl = Renderer::getMarkupTemplate("event.tpl"); } else { -// if (DI::config()->get('experimentals','new_calendar')==1){ $tpl = Renderer::getMarkupTemplate("events_js.tpl"); -// } else { -// $tpl = Renderer::getMarkupTemplate("events.tpl"); -// } } // Get rid of dashes in key names, Smarty3 can't handle them @@ -262,8 +254,7 @@ function cal_content(App $a) ]); if (!empty($_GET['id'])) { - echo $o; - exit(); + System::httpExit($o); } return $o; @@ -298,10 +289,8 @@ function cal_content(App $a) // If nothing went wrong we can echo the export content if ($evexport["success"]) { - header('Content-type: text/calendar'); header('content-disposition: attachment; filename="' . DI::l10n()->t('calendar') . '-' . $nick . '.' . $evexport["extension"] . '"'); - echo $evexport["content"]; - exit(); + System::httpExit($evexport["content"], Response::TYPE_BLANK, 'text/calendar'); } return;