]> source.dussan.org Git - nextcloud-server.git/commitdiff
make shared events editable and add (empty) classes for alarm and attendees
authorGeorg Ehrke <dev@georgswebsite.de>
Tue, 10 Apr 2012 19:53:39 +0000 (15:53 -0400)
committerGeorg Ehrke <dev@georgswebsite.de>
Tue, 10 Apr 2012 20:03:38 +0000 (16:03 -0400)
apps/calendar/ajax/event/edit.form.php
apps/calendar/ajax/event/edit.php
apps/calendar/ajax/event/move.php
apps/calendar/ajax/event/resize.php
apps/calendar/lib/alarm.php [new file with mode: 0644]
apps/calendar/lib/app.php
apps/calendar/lib/attendees.php [new file with mode: 0644]
apps/calendar/lib/object.php
apps/calendar/lib/share.php
apps/calendar/templates/part.editevent.php
apps/calendar/templates/part.eventform.php

index a2e3fe6163f9e60c92eef9f323a58a05c2cf5ea4..6783462eaf166aa04b0657a62ee2c3abbc82dbed 100644 (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;
index 8dd99b2b1000ba9f8fb0d3c724f721e2a4efc42f..f65b67b84ac0bcc0fa890163a286d188c7127a26 100644 (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);
        }
index c6743e2354fd37b0227911d865bee09b43e16dd4..faf3a9c8f1c11cecb679125e241f26388a7eb2f7 100644 (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'];
index a2ae83111b861b5b09d9c3e8f7eadc0c9fd2d656..983a04f3bb841aa5477ae2392201ba765636cc31 100644 (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')));
diff --git a/apps/calendar/lib/alarm.php b/apps/calendar/lib/alarm.php
new file mode 100644 (file)
index 0000000..a71cc08
--- /dev/null
@@ -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{
+       
+}
\ No newline at end of file
index 9febf389f50ed473cf81b8750d682fe7e6e69d55..58cc34658c67ebc1233331819e2accfd01289491 100644 (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;
                }
diff --git a/apps/calendar/lib/attendees.php b/apps/calendar/lib/attendees.php
new file mode 100644 (file)
index 0000000..ac30e11
--- /dev/null
@@ -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{
+       
+}
\ No newline at end of file
index 898b3910140db8c5d6715d1a08b73d333f6ee04d..11123697e9ae26573689acf65726aa52c46db45a 100644 (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'];
+       }
 }
index f5acef92b6f199925fab93b775ef5be811a97d72..6a4e1a6f1cfb9c600f8cc64337ca880a169877f8 100644 (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;
        }
index 6e319e1b4e0fe7b67607ef735f0219c8a39e63ea..58314db1a6bfddc0776959eea17d22bb00605c0e 100644 (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>
index e4bae3d4f817de35ac399db813282d81cfee902f..36c741b3a3967bb0ad19591060ba4405d1425b6c 100644 (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>