summaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax/share/unshare.php
blob: e5676c72f311943905a873e761ef4251178c21d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?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.
 */
 
$id = strip_tags($_GET['id']);
$idtype = strip_tags($_GET['idtype']);
switch($idtype){
	case 'calendar':
	case 'event':
		break;
	default:
		OC_JSON::error(array('message'=>'unexspected parameter'));
		exit;
}
$sharewith = $_GET['sharewith'];
$sharetype = strip_tags($_GET['sharetype']);
switch($sharetype){
	case 'user':
	case 'group':
	case 'public':
		break;
	default:
		OC_JSON::error(array('message'=>'unexspected parameter'));
		exit;
}
if($sharetype == 'user' && !OCP\User::userExists($sharewith)){
	OC_JSON::error(array('message'=>'user not found'));
	exit;
}elseif($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
	OC_JSON::error(array('message'=>'group not found'));
	exit;
}
$success = OC_Calendar_Share::unshare(OCP\USER::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::EVENT));
if($success){
	OC_JSON::success();
}else{
	OC_JSON::error(array('message'=>'can not unshare'));
	exit;
}