]> git.mxchange.org Git - friendica.git/blobdiff - mod/cal.php
Unused use removed
[friendica.git] / mod / cal.php
index 75fe87e7463f3568062f5f9faeb80d875eeeadca..d5b0487a4a958274651cab866d3ab3752d4f11e2 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,7 +27,7 @@ use Friendica\App;
 use Friendica\Content\Nav;
 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;
@@ -40,7 +40,7 @@ use Friendica\Util\Temporal;
 
 function cal_init(App $a)
 {
-       if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+       if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
                throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
        }
 
@@ -100,24 +100,17 @@ function cal_content(App $a)
        $m = 0;
        $ignored = (!empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0);
 
-       $format = 'ical';
-       if (DI::args()->getArgc() == 4 && DI::args()->getArgv()[2] == 'export') {
-               $mode = 'export';
-               $format = DI::args()->getArgv()[3];
-       }
-
        // Setup permissions structures
        $owner_uid = intval($owner['uid']);
-       $nick = $owner['nickname'];
 
-       $contact_id = Session::getRemoteContactID($owner['uid']);
+       $contact_id = DI::userSession()->getRemoteContactID($owner['uid']);
 
        $remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
 
-       $is_owner = local_user() == $owner['uid'];
+       $is_owner = DI::userSession()->getLocalUserId() == $owner['uid'];
 
        if ($owner['hidewall'] && !$is_owner && !$remote_contact) {
-               notice(DI::l10n()->t('Access to this profile has been restricted.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.'));
                return;
        }
 
@@ -216,8 +209,7 @@ function cal_content(App $a)
                $events = Event::prepareListForTemplate($r);
 
                if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
-                       echo json_encode($events);
-                       exit();
+                       System::jsonExit($events);
                }
 
                // links: array('href', 'text', 'extra css classes', 'title')
@@ -253,48 +245,9 @@ function cal_content(App $a)
                ]);
 
                if (!empty($_GET['id'])) {
-                       echo $o;
-                       exit();
+                       System::httpExit($o);
                }
 
                return $o;
        }
-
-       if ($mode == 'export') {
-               if (!$owner_uid) {
-                       notice(DI::l10n()->t('User not found'));
-                       return;
-               }
-
-               // Get the export data by uid
-               $evexport = Event::exportListByUserId($owner_uid, $format);
-
-               if (!$evexport["success"]) {
-                       if ($evexport["content"]) {
-                               notice(DI::l10n()->t('This calendar format is not supported'));
-                       } else {
-                               notice(DI::l10n()->t('No exportable data found'));
-                       }
-
-                       // If it the own calendar return to the events page
-                       // otherwise to the profile calendar page
-                       if (local_user() === $owner_uid) {
-                               $return_path = "events";
-                       } else {
-                               $return_path = "cal/" . $nick;
-                       }
-
-                       DI::baseUrl()->redirect($return_path);
-               }
-
-               // 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();
-               }
-
-               return;
-       }
 }