make shared events editable and add (empty) classes for alarm and attendees

This commit is contained in:
Georg Ehrke 2012-04-10 15:53:39 -04:00
parent eaa649cfb2
commit 64d3301523
11 changed files with 54 additions and 15 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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'];

View File

@ -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')));

View File

@ -0,0 +1,13 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* 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{
}

View File

@ -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;
}

View File

@ -0,0 +1,13 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* 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{
}

View File

@ -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'];
}
}

View File

@ -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;
}

View File

@ -1,13 +1,13 @@
<div id="event" title="<?php echo $l->t("Edit an event");?>">
<form id="event_form">
<input type="hidden" name="id" value="<?php echo $_['id'] ?>">
<input type="hidden" name="id" value="<?php echo $_['eventid'] ?>">
<input type="hidden" name="lastmodified" value="<?php echo $_['lastmodified'] ?>">
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
<span id="actions">
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/edit.php');">
<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/event/delete.php');">
<input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';">
<input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['eventid'] ?>';">
</span>
</form>
</div>

View File

@ -44,7 +44,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid
<?php } else { ?>
<th width="75px">&nbsp;</th>
<td>
<input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['eventid'] ?>">
<input type="hidden" name="calendar" value="<?php echo $_['calendar']; ?>">
</td>
<?php } ?>
</tr>