<?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
*
use Friendica\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
+use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Module\BaseProfile;
+use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
- if ($a->argc < 2) {
+ if (DI::args()->getArgc() < 2) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
// 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.'));
}
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.'));
}
$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
$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') {
$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'];
}
$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,
];
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;
}
// 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
]);
if (!empty($_GET['id'])) {
- echo $o;
- exit();
+ System::httpExit($o);
}
return $o;
// 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;