summaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax/share/unshare.php
diff options
context:
space:
mode:
authorGeorg Ehrke <ownclouddev@georgswebsite.de>2012-02-20 11:26:22 +0100
committerGeorg Ehrke <ownclouddev@georgswebsite.de>2012-02-20 11:26:22 +0100
commit8dff0fb58de75b05540782ea6b33b19f24be2f17 (patch)
treec0903eb362cb83abd617197679c8e4cbd69ee8a6 /apps/calendar/ajax/share/unshare.php
parentceb0016bdc4dae521717ed32986440b41fa9f71a (diff)
downloadnextcloud-server-8dff0fb58de75b05540782ea6b33b19f24be2f17.tar.gz
nextcloud-server-8dff0fb58de75b05540782ea6b33b19f24be2f17.zip
add moved files to clean up ajax folder
Diffstat (limited to 'apps/calendar/ajax/share/unshare.php')
-rw-r--r--apps/calendar/ajax/share/unshare.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php
new file mode 100644
index 00000000000..ec3150a89aa
--- /dev/null
+++ b/apps/calendar/ajax/share/unshare.php
@@ -0,0 +1,44 @@
+<?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']);
+$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' && !OC_User::userExists($sharewith)){
+ OC_JSON::error(array('message'=>'user not found'));
+ exit;
+}
+if($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));
+if($success){
+ OC_JSON::success();
+}else{
+ OC_JSON::error(array('message'=>'can not unshare'));
+ exit;
+} \ No newline at end of file