]> source.dussan.org Git - nextcloud-server.git/commitdiff
added function to export single events
authorGeorg Ehrke <georg.stefan.germany@googlemail.com>
Sat, 1 Oct 2011 21:19:06 +0000 (23:19 +0200)
committerGeorg Ehrke <georg.stefan.germany@googlemail.com>
Sat, 1 Oct 2011 21:19:06 +0000 (23:19 +0200)
apps/calendar/export.php
apps/calendar/templates/part.editevent.php

index feb4755a3aa95c7fe8bc07eaa2059ebd442905a1..b3e5ecd6834f60bc813f4042d95431f625bcb0f9 100644 (file)
@@ -10,15 +10,29 @@ require_once ("../../lib/base.php");
 OC_Util::checkLoggedIn();
 OC_Util::checkAppEnabled('calendar');
 $cal = $_GET["calid"];
-$calendar = OC_Calendar_Calendar::findCalendar($cal);
-if($calendar["userid"] != OC_User::getUser()){
-       header( 'Location: '.OC_Helper::linkTo('', 'index.php'));
-       exit;
-}
-$calobjects = OC_Calendar_Object::all($cal);
-header("Content-Type: text/Calendar");
-header("Content-Disposition: inline; filename=calendar.ics"); 
-for($i = 0;$i <= count($calobjects); $i++){
-       echo $calobjects[$i]["calendardata"] . "\n";
+$event = $_GET["eventid"];
+if(isset($cal)){
+       $calendar = OC_Calendar_Calendar::findCalendar($cal);
+       if($calendar["userid"] != OC_User::getUser()){
+               OC_JSON::error();
+               exit;
+       }
+       $calobjects = OC_Calendar_Object::all($cal);
+       header("Content-Type: text/Calendar");
+       header("Content-Disposition: inline; filename=calendar.ics"); 
+       for($i = 0;$i <= count($calobjects); $i++){
+               echo $calobjects[$i]["calendardata"] . "\n";
+       }
+}elseif(isset($event)){
+       $data = OC_Calendar_Object::find($_GET["eventid"]);
+       $calendarid = $data["calendarid"];
+       $calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+       if($calendar["userid"] != OC_User::getUser()){
+               OC_JSON::error();
+               exit;
+       }
+       header("Content-Type: text/Calendar");
+       header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics"); 
+       echo $data["calendardata"];
 }
 ?>
index be637aeae550ce20766eaf97c7d0a8691ba09db8..ae969f2dc3b6d8658a659fa33eb298a10ba3bd63 100644 (file)
@@ -6,6 +6,7 @@
        <span id="actions">
                <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
                <input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.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'] ?>';">
        </span>
        </form>
 </div>