]> git.mxchange.org Git - friendica.git/blobdiff - mod/cal.php
Merge pull request #10479 from MrPetovan/task/9378-merge-share-template
[friendica.git] / mod / cal.php
index 0e8e8a2af3328d1b73db78ed18c579a2f1cafac1..e1cf91aa685dd4cceeca4a36140e860777f00ce1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,7 +24,6 @@
  */
 
 use Friendica\App;
-use Friendica\Content\Feature;
 use Friendica\Content\Nav;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Widget;
@@ -35,7 +34,7 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Event;
 use Friendica\Model\Item;
-use Friendica\Model\Profile;
+use Friendica\Model\User;
 use Friendica\Module\BaseProfile;
 use Friendica\Network\HTTPException;
 use Friendica\Util\DateTimeFormat;
@@ -68,8 +67,7 @@ function cal_init(App $a)
                return;
        }
 
-       $a->profile = Profile::getByNickname($nick, $a->profile_uid);
-
+       $a->profile = User::getOwnerDataByNick($nick);
        if (empty($a->profile)) {
                throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
        }
@@ -86,7 +84,7 @@ function cal_init(App $a)
                '$about' => BBCode::convert($a->profile['about']),
        ]);
 
-       $cal_widget = Widget\CalendarExport::getHTML();
+       $cal_widget = Widget\CalendarExport::getHTML($user['uid']);
 
        if (empty(DI::page()['aside'])) {
                DI::page()['aside'] = '';
@@ -105,6 +103,11 @@ function cal_content(App $a)
        // get the translation strings for the callendar
        $i18n = Event::getStrings();
 
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
+       DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
+       DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
+
        $htpl = Renderer::getMarkupTemplate('event_head.tpl');
        DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
                '$module_url' => '/cal/' . $a->data['user']['nickname'],
@@ -126,6 +129,9 @@ function cal_content(App $a)
        // Setup permissions structures
        $owner_uid = intval($a->data['user']['uid']);
        $nick = $a->data['user']['nickname'];
+       if (empty($a->profile)) {
+               throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
+       }
 
        $contact_id = Session::getRemoteContactID($a->profile['uid']);