gettasks.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Copyright (c) 2011 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. // Init owncloud
  9. OCP\JSON::checkLoggedIn();
  10. OCP\JSON::checkAppEnabled('tasks');
  11. $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
  12. $user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
  13. $tasks = array();
  14. foreach( $calendars as $calendar ){
  15. $calendar_tasks = OC_Calendar_Object::all($calendar['id']);
  16. foreach( $calendar_tasks as $task ){
  17. if($task['objecttype']!='VTODO'){
  18. continue;
  19. }
  20. if(is_null($task['summary'])){
  21. continue;
  22. }
  23. $object = OC_VObject::parse($task['calendardata']);
  24. $vtodo = $object->VTODO;
  25. try {
  26. $tasks[] = OC_Task_App::arrayForJSON($task['id'], $vtodo, $user_timezone);
  27. } catch(Exception $e) {
  28. OCP\Util::writeLog('tasks', $e->getMessage(), OCP\Util::ERROR);
  29. }
  30. }
  31. }
  32. OCP\JSON::encodedPrint($tasks);