From 64d3301523dce1032f7e20f03452573c125f8b17 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 10 Apr 2012 15:53:39 -0400 Subject: [PATCH] make shared events editable and add (empty) classes for alarm and attendees --- apps/calendar/ajax/event/edit.form.php | 1 + apps/calendar/ajax/event/edit.php | 12 +++++++++--- apps/calendar/ajax/event/move.php | 2 +- apps/calendar/ajax/event/resize.php | 4 ++-- apps/calendar/lib/alarm.php | 13 +++++++++++++ apps/calendar/lib/app.php | 4 ++-- apps/calendar/lib/attendees.php | 13 +++++++++++++ apps/calendar/lib/object.php | 9 +++++++-- apps/calendar/lib/share.php | 5 +++-- apps/calendar/templates/part.editevent.php | 4 ++-- apps/calendar/templates/part.eventform.php | 2 +- 11 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 apps/calendar/lib/alarm.php create mode 100644 apps/calendar/lib/attendees.php diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index a2e3fe6163f..6783462eaf1 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -15,6 +15,7 @@ OC_JSON::checkAppEnabled('calendar'); $id = $_GET['id']; $data = OC_Calendar_App::getEventObject($id, true, true); + if(!$data){ OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); exit; diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php index 8dd99b2b100..f65b67b84ac 100644 --- a/apps/calendar/ajax/event/edit.php +++ b/apps/calendar/ajax/event/edit.php @@ -12,6 +12,13 @@ OC_JSON::checkAppEnabled('calendar'); $id = $_POST['id']; +if(!array_key_exists('calendar', $_POST)){ + $cal = OC_Calendar_Object::getCalendarid($id); + $_POST['calendar'] = $cal; +}else{ + $cal = $_POST['calendar']; +} + $access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); if($access != 'owner' && $access != 'rw'){ OC_JSON::error(array('message'=>'permission denied')); @@ -24,14 +31,13 @@ if($errarr){ OC_JSON::error($errarr); exit; }else{ - $cal = $_POST['calendar']; - $data = OC_Calendar_App::getEventObject($id); + $data = OC_Calendar_App::getEventObject($id, false, false); $vcalendar = OC_VObject::parse($data['calendardata']); OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']); OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar); - $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); + OC_Calendar_Object::edit($id, $vcalendar->serialize()); if ($data['calendarid'] != $cal) { OC_Calendar_Object::moveToCalendar($id, $cal); } diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php index c6743e2354f..faf3a9c8f1c 100644 --- a/apps/calendar/ajax/event/move.php +++ b/apps/calendar/ajax/event/move.php @@ -14,7 +14,7 @@ if($access != 'owner' && $access != 'rw'){ OC_JSON::error(array('message'=>'permission denied')); exit; } -$vcalendar = OC_Calendar_App::getVCalendar($id); +$vcalendar = OC_Calendar_App::getVCalendar($id, false, false); $vevent = $vcalendar->VEVENT; $allday = $_POST['allDay']; diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php index a2ae83111b8..983a04f3bb8 100644 --- a/apps/calendar/ajax/event/resize.php +++ b/apps/calendar/ajax/event/resize.php @@ -16,7 +16,7 @@ if($access != 'owner' && $access != 'rw'){ exit; } -$vcalendar = OC_Calendar_App::getVCalendar($id); +$vcalendar = OC_Calendar_App::getVCalendar($id, false, false); $vevent = $vcalendar->VEVENT; $delta = new DateInterval('P0D'); @@ -33,6 +33,6 @@ unset($vevent->DURATION); $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); -$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); +OC_Calendar_Object::edit($id, $vcalendar->serialize()); $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/lib/alarm.php b/apps/calendar/lib/alarm.php new file mode 100644 index 00000000000..a71cc086827 --- /dev/null +++ b/apps/calendar/lib/alarm.php @@ -0,0 +1,13 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages reminders for calendars + */ +class OC_Calendar_Alarm{ + +} \ No newline at end of file diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 9febf389f50..58cc34658c6 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -80,8 +80,8 @@ class OC_Calendar_App{ * @param bool $security - check access rights or not * @return mixed - bool / object */ - public static function getVCalendar($id, $security = true){ - $event_object = self::getEventObject($id, $security); + public static function getVCalendar($id, $security = true, $shared = false){ + $event_object = self::getEventObject($id, $security, $shared); if($event_object === false){ return false; } diff --git a/apps/calendar/lib/attendees.php b/apps/calendar/lib/attendees.php new file mode 100644 index 00000000000..ac30e11b3be --- /dev/null +++ b/apps/calendar/lib/attendees.php @@ -0,0 +1,13 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages Attendees for calendars + */ +class OC_Calendar_Attendees{ + +} \ No newline at end of file diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 898b3910140..11123697e9a 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -451,8 +451,8 @@ class OC_Calendar_Object{ $errarr['title'] = 'true'; $errnum++; } - $calendar = OC_Calendar_Calendar::find($request['calendar']); - if($calendar['userid'] != OC_User::getUser()){ + $calendar = OC_Calendar_App::getCalendar($request['calendar'], true, true); + if(!$calendar){ $errarr['cal'] = 'true'; $errnum++; } @@ -816,4 +816,9 @@ class OC_Calendar_Object{ $cal = OC_Calendar_Calendar::find($event['calendarid']); return $cal['userid']; } + + public static function getCalendarid($id){ + $event = self::find($id); + return $event['calendarid']; + } } diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index f5acef92b6f..6a4e1a6f1cf 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -213,12 +213,13 @@ class OC_Calendar_Share{ $group_where = self::group_sql(OC_Group::getUserGroups($share)); $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ')'); $result = $stmt->execute(array($share)); - if($result->numRows() > 0){ + $rows = $result->numRows(); + if($rows > 0){ return true; } if($type == self::EVENT){ $event = OC_Calendar_App::getEventObject($id, false, false); - return self::is_editing_allowed($share, $event['calendarid'], self::CALENDAR); + return self::check_access($share, $event['calendarid'], self::CALENDAR); } return false; } diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index 6e319e1b4e0..58314db1a6b 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -1,13 +1,13 @@
">
- + inc("part.eventform"); ?>
" onclick="Calendar.UI.validateEventForm('ajax/event/edit.php');"> " onclick="Calendar.UI.submitDeleteEventForm('ajax/event/delete.php');"> - " onclick="window.location='export.php?eventid=';"> + " onclick="window.location='export.php?eventid=';">
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index e4bae3d4f81..36c741b3a39 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -44,7 +44,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid   - + -- 2.39.5