aboutsummaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/calendar/ajax')
-rw-r--r--apps/calendar/ajax/changeview.php4
-rw-r--r--apps/calendar/ajax/event/resize.php5
-rwxr-xr-xapps/calendar/ajax/events.php41
-rw-r--r--apps/calendar/ajax/share/unshare.php3
4 files changed, 27 insertions, 26 deletions
diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php
index ae48b229b16..76e29cbe265 100644
--- a/apps/calendar/ajax/changeview.php
+++ b/apps/calendar/ajax/changeview.php
@@ -1,12 +1,12 @@
<?php
/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
-require_once ("../../../lib/base.php");
+require_once ('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$view = $_GET['v'];
diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php
index aa2d420e77d..1136273b706 100644
--- a/apps/calendar/ajax/event/resize.php
+++ b/apps/calendar/ajax/event/resize.php
@@ -10,6 +10,11 @@ OC_JSON::checkLoggedIn();
$id = $_POST['id'];
+if(!OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT) && OC_Calendar_Object::getowner($id) != OC_User::getUser()){
+ OC_JSON::error(array('message'=>'permissiondenied'));
+ exit;
+}
+
$vcalendar = OC_Calendar_App::getVCalendar($id);
$vevent = $vcalendar->VEVENT;
diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
index 1436f634316..687b8e38d44 100755
--- a/apps/calendar/ajax/events.php
+++ b/apps/calendar/ajax/events.php
@@ -7,22 +7,7 @@
*/
require_once ('../../../lib/base.php');
-require_once('when/When.php');
-
-function create_return_event($event, $vevent){
- $return_event = array();
- $return_event['id'] = (int)$event['id'];
- $return_event['title'] = htmlspecialchars($event['summary']);
- $return_event['description'] = isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):'';
- $last_modified = $vevent->__get('LAST-MODIFIED');
- if ($last_modified){
- $lastmodified = $last_modified->getDateTime()->format('U');
- }else{
- $lastmodified = 0;
- }
- $return_event['lastmodified'] = (int)$lastmodified;
- return $return_event;
-}
+require_once('../../../3rdparty/when/When.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
@@ -30,9 +15,23 @@ OC_JSON::checkAppEnabled('calendar');
$start = DateTime::createFromFormat('U', $_GET['start']);
$end = DateTime::createFromFormat('U', $_GET['end']);
-$calendar = OC_Calendar_App::getCalendar($_GET['calendar_id']);
-OC_Response::enableCaching(0);
-OC_Response::setETagHeader($calendar['ctag']);
+if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){
+ $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r');
+ $events = array();
+ foreach($calendars as $calendar){
+ $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end);
+ $events = array_merge($events, $calendarevents);
+ }
+}else{
+ $calendar = OC_Calendar_Calendar::find($_GET['calendar_id']);
+ if($calendar['userid'] != OC_User::getUser()){
+ OC_JSON::error();
+ exit;
+ }
+ $events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
+ OC_Response::enableCaching(0);
+ OC_Response::setETagHeader($calendar['ctag']);
+}
$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
@@ -41,7 +40,7 @@ foreach($events as $event){
$object = OC_VObject::parse($event['calendardata']);
$vevent = $object->VEVENT;
- $return_event = create_return_event($event, $vevent);
+ $return_event = OC_Calendar_App::prepareForOutput($event, $vevent);
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
@@ -54,8 +53,6 @@ foreach($events as $event){
$start_dt->setTimezone(new DateTimeZone($user_timezone));
$end_dt->setTimezone(new DateTimeZone($user_timezone));
}
-
- //Repeating Events
if($event['repeating'] == 1){
$duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
$r = new When();
diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php
index ec3150a89aa..25a0ef48fcf 100644
--- a/apps/calendar/ajax/share/unshare.php
+++ b/apps/calendar/ajax/share/unshare.php
@@ -30,8 +30,7 @@ switch($sharetype){
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
OC_JSON::error(array('message'=>'user not found'));
exit;
-}
-if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
+}elseif($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
OC_JSON::error(array('message'=>'group not found'));
exit;
}