4 * @file src/Content/Widget/CalendarExport.php
7 namespace Friendica\Content\Widget;
9 use Friendica\Core\L10n;
11 require_once 'boot.php';
12 require_once 'include/text.php';
22 * @brief Get the events widget.
24 * @return string Formated HTML of the calendar widget.
26 public static function getHTML() {
29 // $owner_uid = $a->data['user']['uid'];
30 // // The permission testing is a little bit tricky because we have to respect many cases.
32 // // It's not the private events page (we don't get the $owner_uid for /events).
33 // if (! local_user() && ! $owner_uid) {
38 // * Cal logged in user (test permission at foreign profile page).
39 // * If the $owner uid is available we know it is part of one of the profile pages (like /cal).
40 // * So we have to test if if it's the own profile page of the logged in user
41 // * or a foreign one. For foreign profile pages we need to check if the feature
42 // * for exporting the cal is enabled (otherwise the widget would appear for logged in users
43 // * on foreigen profile pages even if the widget is disabled).
45 // if (intval($owner_uid) && local_user() !== $owner_uid && ! Feature::isEnabled($owner_uid, "export_calendar")) {
50 // * If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and
51 // * export feature isn't enabled.
53 // if (intval($owner_uid) && ! local_user() && ! Feature::isEnabled($owner_uid, "export_calendar")) {
57 * All the legacy checks above seem to be equivalent to the check below, see https://ethercalc.org/z6ehv1tut9cm
58 * If there is a mistake in the spreadsheet, please notify @MrPetovan on GitHub or by email mrpetovan@gmail.com
64 // $a->data is only available if the profile page is visited. If the visited page is not part
65 // of the profile page it should be the personal /events page. So we can use $a->user.
66 $user = defaults($a->data['user'], 'nickname', $a->user['nickname']);
68 $tpl = get_markup_template("events_aside.tpl");
69 $return = replace_macros($tpl, [
70 '$etitle' => L10n::t("Export"),
71 '$export_ical' => L10n::t("Export calendar as ical"),
72 '$export_csv' => L10n::t("Export calendar as csv"),