nextcloud/apps/calendar/ajax/share/unshare.php

51 lines
1.4 KiB
PHP
Raw Normal View History

<?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-06-09 16:40:15 +04:00
$id = strip_tags($_POST['id']);
$idtype = strip_tags($_POST['idtype']);
switch($idtype){
case 'calendar':
case 'event':
break;
default:
2012-05-03 14:23:29 +04:00
OCP\JSON::error(array('message'=>'unexspected parameter'));
exit;
}
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-06-09 16:40:15 +04:00
$sharewith = $_POST['sharewith'];
$sharetype = strip_tags($_POST['sharetype']);
switch($sharetype){
case 'user':
case 'group':
case 'public':
break;
default:
2012-05-03 14:23:29 +04:00
OCP\JSON::error(array('message'=>'unexspected parameter'));
exit;
}
if($sharetype == 'user' && !OCP\User::userExists($sharewith)){
2012-05-03 14:23:29 +04:00
OCP\JSON::error(array('message'=>'user not found'));
exit;
2012-02-18 00:19:04 +04:00
}elseif($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
2012-05-03 14:23:29 +04:00
OCP\JSON::error(array('message'=>'group not found'));
exit;
}
2012-05-01 20:50:31 +04:00
$success = OC_Calendar_Share::unshare(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT));
if($success){
2012-05-03 14:23:29 +04:00
OCP\JSON::success();
}else{
2012-05-03 14:23:29 +04:00
OCP\JSON::error(array('message'=>'can not unshare'));
exit;
}