resize.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
  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\JSON::checkLoggedIn();
  9. $id = $_POST['id'];
  10. $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
  11. if($access != 'owner' && $access != 'rw'){
  12. OCP\JSON::error(array('message'=>'permission denied'));
  13. exit;
  14. }
  15. $vcalendar = OC_Calendar_App::getVCalendar($id, false, false);
  16. $vevent = $vcalendar->VEVENT;
  17. $delta = new DateInterval('P0D');
  18. $delta->d = $_POST['dayDelta'];
  19. $delta->i = $_POST['minuteDelta'];
  20. OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
  21. $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
  22. $end_type = $dtend->getDateType();
  23. $dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
  24. unset($vevent->DURATION);
  25. $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Property_DateTime::UTC);
  26. $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC);
  27. OC_Calendar_Object::edit($id, $vcalendar->serialize());
  28. $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
  29. OCP\JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));