summaryrefslogtreecommitdiffstats
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/delete.php7
-rw-r--r--apps/calendar/ajax/event/edit.form.php26
-rw-r--r--apps/calendar/ajax/event/edit.php21
-rw-r--r--apps/calendar/ajax/event/move.php9
-rw-r--r--apps/calendar/ajax/event/new.form.php1
-rw-r--r--apps/calendar/ajax/event/resize.php10
-rwxr-xr-xapps/calendar/ajax/events.php98
-rw-r--r--apps/calendar/ajax/import/import.php134
-rw-r--r--apps/calendar/ajax/share/activation.php12
-rw-r--r--apps/calendar/ajax/share/changepermission.php2
-rw-r--r--apps/calendar/ajax/share/share.php10
-rw-r--r--apps/calendar/ajax/share/unshare.php5
13 files changed, 163 insertions, 176 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/delete.php b/apps/calendar/ajax/event/delete.php
index 5fc12900ef3..fd7b709393a 100644
--- a/apps/calendar/ajax/event/delete.php
+++ b/apps/calendar/ajax/event/delete.php
@@ -11,7 +11,10 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
-$event_object = OC_Calendar_App::getEventObject($id);
+$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
+if($access != 'owner' && $access != 'rw'){
+ OC_JSON::error(array('message'=>'permission denied'));
+ exit;
+}
$result = OC_Calendar_Object::delete($id);
OC_JSON::success();
-?>
diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php
index 7cbf3a87cfc..97b0907c839 100644
--- a/apps/calendar/ajax/event/edit.form.php
+++ b/apps/calendar/ajax/event/edit.form.php
@@ -14,7 +14,13 @@ if(!OC_USER::isLoggedIn()) {
OC_JSON::checkAppEnabled('calendar');
$id = $_GET['id'];
-$data = OC_Calendar_App::getEventObject($id);
+$data = OC_Calendar_App::getEventObject($id, true, true);
+
+if(!$data){
+ OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar'))));
+ exit;
+}
+$access = OC_Calendar_App::getaccess($id, OC_Calendar_Share::EVENT);
$object = OC_VObject::parse($data['calendardata']);
$vevent = $object->VEVENT;
@@ -182,8 +188,12 @@ if($data['repeating'] == 1){
}else{
$repeat['repeat'] = 'doesnotrepeat';
}
-
-$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+if($access == 'owner'){
+ $calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+}else{
+ $calendar_options = array(OC_Calendar_App::getCalendar($data['calendarid'], false));
+}
+$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
$repeat_end_options = OC_Calendar_App::getEndOptions();
$repeat_month_options = OC_Calendar_App::getMonthOptions();
@@ -195,8 +205,14 @@ $repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
-$tmpl = new OC_Template('calendar', 'part.editevent');
-$tmpl->assign('id', $id);
+if($access == 'owner' || $access == 'rw'){
+ $tmpl = new OC_Template('calendar', 'part.editevent');
+}elseif($access == 'r'){
+ $tmpl = new OC_Template('calendar', 'part.showevent');
+}
+
+$tmpl->assign('eventid', $id);
+$tmpl->assign('access', $access);
$tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('repeat_options', $repeat_options);
diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php
index 64daffddef0..f65b67b84ac 100644
--- a/apps/calendar/ajax/event/edit.php
+++ b/apps/calendar/ajax/event/edit.php
@@ -10,21 +10,34 @@ require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
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'));
+ exit;
+}
+
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){
//show validate errors
OC_JSON::error($errarr);
exit;
}else{
- $id = $_POST['id'];
- $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 37420e2a876..63995602de2 100644
--- a/apps/calendar/ajax/event/move.php
+++ b/apps/calendar/ajax/event/move.php
@@ -9,15 +9,18 @@ require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$id = $_POST['id'];
-
-$vcalendar = OC_Calendar_App::getVCalendar($id);
+$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
+if($access != 'owner' && $access != 'rw'){
+ OC_JSON::error(array('message'=>'permission denied'));
+ exit;
+}
+$vcalendar = OC_Calendar_App::getVCalendar($id, false, false);
$vevent = $vcalendar->VEVENT;
$allday = $_POST['allDay'];
$delta = new DateInterval('P0D');
$delta->d = $_POST['dayDelta'];
$delta->i = $_POST['minuteDelta'];
-
OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
$dtstart = $vevent->DTSTART;
diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php
index 838002a3a09..91b95546569 100644
--- a/apps/calendar/ajax/event/new.form.php
+++ b/apps/calendar/ajax/event/new.form.php
@@ -44,6 +44,7 @@ $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
+$tmpl->assign('access', 'owner');
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('repeat_options', $repeat_options);
$tmpl->assign('repeat_month_options', $repeat_month_options);
diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php
index a8d8f49ae0a..75d6e0b2547 100644
--- a/apps/calendar/ajax/event/resize.php
+++ b/apps/calendar/ajax/event/resize.php
@@ -10,7 +10,13 @@ OC_JSON::checkLoggedIn();
$id = $_POST['id'];
-$vcalendar = OC_Calendar_App::getVCalendar($id);
+$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
+if($access != 'owner' && $access != 'rw'){
+ OC_JSON::error(array('message'=>'permission denied'));
+ exit;
+}
+
+$vcalendar = OC_Calendar_App::getVCalendar($id, false, false);
$vevent = $vcalendar->VEVENT;
$delta = new DateInterval('P0D');
@@ -27,6 +33,6 @@ unset($vevent->DURATION);
$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Property_DateTime::UTC);
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_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/ajax/events.php b/apps/calendar/ajax/events.php
index 76dd1b4974e..5b3d26b53b7 100755
--- a/apps/calendar/ajax/events.php
+++ b/apps/calendar/ajax/events.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * Copyright (c) 2011, 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.
@@ -8,102 +8,18 @@
require_once ('../../../lib/base.php');
require_once('when/When.php');
-$l = OC_L10N::get('calendar');
-$unnamed = $l->t('unnamed');
-function create_return_event($event, $vevent){
- $return_event = array();
- global $unnamed;
- $return_event['id'] = (int)$event['id'];
- $return_event['title'] = htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: $unnamed);
- $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;
-}
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
-if(version_compare(PHP_VERSION, '5.3.0', '>=')){
- $start = DateTime::createFromFormat('U', $_GET['start']);
- $end = DateTime::createFromFormat('U', $_GET['end']);
-}else{
- $start = new DateTime('@' . $_GET['start']);
- $end = new DateTime('@' . $_GET['end']);
-}
+$start = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['start']):new DateTime('@' . $_GET['start']);
+$end = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['end']):new DateTime('@' . $_GET['end']);
-$calendar_id = $_GET['calendar_id'];
-if (is_numeric($calendar_id)) {
- $calendar = OC_Calendar_App::getCalendar($calendar_id);
- OC_Response::enableCaching(0);
- OC_Response::setETagHeader($calendar['ctag']);
- $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end);
-} else {
- $events = array();
- OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events));
-}
+$events = OC_Calendar_App::getrequestedEvents($_GET['calendar_id'], $start, $end);
-$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
-$return = array();
+$output = array();
foreach($events as $event){
- if (isset($event['calendardata'])) {
- $object = OC_VObject::parse($event['calendardata']);
- $vevent = $object->VEVENT;
- } else {
- $vevent = $event['vevent'];
- }
-
- $return_event = create_return_event($event, $vevent);
-
- $dtstart = $vevent->DTSTART;
- $start_dt = $dtstart->getDateTime();
- $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
- $end_dt = $dtend->getDateTime();
- if ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE){
- $return_event['allDay'] = true;
- }else{
- $return_event['allDay'] = false;
- $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();
- $r->recur($start_dt)->rrule((string) $vevent->RRULE);
- while($result = $r->next()){
- if($result < $start){
- continue;
- }
- if($result > $end){
- break;
- }
- if($return_event['allDay'] == true){
- $return_event['start'] = $result->format('Y-m-d');
- $return_event['end'] = date('Y-m-d', $result->format('U') + --$duration);
- }else{
- $return_event['start'] = $result->format('Y-m-d H:i:s');
- $return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration);
- }
- $return[] = $return_event;
- }
- }else{
- if($return_event['allDay'] == true){
- $return_event['start'] = $start_dt->format('Y-m-d');
- $end_dt->modify('-1 sec');
- $return_event['end'] = $end_dt->format('Y-m-d');
- }else{
- $return_event['start'] = $start_dt->format('Y-m-d H:i:s');
- $return_event['end'] = $end_dt->format('Y-m-d H:i:s');
- }
- $return[] = $return_event;
- }
+ $output[] = OC_Calendar_App::generateEventOutput($event, $start, $end);
}
-OC_JSON::encodedPrint($return);
+OC_JSON::encodedPrint($output);
?>
diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php
index d0bdab4f0d5..4d5e7340aef 100644
--- a/apps/calendar/ajax/import/import.php
+++ b/apps/calendar/ajax/import/import.php
@@ -7,11 +7,12 @@
*/
//check for calendar rights or create new one
ob_start();
-require_once('../../../../lib/base.php');
+require_once ('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
-$nl = "\n\r";
-$progressfile = OC::$APPSROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
+$nl="\r\n";
+$comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true);
+$progressfile = 'import_tmp/' . md5(session_id()) . '.txt';
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '10');
@@ -29,85 +30,94 @@ if($_POST['method'] == 'new'){
}
$id = $_POST['id'];
}
-//analyse the calendar file
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '20');
fclose($progressfopen);
}
-$searchfor = array('VEVENT', 'VTODO', 'VJOURNAL');
-$parts = $searchfor;
-$filearr = explode($nl, $file);
-$inelement = false;
-$parts = array();
+// normalize the newlines
+$file = str_replace(array("\r","\n\n"), array("\n","\n"), $file);
+$lines = explode("\n", $file);
+unset($file);
+if(is_writable('import_tmp/')){
+ $progressfopen = fopen($progressfile, 'w');
+ fwrite($progressfopen, '30');
+ fclose($progressfopen);
+}
+// analyze the file, group components by uid, and keep refs to originating calendar object
+// $cals is array calendar objects, keys are 1st line# $cal, ie array( $cal => $caldata )
+// $caldata is array( 'first' => 1st component line#, 'last' => last comp line#, 'end' => end line# )
+// $caldata is used to create prefix/suffix strings when building import text
+// $uids is array of component arrays, keys are $uid, ie array( $uid => array( $beginlineno => $component ) )
+// $component is array( 'end' => end line#, 'cal'=> $cal )
+$comp=$uid=$cal=false;
+$cals=$uids=array();
$i = 0;
-foreach($filearr as $line){
- foreach($searchfor as $search){
- if(substr_count($line, $search) == 1){
- list($attr, $val) = explode(':', $line);
- if($attr == 'BEGIN'){
- $parts[]['begin'] = $i;
- $inelement = true;
+foreach($lines as $line) {
+
+ if(strpos($line, ':')!==false) {
+ list($attr, $val) = explode(':', strtoupper($line));
+ if ($attr == 'BEGIN' && $val == 'VCALENDAR') {
+ $cal = $i;
+ $cals[$cal] = array('first'=>$i,'last'=>$i,'end'=>$i);
+ } elseif ($attr =='BEGIN' && $cal!==false && isset($comps[$val])) {
+ $comp = $val;
+ $beginNo = $i;
+ } elseif ($attr == 'END' && $cal!==false && $val == 'VCALENDAR') {
+ if($comp!==false) {
+ unset($cals[$cal]); // corrupt calendar, unset it
+ } else {
+ $cals[$cal]['end'] = $i;
+ }
+ $comp=$uid=$cal=false; // reset calendar
+ } elseif ($attr == 'END' && $comp!==false && $val == $comp) {
+ if(! $uid) {
+ $uid = OC_Calendar_Object::createUID();
}
- if($attr == 'END'){
- $parts[count($parts) - 1]['end'] = $i;
- $inelement = false;
+ $uids[$uid][$beginNo] = array('end'=>$i, 'cal'=>$cal);
+ if ($cals[$cal]['first'] == $cal) {
+ $cals[$cal]['first'] = $beginNo;
}
+ $cals[$cal]['last'] = $i;
+ $comp=$uid=false; // reset component
+ } elseif ($attr =="UID" && $comp!==false) {
+ list($attr, $uid) = explode(':', $line);
}
}
$i++;
}
-//import the calendar
+// import the calendar
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
- fwrite($progressfopen, '40');
+ fwrite($progressfopen, '60');
fclose($progressfopen);
}
-$start = '';
-for ($i = 0; $i < $parts[0]['begin']; $i++) {
- if($i == 0){
- $start = $filearr[0];
- }else{
- $start .= $nl . $filearr[$i];
- }
-}
-$end = '';
-for($i = $parts[count($parts) - 1]['end'] + 1;$i <= count($filearr) - 1; $i++){
- if($i == $parts[count($parts) - 1]['end'] + 1){
- $end = $filearr[$parts[count($parts) - 1]['end'] + 1];
- }else{
- $end .= $nl . $filearr[$i];
- }
-}
-if(is_writable('import_tmp/')){
- $progressfopen = fopen($progressfile, 'w');
- fwrite($progressfopen, '50');
- fclose($progressfopen);
-}
-$importready = array();
-foreach($parts as $part){
- for($i = $part['begin']; $i <= $part['end'];$i++){
- if($i == $part['begin']){
- $content = $filearr[$i];
- }else{
- $content .= $nl . $filearr[$i];
+foreach($uids as $uid) {
+
+ $prefix=$suffix=$content=array();
+ foreach($uid as $begin=>$details) {
+
+ $cal = $details['cal'];
+ if(!isset($cals[$cal])) {
+ continue; // from corrupt/incomplete calendar
+ }
+ $cdata = $cals[$cal];
+ // if we have multiple components from different calendar objects,
+ // we should really merge their elements (enhancement?) -- 1st one wins for now.
+ if(! count($prefix)) {
+ $prefix = array_slice($lines, $cal, $cdata['first'] - $cal);
}
+ if(! count($suffix)) {
+ $suffix = array_slice($lines, $cdata['last']+1, $cdata['end'] - $cdata['last']);
+ }
+ $content = array_merge($content, array_slice($lines, $begin, $details['end'] - $begin + 1));
}
- $importready[] = $start . $nl . $content . $nl . $end;
-}
-if(is_writable('import_tmp/')){
- $progressfopen = fopen($progressfile, 'w');
- fwrite($progressfopen, '70');
- fclose($progressfopen);
-}
-if(count($parts) == 1){
- OC_Calendar_Object::add($id, $file);
-}else{
- foreach($importready as $import){
+ if(count($content)) {
+ $import = join($nl, array_merge($prefix, $content, $suffix)) . $nl;
OC_Calendar_Object::add($id, $import);
}
}
-//done the import
+// finished import
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '100');
@@ -117,4 +127,4 @@ sleep(3);
if(is_writable('import_tmp/')){
unlink($progressfile);
}
-OC_JSON::success();
+OC_JSON::success(); \ No newline at end of file
diff --git a/apps/calendar/ajax/share/activation.php b/apps/calendar/ajax/share/activation.php
new file mode 100644
index 00000000000..a4a3ce48192
--- /dev/null
+++ b/apps/calendar/ajax/share/activation.php
@@ -0,0 +1,12 @@
+<?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.
+ */
+require_once('../../../../lib/base.php');
+$id = strip_tags($_GET['id']);
+$activation = strip_tags($_GET['activation']);
+OC_Calendar_Share::set_active(OC_User::getUser(), $id, $activation);
+OC_JSON::success(); \ No newline at end of file
diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php
index d91f87b613f..41d49e7b521 100644
--- a/apps/calendar/ajax/share/changepermission.php
+++ b/apps/calendar/ajax/share/changepermission.php
@@ -36,5 +36,5 @@ if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
OC_JSON::error(array('message'=>'group not found'));
exit;
}
-$success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
+$success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT));
OC_JSON::success(); \ No newline at end of file
diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php
index d892727701a..2e81040b477 100644
--- a/apps/calendar/ajax/share/share.php
+++ b/apps/calendar/ajax/share/share.php
@@ -16,6 +16,14 @@ switch($idtype){
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
+if($idtype == 'calendar' && !OC_Calendar_App::getCalendar($id)){
+ OC_JSON::error(array('message'=>'permission denied'));
+ exit;
+}
+if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){
+ OC_JSON::error(array('message'=>'permission denied'));
+ exit;
+}
$sharewith = $_GET['sharewith'];
$sharetype = strip_tags($_GET['sharetype']);
switch($sharetype){
@@ -38,7 +46,7 @@ if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
if($sharetype == 'user' && OC_User::getUser() == $sharewith){
OC_JSON::error(array('meesage'=>'you can not share with yourself'));
}
-$success = OC_Calendar_Share::share(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
+$success = OC_Calendar_Share::share(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT));
if($success){
if($sharetype == 'public'){
OC_JSON::success(array('message'=>$success));
diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php
index ec3150a89aa..5bedbaaf0a6 100644
--- a/apps/calendar/ajax/share/unshare.php
+++ b/apps/calendar/ajax/share/unshare.php
@@ -30,12 +30,11 @@ 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;
}
-$success = OC_Calendar_Share::unshare(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
+$success = OC_Calendar_Share::unshare(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT));
if($success){
OC_JSON::success();
}else{