2012-02-20 10:26:22 +00:00
|
|
|
<?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.
|
|
|
|
*/
|
2012-04-17 17:31:29 +00:00
|
|
|
|
2012-02-20 10:26:22 +00:00
|
|
|
$id = strip_tags($_GET['id']);
|
|
|
|
$idtype = strip_tags($_GET['idtype']);
|
|
|
|
switch($idtype){
|
|
|
|
case 'calendar':
|
|
|
|
case 'event':
|
|
|
|
break;
|
|
|
|
default:
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::error(array('message'=>'unexspected parameter'));
|
2012-02-20 10:26:22 +00:00
|
|
|
exit;
|
|
|
|
}
|
2012-05-14 13:33:00 +00:00
|
|
|
if($idtype == 'calendar' && !OC_Calendar_App::getCalendar($id)){
|
|
|
|
OCP\JSON::error(array('message'=>'permission denied'));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if($idtype == 'event' && !OC_Calendar_App::getEventObject($id)){
|
|
|
|
OCP\JSON::error(array('message'=>'permission denied'));
|
|
|
|
exit;
|
|
|
|
}
|
2012-02-20 10:26:22 +00:00
|
|
|
$sharewith = $_GET['sharewith'];
|
|
|
|
$sharetype = strip_tags($_GET['sharetype']);
|
|
|
|
switch($sharetype){
|
|
|
|
case 'user':
|
|
|
|
case 'group':
|
|
|
|
case 'public':
|
|
|
|
break;
|
|
|
|
default:
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::error(array('message'=>'unexspected parameter'));
|
2012-02-20 10:26:22 +00:00
|
|
|
exit;
|
|
|
|
}
|
2012-05-01 17:04:20 +00:00
|
|
|
if($sharetype == 'user' && !OCP\User::userExists($sharewith)){
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::error(array('message'=>'user not found'));
|
2012-02-20 10:26:22 +00:00
|
|
|
exit;
|
2012-02-17 20:19:04 +00:00
|
|
|
}elseif($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::error(array('message'=>'group not found'));
|
2012-02-20 10:26:22 +00:00
|
|
|
exit;
|
|
|
|
}
|
2012-05-01 16:50:31 +00:00
|
|
|
$success = OC_Calendar_Share::unshare(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT));
|
2012-02-20 10:26:22 +00:00
|
|
|
if($success){
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::success();
|
2012-02-20 10:26:22 +00:00
|
|
|
}else{
|
2012-05-03 10:23:29 +00:00
|
|
|
OCP\JSON::error(array('message'=>'can not unshare'));
|
2012-02-20 10:26:22 +00:00
|
|
|
exit;
|
|
|
|
}
|