events.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright (c) 2011, 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. require_once('when/When.php');
  9. OCP\JSON::checkLoggedIn();
  10. OCP\JSON::checkAppEnabled('calendar');
  11. // Look for the calendar id
  12. $calendar_id = OC_Calendar_App::getCalendar($_GET['calendar_id'], false, false);
  13. if($calendar_id !== false){
  14. if(! is_numeric($calendar_id['userid']) && $calendar_id['userid'] != OCP\User::getUser()){
  15. OCP\JSON::error();
  16. exit;
  17. }
  18. }
  19. else {
  20. $calendar_id = $_GET['calendar_id'];
  21. }
  22. $start = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['start']):new DateTime('@' . $_GET['start']);
  23. $end = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['end']):new DateTime('@' . $_GET['end']);
  24. $events = OC_Calendar_App::getrequestedEvents($calendar_id, $start, $end);
  25. $output = array();
  26. foreach($events as $event){
  27. $output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
  28. }
  29. OCP\JSON::encodedPrint($output);