export.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. OCP\User::checkLoggedIn();
  9. OCP\App::checkAppEnabled('calendar');
  10. $cal = isset($_GET['calid']) ? $_GET['calid'] : NULL;
  11. $event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL;
  12. $nl = "\r\n";
  13. if(isset($cal)){
  14. $calendar = OC_Calendar_App::getCalendar($cal, true);
  15. if(!$calendar){
  16. header('HTTP/1.0 404 Not Found');
  17. exit;
  18. }
  19. $calobjects = OC_Calendar_Object::all($cal);
  20. header('Content-Type: text/Calendar');
  21. header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics');
  22. foreach($calobjects as $calobject){
  23. echo $calobject['calendardata'] . $nl;
  24. }
  25. }elseif(isset($event)){
  26. $data = OC_Calendar_App::getEventObject($_GET['eventid'], true);
  27. if(!$data){
  28. header('HTTP/1.0 404 Not Found');
  29. exit;
  30. }
  31. $calendarid = $data['calendarid'];
  32. $calendar = OC_Calendar_App::getCalendar($calendarid);
  33. header('Content-Type: text/Calendar');
  34. header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics');
  35. echo $data['calendardata'];
  36. }
  37. ?>