3 * @file include/event.php
4 * @brief functions specific to event handling
9 require_once 'include/bbcode.php';
10 require_once 'include/map.php';
11 require_once 'include/datetime.php';
13 function format_event_html($ev, $simple = false) {
15 if (! ((is_array($ev)) && count($ev))) {
19 $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
21 $event_start = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
22 $ev['start'] , $bd_format ))
23 : day_translate(datetime_convert('UTC', 'UTC',
24 $ev['start'] , $bd_format)));
26 $event_end = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
27 $ev['finish'] , $bd_format ))
28 : day_translate(datetime_convert('UTC', 'UTC',
29 $ev['finish'] , $bd_format )));
32 $o = "<h3>" . bbcode($ev['summary']) . "</h3>";
34 $o .= "<p>" . bbcode($ev['desc']) . "</p>";
36 $o .= "<h4>" . t('Starts:') . "</h4><p>" . $event_start . "</p>";
38 if (! $ev['nofinish']) {
39 $o .= "<h4>" . t('Finishes:') . "</h4><p>" . $event_end ."</p>";
42 if (strlen($ev['location'])) {
43 $o .= "<h4>" . t('Location:') . "</h4><p>" . $ev['location'] . "</p>";
49 $o = '<div class="vevent">' . "\r\n";
52 $o .= '<p class="summary event-summary">' . bbcode($ev['summary']) . '</p>' . "\r\n";
54 $o .= '<p class="description event-description">' . bbcode($ev['desc']) . '</p>' . "\r\n";
56 $o .= '<p class="event-start">' . t('Starts:') . ' <abbr class="dtstart" title="'
57 . datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
59 . '</abbr></p>' . "\r\n";
61 if (! $ev['nofinish']) {
62 $o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="'
63 . datetime_convert('UTC', 'UTC', $ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
65 . '</abbr></p>' . "\r\n";
68 if (strlen($ev['location'])) {
69 $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">'
70 . bbcode($ev['location'])
71 . '</span></p>' . "\r\n";
73 // Include a map of the location if the [map] BBCode is used
74 if (strpos($ev['location'], "[map") !== false) {
75 $map = generate_named_map($ev['location']);
76 if ($map !== $ev['location']) {
82 $o .= '</div>' . "\r\n";
86 function format_event_bbcode($ev) {
91 $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]';
95 $o .= '[event-description]' . $ev['desc'] . '[/event-description]';
99 $o .= '[event-start]' . $ev['start'] . '[/event-start]';
102 if (($ev['finish']) && (! $ev['nofinish'])) {
103 $o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
106 if ($ev['location']) {
107 $o .= '[event-location]' . $ev['location'] . '[/event-location]';
111 $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
117 function bbtovcal($s) {
122 $o = format_event_html($ev);
128 function bbtoevent($s) {
133 if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) {
134 $ev['summary'] = $match[1];
138 if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $s, $match)) {
139 $ev['desc'] = $match[1];
143 if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $s, $match)) {
144 $ev['start'] = $match[1];
148 if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $s, $match)) {
149 $ev['finish'] = $match[1];
153 if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $s, $match)) {
154 $ev['location'] = $match[1];
158 if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $s, $match)) {
159 $ev['adjust'] = $match[1];
162 $ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0);
168 function sort_by_date($a) {
170 usort($a,'ev_compare');
174 function ev_compare($a,$b) {
176 $date_a = (($a['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $a['start']) : $a['start']);
177 $date_b = (($b['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $b['start']) : $b['start']);
179 if ($date_a === $date_b) {
180 return strcasecmp($a['desc'], $b['desc']);
183 return strcmp($date_a, $date_b);
186 function event_delete($event_id) {
187 if ($event_id == 0) {
191 q("DELETE FROM `event` WHERE `id` = %d", intval($event_id));
192 logger("Deleted event ".$event_id, LOGGER_DEBUG);
195 function event_store($arr) {
197 require_once 'include/datetime.php';
198 require_once 'include/items.php';
199 require_once 'include/bbcode.php';
203 $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
204 $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
205 $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
206 $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
207 $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid']));
208 $arr['private'] = ((x($arr, 'private')) ? intval($arr['private']) : 0);
209 $arr['guid'] = get_guid(32);
212 $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
217 $c = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
222 if (dbm::is_result($c)) {
227 // Existing event being modified
231 // has the event actually changed?
233 $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
237 if ((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
239 // Nothing has changed. Grab the item id to return.
241 $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1",
245 return ((dbm::is_result($r)) ? $r[0]['id'] : 0);
248 // The event changed. Update it.
250 $r = q("UPDATE `event` SET
260 WHERE `id` = %d AND `uid` = %d",
262 dbesc($arr['edited']),
263 dbesc($arr['start']),
264 dbesc($arr['finish']),
265 dbesc($arr['summary']),
267 dbesc($arr['location']),
269 intval($arr['adjust']),
270 intval($arr['nofinish']),
274 $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1",
278 if (dbm::is_result($r)) {
279 $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
280 $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
281 $object .= '</object>' . "\n";
283 q("UPDATE `item` SET `body` = '%s', `object` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d",
284 dbesc(format_event_bbcode($arr)),
286 dbesc($arr['edited']),
291 $item_id = $r[0]['id'];
296 call_hooks("event_updated", $arr['id']);
301 // New event. Store it.
303 $r = q("INSERT INTO `event` (`uid`,`cid`,`guid`,`uri`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`,
304 `adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)
305 VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
310 dbesc($arr['created']),
311 dbesc($arr['edited']),
312 dbesc($arr['start']),
313 dbesc($arr['finish']),
314 dbesc($arr['summary']),
316 dbesc($arr['location']),
318 intval($arr['adjust']),
319 intval($arr['nofinish']),
320 dbesc($arr['allow_cid']),
321 dbesc($arr['allow_gid']),
322 dbesc($arr['deny_cid']),
323 dbesc($arr['deny_gid'])
327 $r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
331 if (dbm::is_result($r)) {
337 $item_arr['uid'] = $arr['uid'];
338 $item_arr['contact-id'] = $arr['cid'];
339 $item_arr['uri'] = $arr['uri'];
340 $item_arr['parent-uri'] = $arr['uri'];
341 $item_arr['guid'] = $arr['guid'];
342 $item_arr['type'] = 'activity';
343 $item_arr['wall'] = (($arr['cid']) ? 0 : 1);
344 $item_arr['contact-id'] = $contact['id'];
345 $item_arr['owner-name'] = $contact['name'];
346 $item_arr['owner-link'] = $contact['url'];
347 $item_arr['owner-avatar'] = $contact['thumb'];
348 $item_arr['author-name'] = $contact['name'];
349 $item_arr['author-link'] = $contact['url'];
350 $item_arr['author-avatar'] = $contact['thumb'];
351 $item_arr['title'] = '';
352 $item_arr['allow_cid'] = $arr['allow_cid'];
353 $item_arr['allow_gid'] = $arr['allow_gid'];
354 $item_arr['deny_cid'] = $arr['deny_cid'];
355 $item_arr['deny_gid'] = $arr['deny_gid'];
356 $item_arr['private'] = $arr['private'];
357 $item_arr['last-child'] = 1;
358 $item_arr['visible'] = 1;
359 $item_arr['verb'] = ACTIVITY_POST;
360 $item_arr['object-type'] = ACTIVITY_OBJ_EVENT;
361 $item_arr['origin'] = ((intval($arr['cid']) == 0) ? 1 : 0);
362 $item_arr['body'] = format_event_bbcode($event);
365 $item_arr['object'] = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
366 $item_arr['object'] .= '<content>' . xmlify(format_event_bbcode($event)) . '</content>';
367 $item_arr['object'] .= '</object>' . "\n";
369 $item_id = item_store($item_arr);
371 $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
374 //if (dbm::is_result($r))
375 // $plink = App::get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
379 //q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d",
381 // intval($event['id']),
382 // intval($arr['uid']),
385 q("UPDATE `item` SET `event-id` = %d WHERE `uid` = %d AND `id` = %d",
386 intval($event['id']),
392 call_hooks("event_created", $event['id']);
398 function get_event_strings() {
400 // First day of the week (0 = Sunday)
401 $firstDay = get_pconfig(local_user(), 'system', 'first_day_of_week');
402 if ($firstDay === false) {
407 "firstDay" => $firstDay,
408 "allday" => t("all-day"),
418 "Sunday" => t("Sunday"),
419 "Monday" => t("Monday"),
420 "Tuesday" => t("Tuesday"),
421 "Wednesday" => t("Wednesday"),
422 "Thursday" => t("Thursday"),
423 "Friday" => t("Friday"),
424 "Saturday" => t("Saturday"),
439 "January" => t("January"),
440 "February" => t("February"),
441 "March" => t("March"),
442 "April" => t("April"),
446 "August" => t("August"),
447 "September" => t("September"),
448 "October" => t("October"),
449 "November" => t("November"),
450 "December" => t("December"),
452 "today" => t("today"),
453 "month" => t("month"),
457 "noevent" => t("No events to display"),
459 "dtstart_label" => t("Starts:"),
460 "dtend_label" => t("Finishes:"),
461 "location_label" => t("Location:")
468 * @brief Removes duplicated birthday events
470 * @param array $dates Array of possibly duplicated events
471 * @return array Cleaned events
473 * @todo We should replace this with a separate update function if there is some time left
475 function event_remove_duplicates($dates) {
478 foreach ($dates AS $date) {
479 if ($date['type'] == 'birthday') {
480 $dates2[$date['uid'] . "-" . $date['cid'] . "-" . $date['start']] = $date;
489 * @brief Get an event by its event ID
491 * @param type $owner_uid The User ID of the owner of the event
492 * @param type $event_params An assoziative array with
493 * int 'event_id' => The ID of the event in the event table
494 * @param type $sql_extra
495 * @return array Query result
497 function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
498 // ownly allow events if there is a valid owner_id
499 if ($owner_uid == 0) {
503 // Query for the event by event id
504 $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
505 `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
506 LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
507 WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra",
509 intval($event_params["event_id"])
512 if (dbm::is_result($r)) {
513 return event_remove_duplicates($r);
518 * @brief Get all events in a specific timeframe
520 * @param int $owner_uid The User ID of the owner of the events
521 * @param array $event_params An assoziative array with
523 * string 'start' => Start time of the timeframe
524 * string 'finish' => Finish time of the timeframe
525 * string 'adjust_start' =>
526 * string 'adjust_start' =>
528 * @param string $sql_extra Additional sql conditions (e.g. permission request)
529 * @return array Query results
531 function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
532 // Only allow events if there is a valid owner_id
533 if ($owner_uid == 0) {
537 // Query for the event by date
538 $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
539 `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
540 LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
541 WHERE `event`.`uid` = %d AND event.ignore = %d
542 AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
543 OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s'))
546 intval($event_params["ignored"]),
547 dbesc($event_params["start"]),
548 dbesc($event_params["start"]),
549 dbesc($event_params["finish"]),
550 dbesc($event_params["adjust_start"]),
551 dbesc($event_params["adjust_start"]),
552 dbesc($event_params["adjust_finish"])
555 if (dbm::is_result($r)) {
556 return event_remove_duplicates($r);
561 * @brief Convert an array query results in an arry which could be used by the events template
563 * @param array $arr Event query array
564 * @return array Event array for the template
566 function process_events($arr) {
572 foreach ($arr as $rr) {
574 $j = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j'));
575 $d = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt));
576 $d = day_translate($d);
578 $start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'c') : datetime_convert('UTC', 'UTC', $rr['start'], 'c'));
579 if ($rr['nofinish']) {
582 $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['finish'], 'c') : datetime_convert('UTC', 'UTC', $rr['finish'], 'c'));
585 $is_first = ($d !== $last_date);
589 // Show edit and drop actions only if the user is the owner of the event and the event
590 // is a real event (no bithdays)
591 if (local_user() && local_user() == $rr['uid'] && $rr['type'] == 'event') {
592 $edit = ((! $rr['cid']) ? array(App::get_baseurl() . '/events/event/' . $rr['id'], t('Edit event'), '', '') : null);
593 $drop = array(App::get_baseurl() . '/events/drop/' . $rr['id'], t('Delete event'), '', '');
596 $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
598 list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
599 $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
602 $html = format_event_html($rr);
603 $rr['desc'] = bbcode($rr['desc']);
604 $rr['location'] = bbcode($rr['location']);
616 'is_first' => $is_first,
619 'plink' => array($rr['plink'], t('link to source'), '', ''),
628 * @brief Format event to export format (ical/csv)
630 * @param array $events Query result for events
631 * @param string $format The output format (ical/csv)
632 * @param string $timezone The timezone of the user (not implemented yet)
634 * @return string Content according to selected export format
636 function event_format_export ($events, $format = 'ical', $timezone) {
637 if (! ((is_array($events)) && count($events))) {
642 // Format the exported data as a CSV file
644 header("Content-type: text/csv");
645 $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
647 foreach ($events as $event) {
648 /// @todo The time / date entries don't include any information about the
649 /// timezone the event is scheduled in :-/
650 $tmp1 = strtotime($event['start']);
651 $tmp2 = strtotime($event['finish']);
652 $time_format = "%H:%M:%S";
653 $date_format = "%Y-%m-%d";
655 $o .= '"' . $event['summary'] . '", "' . strftime($date_format, $tmp1) .
656 '", "' . strftime($time_format, $tmp1) . '", "' . $event['desc'] .
657 '", "' . strftime($date_format, $tmp2) .
658 '", "' . strftime($time_format, $tmp2) .
659 '", "' . $event['location'] . '"' . PHP_EOL;
663 // Format the exported data as a ics file
665 header("Content-type: text/ics");
666 $o = 'BEGIN:VCALENDAR' . PHP_EOL
667 . 'VERSION:2.0' . PHP_EOL
668 . 'PRODID:-//friendica calendar export//0.1//EN' . PHP_EOL;
669 /// @todo include timezone informations in cases were the time is not in UTC
670 // see http://tools.ietf.org/html/rfc2445#section-4.8.3
671 // . 'BEGIN:VTIMEZONE' . PHP_EOL
672 // . 'TZID:' . $timezone . PHP_EOL
673 // . 'END:VTIMEZONE' . PHP_EOL;
674 // TODO instead of PHP_EOL CRLF should be used for long entries
675 // but test your solution against http://icalvalid.cloudapp.net/
676 // also long lines SHOULD be split at 75 characters length
677 foreach ($events as $event) {
679 if ($event['adjust'] == 1) {
684 $o .= 'BEGIN:VEVENT' . PHP_EOL;
686 if ($event['start']) {
687 $tmp = strtotime($event['start']);
688 $dtformat = "%Y%m%dT%H%M%S" . $UTC;
689 $o .= 'DTSTART:' . strftime($dtformat, $tmp) . PHP_EOL;
692 if (!$event['nofinish']) {
693 $tmp = strtotime($event['finish']);
694 $dtformat = "%Y%m%dT%H%M%S" . $UTC;
695 $o .= 'DTEND:' . strftime($dtformat, $tmp) . PHP_EOL;
698 if ($event['summary']) {
699 $tmp = $event['summary'];
700 $tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
701 $tmp = addcslashes($tmp, ',;');
702 $o .= 'SUMMARY:' . $tmp . PHP_EOL;
705 if ($event['desc']) {
706 $tmp = $event['desc'];
707 $tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
708 $tmp = addcslashes($tmp, ',;');
709 $o .= 'DESCRIPTION:' . $tmp . PHP_EOL;
712 if ($event['location']) {
713 $tmp = $event['location'];
714 $tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
715 $tmp = addcslashes($tmp, ',;');
716 $o .= 'LOCATION:' . $tmp . PHP_EOL;
719 $o .= 'END:VEVENT' . PHP_EOL;
723 $o .= 'END:VCALENDAR' . PHP_EOL;
731 * @brief Get all events for a user ID
733 * The query for events is done permission sensitive
734 * If the user is the owner of the calendar he/she
735 * will get all of his/her available events.
736 * If the user is only a visitor only the public events will
739 * @param int $uid The user ID
740 * @param int $sql_extra Additional sql conditions for permission
742 * @return array Query results
744 function events_by_uid($uid = 0, $sql_extra = '') {
749 // The permission condition if no condition was transmitted
750 if ($sql_extra == '') {
751 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' ";
754 // Does the user who requests happen to be the owner of the events
755 // requested? then show all of your events, otherwise only those that
756 // don't have limitations set in allow_cid and allow_gid
757 if (local_user() == $uid) {
758 $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`, `nofinish`
759 FROM `event` WHERE `uid`= %d AND `cid` = 0 ",
763 $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`, `nofinish`
764 FROM `event` WHERE `uid`= %d AND `cid` = 0 $sql_extra ",
769 if (dbm::is_result($r)) {
776 * @param int $uid The user ID
777 * @param string $format Output format (ical/csv)
778 * @return array With the results
779 * bool 'success' => True if the processing was successful
780 * string 'format' => The output format
781 * string 'extension' => The file extension of the output format
782 * string 'content' => The formatted output content
784 * @todo Respect authenticated users with events_by_uid()
786 function event_export($uid, $format = 'ical') {
790 // We are allowed to show events
791 // get the timezone the user is in
792 $r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
793 if (dbm::is_result($r)) {
794 $timezone = $r[0]['timezone'];
797 // Get all events which are owned by a uid (respects permissions);
798 $events = events_by_uid($uid);
800 // We have the events that are available for the requestor
801 // now format the output according to the requested format
802 if (count($events)) {
803 $res = event_format_export($events, $format, $timezone);
806 // If there are results the precess was successfull
811 // Get the file extension for the format
826 'success' => $process,
828 'extension' => $file_ext,
836 * @brief Get the events widget
838 * @return string Formated html of the evens widget
840 function widget_events() {
843 $owner_uid = $a->data['user']['uid'];
844 // $a->data is only available if the profile page is visited. If the visited page is not part
845 // of the profile page it should be the personal /events page. So we can use $a->user
846 $user = ($a->data['user']['nickname'] ? $a->data['user']['nickname'] : $a->user['nickname']);
849 // The permission testing is a little bit tricky because we have to respect many cases
851 // It's not the private events page (we don't get the $owner_uid for /events)
852 if (! local_user() && ! $owner_uid) {
856 // Cal logged in user (test permission at foreign profile page)
857 // If the $owner uid is available we know it is part of one of the profile pages (like /cal)
858 // So we have to test if if it's the own profile page of the logged in user
859 // or a foreign one. For foreign profile pages we need to check if the feature
860 // for exporting the cal is enabled (otherwise the widget would appear for logged in users
861 // on foreigen profile pages even if the widget is disabled)
862 if (intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar")) {
866 // If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and
867 // export feature isn't enabled
868 if (intval($owner_uid) && ! local_user() && ! feature_enabled($owner_uid, "export_calendar")) {
872 return replace_macros(get_markup_template("events_aside.tpl"), array(
873 '$etitle' => t("Export"),
874 '$export_ical' => t("Export calendar as ical"),
875 '$export_csv' => t("Export calendar as csv"),