edit.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. OCP\JSON::checkAppEnabled('calendar');
  10. $id = $_POST['id'];
  11. if(!array_key_exists('calendar', $_POST)){
  12. $cal = OC_Calendar_Object::getCalendarid($id);
  13. $_POST['calendar'] = $cal;
  14. }else{
  15. $cal = $_POST['calendar'];
  16. }
  17. $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
  18. if($access != 'owner' && $access != 'rw'){
  19. OCP\JSON::error(array('message'=>'permission denied'));
  20. exit;
  21. }
  22. $errarr = OC_Calendar_Object::validateRequest($_POST);
  23. if($errarr){
  24. //show validate errors
  25. OCP\JSON::error($errarr);
  26. exit;
  27. }else{
  28. $data = OC_Calendar_App::getEventObject($id, false, false);
  29. $vcalendar = OC_VObject::parse($data['calendardata']);
  30. OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']);
  31. OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
  32. OC_Calendar_Object::edit($id, $vcalendar->serialize());
  33. if ($data['calendarid'] != $cal) {
  34. OC_Calendar_Object::moveToCalendar($id, $cal);
  35. }
  36. OCP\JSON::success();
  37. }
  38. ?>