3 * @file include/event.php
4 * @brief functions specific to event handling
8 use Friendica\Core\System;
10 require_once 'include/bbcode.php';
11 require_once 'include/map.php';
12 require_once 'include/datetime.php';
14 function format_event_html($ev, $simple = false) {
16 if (! ((is_array($ev)) && count($ev))) {
20 $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
22 $event_start = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
23 $ev['start'] , $bd_format ))
24 : day_translate(datetime_convert('UTC', 'UTC',
25 $ev['start'] , $bd_format)));
27 $event_end = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
28 $ev['finish'] , $bd_format ))
29 : day_translate(datetime_convert('UTC', 'UTC',
30 $ev['finish'] , $bd_format )));
33 $o = "<h3>" . bbcode($ev['summary']) . "</h3>";
35 $o .= "<p>" . bbcode($ev['desc']) . "</p>";
37 $o .= "<h4>" . t('Starts:') . "</h4><p>" . $event_start . "</p>";
39 if (! $ev['nofinish']) {
40 $o .= "<h4>" . t('Finishes:') . "</h4><p>" . $event_end ."</p>";
43 if (strlen($ev['location'])) {
44 $o .= "<h4>" . t('Location:') . "</h4><p>" . $ev['location'] . "</p>";
50 $o = '<div class="vevent">' . "\r\n";
53 $o .= '<p class="summary event-summary">' . bbcode($ev['summary']) . '</p>' . "\r\n";
55 $o .= '<p class="description event-description">' . bbcode($ev['desc']) . '</p>' . "\r\n";
57 $o .= '<p class="event-start">' . t('Starts:') . ' <abbr class="dtstart" title="'
58 . datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
60 . '</abbr></p>' . "\r\n";
62 if (! $ev['nofinish']) {
63 $o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="'
64 . datetime_convert('UTC', 'UTC', $ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
66 . '</abbr></p>' . "\r\n";
69 if (strlen($ev['location'])) {
70 $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">'
71 . bbcode($ev['location'])
72 . '</span></p>' . "\r\n";
74 // Include a map of the location if the [map] BBCode is used
75 if (strpos($ev['location'], "[map") !== false) {
76 $map = generate_named_map($ev['location']);
77 if ($map !== $ev['location']) {
83 $o .= '</div>' . "\r\n";
87 function format_event_bbcode($ev) {
92 $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]';
96 $o .= '[event-description]' . $ev['desc'] . '[/event-description]';
100 $o .= '[event-start]' . $ev['start'] . '[/event-start]';
103 if (($ev['finish']) && (! $ev['nofinish'])) {
104 $o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
107 if ($ev['location']) {
108 $o .= '[event-location]' . $ev['location'] . '[/event-location]';
112 $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
118 function bbtovcal($s) {
123 $o = format_event_html($ev);
129 function bbtoevent($s) {
134 if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) {
135 $ev['summary'] = $match[1];
139 if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $s, $match)) {
140 $ev['desc'] = $match[1];
144 if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $s, $match)) {
145 $ev['start'] = $match[1];
149 if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $s, $match)) {
150 $ev['finish'] = $match[1];
154 if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $s, $match)) {
155 $ev['location'] = $match[1];
159 if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $s, $match)) {
160 $ev['adjust'] = $match[1];
163 $ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0);
169 function sort_by_date($a) {
171 usort($a,'ev_compare');
175 function ev_compare($a,$b) {
177 $date_a = (($a['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $a['start']) : $a['start']);
178 $date_b = (($b['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $b['start']) : $b['start']);
180 if ($date_a === $date_b) {
181 return strcasecmp($a['desc'], $b['desc']);
184 return strcmp($date_a, $date_b);
187 function event_delete($event_id) {
188 if ($event_id == 0) {
192 q("DELETE FROM `event` WHERE `id` = %d", intval($event_id));
193 logger("Deleted event ".$event_id, LOGGER_DEBUG);
196 function event_store($arr) {
198 require_once 'include/datetime.php';
199 require_once 'include/items.php';
200 require_once 'include/bbcode.php';
204 $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
205 $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
206 $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
207 $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
208 $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid']));
209 $arr['private'] = ((x($arr, 'private')) ? intval($arr['private']) : 0);
210 $arr['guid'] = get_guid(32);
213 $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
218 $c = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
223 if (dbm::is_result($c)) {
228 // Existing event being modified
232 // has the event actually changed?
234 $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
238 if ((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
240 // Nothing has changed. Grab the item id to return.
242 $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1",
246 return ((dbm::is_result($r)) ? $r[0]['id'] : 0);
249 // The event changed. Update it.
251 $r = q("UPDATE `event` SET
261 WHERE `id` = %d AND `uid` = %d",
263 dbesc($arr['edited']),
264 dbesc($arr['start']),
265 dbesc($arr['finish']),
266 dbesc($arr['summary']),
268 dbesc($arr['location']),
270 intval($arr['adjust']),
271 intval($arr['nofinish']),
275 $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1",
279 if (dbm::is_result($r)) {
280 $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
281 $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
282 $object .= '</object>' . "\n";
284 q("UPDATE `item` SET `body` = '%s', `object` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d",
285 dbesc(format_event_bbcode($arr)),
287 dbesc($arr['edited']),
292 $item_id = $r[0]['id'];
297 call_hooks("event_updated", $arr['id']);
302 // New event. Store it.
304 $r = q("INSERT INTO `event` (`uid`,`cid`,`guid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
305 `adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
306 VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
311 dbesc($arr['created']),
312 dbesc($arr['edited']),
313 dbesc($arr['start']),
314 dbesc($arr['finish']),
315 dbesc($arr['summary']),
317 dbesc($arr['location']),
319 intval($arr['adjust']),
320 intval($arr['nofinish']),
321 dbesc($arr['allow_cid']),
322 dbesc($arr['allow_gid']),
323 dbesc($arr['deny_cid']),
324 dbesc($arr['deny_gid'])
328 $r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
332 if (dbm::is_result($r)) {
338 $item_arr['uid'] = $arr['uid'];
339 $item_arr['contact-id'] = $arr['cid'];
340 $item_arr['uri'] = $arr['uri'];
341 $item_arr['parent-uri'] = $arr['uri'];
342 $item_arr['guid'] = $arr['guid'];
343 $item_arr['type'] = 'activity';
344 $item_arr['wall'] = (($arr['cid']) ? 0 : 1);
345 $item_arr['contact-id'] = $contact['id'];
346 $item_arr['owner-name'] = $contact['name'];
347 $item_arr['owner-link'] = $contact['url'];
348 $item_arr['owner-avatar'] = $contact['thumb'];
349 $item_arr['author-name'] = $contact['name'];
350 $item_arr['author-link'] = $contact['url'];
351 $item_arr['author-avatar'] = $contact['thumb'];
352 $item_arr['title'] = '';
353 $item_arr['allow_cid'] = $arr['allow_cid'];
354 $item_arr['allow_gid'] = $arr['allow_gid'];
355 $item_arr['deny_cid'] = $arr['deny_cid'];
356 $item_arr['deny_gid'] = $arr['deny_gid'];
357 $item_arr['private'] = $arr['private'];
358 $item_arr['last-child'] = 1;
359 $item_arr['visible'] = 1;
360 $item_arr['verb'] = ACTIVITY_POST;
361 $item_arr['object-type'] = ACTIVITY_OBJ_EVENT;
362 $item_arr['origin'] = ((intval($arr['cid']) == 0) ? 1 : 0);
363 $item_arr['body'] = format_event_bbcode($event);
366 $item_arr['object'] = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
367 $item_arr['object'] .= '<content>' . xmlify(format_event_bbcode($event)) . '</content>';
368 $item_arr['object'] .= '</object>' . "\n";
370 $item_id = item_store($item_arr);
372 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
375 //if (dbm::is_result($r))
376 // $plink = System::baseUrl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
380 //q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d",
382 // intval($event['id']),
383 // intval($arr['uid']),
386 q("UPDATE `item` SET `event-id` = %d WHERE `uid` = %d AND `id` = %d",
387 intval($event['id']),
393 call_hooks("event_created", $event['id']);
399 function get_event_strings() {
401 // First day of the week (0 = Sunday)
402 $firstDay = get_pconfig(local_user(), 'system', 'first_day_of_week');
403 if ($firstDay === false) {
408 "firstDay" => $firstDay,
409 "allday" => t("all-day"),
419 "Sunday" => t("Sunday"),
420 "Monday" => t("Monday"),
421 "Tuesday" => t("Tuesday"),
422 "Wednesday" => t("Wednesday"),
423 "Thursday" => t("Thursday"),
424 "Friday" => t("Friday"),
425 "Saturday" => t("Saturday"),
440 "January" => t("January"),
441 "February" => t("February"),
442 "March" => t("March"),
443 "April" => t("April"),
447 "August" => t("August"),
448 "September" => t("September"),
449 "October" => t("October"),
450 "November" => t("November"),
451 "December" => t("December"),
453 "today" => t("today"),
454 "month" => t("month"),
458 "noevent" => t("No events to display"),
460 "dtstart_label" => t("Starts:"),
461 "dtend_label" => t("Finishes:"),
462 "location_label" => t("Location:")
469 * @brief Removes duplicated birthday events
471 * @param array $dates Array of possibly duplicated events
472 * @return array Cleaned events
474 * @todo We should replace this with a separate update function if there is some time left
476 function event_remove_duplicates($dates) {
479 foreach ($dates AS $date) {
480 if ($date['type'] == 'birthday') {
481 $dates2[$date['uid'] . "-" . $date['cid'] . "-" . $date['start']] = $date;
490 * @brief Get an event by its event ID
492 * @param type $owner_uid The User ID of the owner of the event
493 * @param type $event_params An assoziative array with
494 * int 'event_id' => The ID of the event in the event table
495 * @param type $sql_extra
496 * @return array Query result
498 function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
499 // ownly allow events if there is a valid owner_id
500 if ($owner_uid == 0) {
504 // Query for the event by event id
505 $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
506 `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
507 LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
508 WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra",
510 intval($event_params["event_id"])
513 if (dbm::is_result($r)) {
514 return event_remove_duplicates($r);
519 * @brief Get all events in a specific timeframe
521 * @param int $owner_uid The User ID of the owner of the events
522 * @param array $event_params An assoziative array with
524 * string 'start' => Start time of the timeframe
525 * string 'finish' => Finish time of the timeframe
526 * string 'adjust_start' =>
527 * string 'adjust_start' =>
529 * @param string $sql_extra Additional sql conditions (e.g. permission request)
530 * @return array Query results
532 function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
533 // Only allow events if there is a valid owner_id
534 if ($owner_uid == 0) {
538 // Query for the event by date
539 $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
540 `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
541 LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
542 WHERE `event`.`uid` = %d AND event.ignore = %d
543 AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
544 OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s'))
547 intval($event_params["ignored"]),
548 dbesc($event_params["start"]),
549 dbesc($event_params["start"]),
550 dbesc($event_params["finish"]),
551 dbesc($event_params["adjust_start"]),
552 dbesc($event_params["adjust_start"]),
553 dbesc($event_params["adjust_finish"])
556 if (dbm::is_result($r)) {
557 return event_remove_duplicates($r);
562 * @brief Convert an array query results in an arry which could be used by the events template
564 * @param array $arr Event query array
565 * @return array Event array for the template
567 function process_events($arr) {
573 foreach ($arr as $rr) {
575 $j = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j'));
576 $d = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt));
577 $d = day_translate($d);
579 $start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'c') : datetime_convert('UTC', 'UTC', $rr['start'], 'c'));
580 if ($rr['nofinish']) {
583 $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['finish'], 'c') : datetime_convert('UTC', 'UTC', $rr['finish'], 'c'));
586 $is_first = ($d !== $last_date);
590 // Show edit and drop actions only if the user is the owner of the event and the event
591 // is a real event (no bithdays)
592 if (local_user() && local_user() == $rr['uid'] && $rr['type'] == 'event') {
593 $edit = ((! $rr['cid']) ? array(System::baseUrl() . '/events/event/' . $rr['id'], t('Edit event'), '', '') : null);
594 $drop = array(System::baseUrl() . '/events/drop/' . $rr['id'], t('Delete event'), '', '');
597 $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
599 list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
600 $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
603 $html = format_event_html($rr);
604 $rr['desc'] = bbcode($rr['desc']);
605 $rr['location'] = bbcode($rr['location']);
617 'is_first' => $is_first,
620 'plink' => array($rr['plink'], t('link to source'), '', ''),
629 * @brief Format event to export format (ical/csv)
631 * @param array $events Query result for events
632 * @param string $format The output format (ical/csv)
633 * @param string $timezone The timezone of the user (not implemented yet)
635 * @return string Content according to selected export format
637 function event_format_export ($events, $format = 'ical', $timezone) {
638 if (! ((is_array($events)) && count($events))) {
643 // Format the exported data as a CSV file
645 header("Content-type: text/csv");
646 $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
648 foreach ($events as $event) {
649 /// @todo The time / date entries don't include any information about the
650 /// timezone the event is scheduled in :-/
651 $tmp1 = strtotime($event['start']);
652 $tmp2 = strtotime($event['finish']);
653 $time_format = "%H:%M:%S";
654 $date_format = "%Y-%m-%d";
656 $o .= '"' . $event['summary'] . '", "' . strftime($date_format, $tmp1) .
657 '", "' . strftime($time_format, $tmp1) . '", "' . $event['desc'] .
658 '", "' . strftime($date_format, $tmp2) .
659 '", "' . strftime($time_format, $tmp2) .
660 '", "' . $event['location'] . '"' . PHP_EOL;
664 // Format the exported data as a ics file
666 header("Content-type: text/ics");
667 $o = 'BEGIN:VCALENDAR' . PHP_EOL
668 . 'VERSION:2.0' . PHP_EOL
669 . 'PRODID:-//friendica calendar export//0.1//EN' . PHP_EOL;
670 /// @todo include timezone informations in cases were the time is not in UTC
671 // see http://tools.ietf.org/html/rfc2445#section-4.8.3
672 // . 'BEGIN:VTIMEZONE' . PHP_EOL
673 // . 'TZID:' . $timezone . PHP_EOL
674 // . 'END:VTIMEZONE' . PHP_EOL;
675 // TODO instead of PHP_EOL CRLF should be used for long entries
676 // but test your solution against http://icalvalid.cloudapp.net/
677 // also long lines SHOULD be split at 75 characters length
678 foreach ($events as $event) {
680 if ($event['adjust'] == 1) {
685 $o .= 'BEGIN:VEVENT' . PHP_EOL;
687 if ($event['start']) {
688 $tmp = strtotime($event['start']);
689 $dtformat = "%Y%m%dT%H%M%S" . $UTC;
690 $o .= 'DTSTART:' . strftime($dtformat, $tmp) . PHP_EOL;
693 if (!$event['nofinish']) {
694 $tmp = strtotime($event['finish']);
695 $dtformat = "%Y%m%dT%H%M%S" . $UTC;
696 $o .= 'DTEND:' . strftime($dtformat, $tmp) . PHP_EOL;
699 if ($event['summary']) {
700 $tmp = $event['summary'];
701 $tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
702 $tmp = addcslashes($tmp, ',;');
703 $o .= 'SUMMARY:' . $tmp . PHP_EOL;
706 if ($event['desc']) {
707 $tmp = $event['desc'];
708 $tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
709 $tmp = addcslashes($tmp, ',;');
710 $o .= 'DESCRIPTION:' . $tmp . PHP_EOL;
713 if ($event['location']) {
714 $tmp = $event['location'];
715 $tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
716 $tmp = addcslashes($tmp, ',;');
717 $o .= 'LOCATION:' . $tmp . PHP_EOL;
720 $o .= 'END:VEVENT' . PHP_EOL;
724 $o .= 'END:VCALENDAR' . PHP_EOL;
732 * @brief Get all events for a user ID
734 * The query for events is done permission sensitive
735 * If the user is the owner of the calendar he/she
736 * will get all of his/her available events.
737 * If the user is only a visitor only the public events will
740 * @param int $uid The user ID
741 * @param int $sql_extra Additional sql conditions for permission
743 * @return array Query results
745 function events_by_uid($uid = 0, $sql_extra = '') {
750 // The permission condition if no condition was transmitted
751 if ($sql_extra == '') {
752 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' ";
755 // Does the user who requests happen to be the owner of the events
756 // requested? then show all of your events, otherwise only those that
757 // don't have limitations set in allow_cid and allow_gid
758 if (local_user() == $uid) {
759 $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`, `nofinish`
760 FROM `event` WHERE `uid`= %d AND `cid` = 0 ",
764 $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`, `nofinish`
765 FROM `event` WHERE `uid`= %d AND `cid` = 0 $sql_extra ",
770 if (dbm::is_result($r)) {
777 * @param int $uid The user ID
778 * @param string $format Output format (ical/csv)
779 * @return array With the results
780 * bool 'success' => True if the processing was successful
781 * string 'format' => The output format
782 * string 'extension' => The file extension of the output format
783 * string 'content' => The formatted output content
785 * @todo Respect authenticated users with events_by_uid()
787 function event_export($uid, $format = 'ical') {
791 // We are allowed to show events
792 // get the timezone the user is in
793 $r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
794 if (dbm::is_result($r)) {
795 $timezone = $r[0]['timezone'];
798 // Get all events which are owned by a uid (respects permissions);
799 $events = events_by_uid($uid);
801 // We have the events that are available for the requestor
802 // now format the output according to the requested format
803 if (count($events)) {
804 $res = event_format_export($events, $format, $timezone);
807 // If there are results the precess was successfull
812 // Get the file extension for the format
827 'success' => $process,
829 'extension' => $file_ext,
837 * @brief Get the events widget
839 * @return string Formated html of the evens widget
841 function widget_events() {
844 $owner_uid = $a->data['user']['uid'];
845 // $a->data is only available if the profile page is visited. If the visited page is not part
846 // of the profile page it should be the personal /events page. So we can use $a->user
847 $user = ($a->data['user']['nickname'] ? $a->data['user']['nickname'] : $a->user['nickname']);
850 // The permission testing is a little bit tricky because we have to respect many cases
852 // It's not the private events page (we don't get the $owner_uid for /events)
853 if (! local_user() && ! $owner_uid) {
858 * Cal logged in user (test permission at foreign profile page)
859 * If the $owner uid is available we know it is part of one of the profile pages (like /cal)
860 * So we have to test if if it's the own profile page of the logged in user
861 * or a foreign one. For foreign profile pages we need to check if the feature
862 * for exporting the cal is enabled (otherwise the widget would appear for logged in users
863 * on foreigen profile pages even if the widget is disabled)
865 if (intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar")) {
870 * If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and
871 * export feature isn't enabled
873 if (intval($owner_uid) && ! local_user() && ! feature_enabled($owner_uid, "export_calendar")) {
877 return replace_macros(get_markup_template("events_aside.tpl"), array(
878 '$etitle' => t("Export"),
879 '$export_ical' => t("Export calendar as ical"),
880 '$export_csv' => t("Export calendar as csv"),