summaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/calendar/ajax')
-rw-r--r--apps/calendar/ajax/calendar/activation.php (renamed from apps/calendar/ajax/activation.php)2
-rw-r--r--apps/calendar/ajax/calendar/delete.php (renamed from apps/calendar/ajax/deletecalendar.php)2
-rw-r--r--apps/calendar/ajax/calendar/edit.form.php (renamed from apps/calendar/ajax/editcalendar.php)2
-rw-r--r--apps/calendar/ajax/calendar/edit.php20
-rw-r--r--apps/calendar/ajax/calendar/new.form.php (renamed from apps/calendar/ajax/newcalendar.php)2
-rw-r--r--apps/calendar/ajax/calendar/new.php (renamed from apps/calendar/ajax/createcalendar.php)2
-rw-r--r--apps/calendar/ajax/calendar/overview.php (renamed from apps/calendar/ajax/choosecalendar.php)2
-rw-r--r--apps/calendar/ajax/calendar/update.php (renamed from apps/calendar/ajax/updatecalendar.php)12
-rw-r--r--apps/calendar/ajax/changeview.php13
-rw-r--r--apps/calendar/ajax/event/delete.php (renamed from apps/calendar/ajax/deleteevent.php)2
-rw-r--r--apps/calendar/ajax/event/edit.form.php (renamed from apps/calendar/ajax/editeventform.php)14
-rw-r--r--apps/calendar/ajax/event/edit.php (renamed from apps/calendar/ajax/editevent.php)2
-rw-r--r--apps/calendar/ajax/event/move.php (renamed from apps/calendar/ajax/moveevent.php)2
-rw-r--r--apps/calendar/ajax/event/new.form.php (renamed from apps/calendar/ajax/neweventform.php)2
-rw-r--r--apps/calendar/ajax/event/new.php (renamed from apps/calendar/ajax/newevent.php)2
-rw-r--r--apps/calendar/ajax/event/resize.php (renamed from apps/calendar/ajax/resizeevent.php)2
-rwxr-xr-xapps/calendar/ajax/events.php2
-rw-r--r--apps/calendar/ajax/import/dialog.php (renamed from apps/calendar/ajax/importdialog.php)2
-rw-r--r--apps/calendar/ajax/import/import.php120
-rw-r--r--apps/calendar/ajax/settings/gettimezonedetection.php (renamed from apps/calendar/ajax/gettimezonedetection.php)2
-rwxr-xr-xapps/calendar/ajax/settings/guesstimezone.php (renamed from apps/calendar/ajax/guesstimezone.php)2
-rw-r--r--apps/calendar/ajax/settings/settimeformat.php (renamed from apps/calendar/ajax/settimeformat.php)2
-rw-r--r--apps/calendar/ajax/settings/settimezone.php (renamed from apps/calendar/ajax/settimezone.php)2
-rw-r--r--apps/calendar/ajax/settings/timeformat.php (renamed from apps/calendar/ajax/timeformat.php)2
-rw-r--r--apps/calendar/ajax/settings/timezonedetection.php (renamed from apps/calendar/ajax/timezonedetection.php)2
-rw-r--r--apps/calendar/ajax/share/changepermission.php40
-rw-r--r--apps/calendar/ajax/share/dropdown.php18
-rw-r--r--apps/calendar/ajax/share/share.php51
-rw-r--r--apps/calendar/ajax/share/unshare.php44
29 files changed, 328 insertions, 44 deletions
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/calendar/activation.php
index ada2e44547b..7677d85aff3 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/calendar/activation.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once ("../../../lib/base.php");
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/calendar/delete.php
index 901cbbfcb08..a2f5311731c 100644
--- a/apps/calendar/ajax/deletecalendar.php
+++ b/apps/calendar/ajax/calendar/delete.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/calendar/edit.form.php
index 7aeb5bbe305..8922b3eba4e 100644
--- a/apps/calendar/ajax/editcalendar.php
+++ b/apps/calendar/ajax/calendar/edit.form.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
diff --git a/apps/calendar/ajax/calendar/edit.php b/apps/calendar/ajax/calendar/edit.php
new file mode 100644
index 00000000000..8922b3eba4e
--- /dev/null
+++ b/apps/calendar/ajax/calendar/edit.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+require_once('../../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+
+$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
+$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
+$tmpl = new OC_Template("calendar", "part.editcalendar");
+$tmpl->assign('new', false);
+$tmpl->assign('calendarcolor_options', $calendarcolor_options);
+$tmpl->assign('calendar', $calendar);
+$tmpl->printPage();
+?>
diff --git a/apps/calendar/ajax/newcalendar.php b/apps/calendar/ajax/calendar/new.form.php
index af3ba4fbbea..6e7423cbe92 100644
--- a/apps/calendar/ajax/newcalendar.php
+++ b/apps/calendar/ajax/calendar/new.form.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/calendar/new.php
index 8d7b12f9b89..228e6247724 100644
--- a/apps/calendar/ajax/createcalendar.php
+++ b/apps/calendar/ajax/calendar/new.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
diff --git a/apps/calendar/ajax/choosecalendar.php b/apps/calendar/ajax/calendar/overview.php
index 9281c8edbdc..2f73f5d0710 100644
--- a/apps/calendar/ajax/choosecalendar.php
+++ b/apps/calendar/ajax/calendar/overview.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/calendar/update.php
index 20c225d8a29..f400c8c14b4 100644
--- a/apps/calendar/ajax/updatecalendar.php
+++ b/apps/calendar/ajax/calendar/update.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
@@ -25,16 +25,8 @@ foreach($calendars as $cal){
}
$calendarid = $_POST['id'];
-$calendarcolor = $_POST['color'];
-if (preg_match('/^#?([0-9a-f]{6})/', $calendarcolor, $matches)) {
- $calendarcolor = '#'.$matches[1];
-}
-else {
- $calendarcolor = null;
-}
-
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
-OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $calendarcolor);
+OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$calendar = OC_Calendar_App::getCalendar($calendarid);
diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php
index ef05c7cd496..ae48b229b16 100644
--- a/apps/calendar/ajax/changeview.php
+++ b/apps/calendar/ajax/changeview.php
@@ -9,7 +9,16 @@
require_once ("../../../lib/base.php");
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
-$currentview = $_GET["v"];
-OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
+$view = $_GET['v'];
+switch($view){
+ case 'agendaWeek':
+ case 'month';
+ case 'list':
+ break;
+ default:
+ OC_JSON::error(array('message'=>'unexspected parameter: ' . $view));
+ exit;
+}
+OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $view);
OC_JSON::success();
?>
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/event/delete.php
index b25a5af1a29..862dec6bf5b 100644
--- a/apps/calendar/ajax/deleteevent.php
+++ b/apps/calendar/ajax/event/delete.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/event/edit.form.php
index 19f6a80a167..837edbbbf05 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/event/edit.form.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
@@ -243,16 +243,6 @@ if($repeat['repeat'] != 'doesnotrepeat'){
$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
}
-else {
- $tmpl->assign('repeat_month', 'monthday');
- $tmpl->assign('repeat_weekdays', array());
- $tmpl->assign('repeat_interval', 1);
- $tmpl->assign('repeat_end', 'never');
- $tmpl->assign('repeat_count', '10');
- $tmpl->assign('repeat_weekofmonth', 'auto');
- $tmpl->assign('repeat_date', '');
- $tmpl->assign('repeat_year', 'bydate');
-}
$tmpl->printpage();
-?>
+?> \ No newline at end of file
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/event/edit.php
index 5a487da1758..64daffddef0 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/event/edit.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/event/move.php
index f2256d4eee6..8150fdbaa32 100644
--- a/apps/calendar/ajax/moveevent.php
+++ b/apps/calendar/ajax/event/move.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$id = $_POST['id'];
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/event/new.form.php
index 3870c879b0e..c19928a727e 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/event/new.form.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/event/new.php
index c7c4d29943a..59fda79da73 100644
--- a/apps/calendar/ajax/newevent.php
+++ b/apps/calendar/ajax/event/new.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/event/resize.php
index 68347906529..aa2d420e77d 100644
--- a/apps/calendar/ajax/resizeevent.php
+++ b/apps/calendar/ajax/event/resize.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$id = $_POST['id'];
diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
index 7734129bd95..1436f634316 100755
--- a/apps/calendar/ajax/events.php
+++ b/apps/calendar/ajax/events.php
@@ -7,7 +7,7 @@
*/
require_once ('../../../lib/base.php');
-require_once('../../../3rdparty/when/When.php');
+require_once('when/When.php');
function create_return_event($event, $vevent){
$return_event = array();
diff --git a/apps/calendar/ajax/importdialog.php b/apps/calendar/ajax/import/dialog.php
index f6b8453fc22..2e002092150 100644
--- a/apps/calendar/ajax/importdialog.php
+++ b/apps/calendar/ajax/import/dialog.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
$l10n = new OC_L10N('calendar');
diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php
new file mode 100644
index 00000000000..96d7af48341
--- /dev/null
+++ b/apps/calendar/ajax/import/import.php
@@ -0,0 +1,120 @@
+<?php
+/**
+ * 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.
+ */
+//check for calendar rights or create new one
+ob_start();
+require_once('../../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_Util::checkAppEnabled('calendar');
+$nl = "\n";
+$progressfile = OC::$SERVERROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
+if(is_writable('import_tmp/')){
+ $progressfopen = fopen($progressfile, 'w');
+ fwrite($progressfopen, '10');
+ fclose($progressfopen);
+}
+$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
+if($_POST['method'] == 'new'){
+ $id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']);
+ OC_Calendar_Calendar::setCalendarActive($id, 1);
+}else{
+ $calendar = OC_Calendar_App::getCalendar($_POST['id']);
+ if($calendar['userid'] != OC_USER::getUser()){
+ OC_JSON::error();
+ exit();
+ }
+ $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();
+$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;
+ }
+ if($attr == 'END'){
+ $parts[count($parts) - 1]['end'] = $i;
+ $inelement = false;
+ }
+ }
+ }
+ $i++;
+}
+//import the calendar
+if(is_writable('import_tmp/')){
+ $progressfopen = fopen($progressfile, 'w');
+ fwrite($progressfopen, '40');
+ 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];
+ }
+ }
+ $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){
+ OC_Calendar_Object::add($id, $import);
+ }
+}
+//done the import
+if(is_writable('import_tmp/')){
+ $progressfopen = fopen($progressfile, 'w');
+ fwrite($progressfopen, '100');
+ fclose($progressfopen);
+}
+sleep(3);
+if(is_writable('import_tmp/')){
+ unlink($progressfile);
+}
+OC_JSON::success(); \ No newline at end of file
diff --git a/apps/calendar/ajax/gettimezonedetection.php b/apps/calendar/ajax/settings/gettimezonedetection.php
index ae58370712d..11255fe8ef3 100644
--- a/apps/calendar/ajax/gettimezonedetection.php
+++ b/apps/calendar/ajax/settings/gettimezonedetection.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once ("../../../lib/base.php");
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection'))); \ No newline at end of file
diff --git a/apps/calendar/ajax/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php
index 41aea26985f..cfa92e1aee8 100755
--- a/apps/calendar/ajax/guesstimezone.php
+++ b/apps/calendar/ajax/settings/guesstimezone.php
@@ -18,7 +18,7 @@ function make_array_out_of_xml ($xml){
}
return $returnarray;
}
-require_once ("../../../lib/base.php");
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$l = new OC_L10N('calendar');
diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php
index 7805120ba5e..8f65447065c 100644
--- a/apps/calendar/ajax/settimeformat.php
+++ b/apps/calendar/ajax/settings/settimeformat.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
if(isset($_POST["timeformat"])){
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settings/settimezone.php
index c726a11471d..c639753fe2f 100644
--- a/apps/calendar/ajax/settimezone.php
+++ b/apps/calendar/ajax/settings/settimezone.php
@@ -7,7 +7,7 @@
*/
// Init owncloud
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
$l=new OC_L10N('calendar');
diff --git a/apps/calendar/ajax/timeformat.php b/apps/calendar/ajax/settings/timeformat.php
index 3533adcf8e0..e0dbe8d3cd7 100644
--- a/apps/calendar/ajax/timeformat.php
+++ b/apps/calendar/ajax/settings/timeformat.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once('../../../lib/base.php');
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
OC_JSON::encodedPrint(array("timeformat" => $timeformat));
diff --git a/apps/calendar/ajax/timezonedetection.php b/apps/calendar/ajax/settings/timezonedetection.php
index 77e4c4f6ebe..f67bab901e7 100644
--- a/apps/calendar/ajax/timezonedetection.php
+++ b/apps/calendar/ajax/settings/timezonedetection.php
@@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
-require_once ("../../../lib/base.php");
+require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
if($_POST['timezonedetection'] == 'on'){
diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php
new file mode 100644
index 00000000000..d91f87b613f
--- /dev/null
+++ b/apps/calendar/ajax/share/changepermission.php
@@ -0,0 +1,40 @@
+<?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']);
+$permission = (int) strip_tags($_GET['permission']);
+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::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/dropdown.php b/apps/calendar/ajax/share/dropdown.php
new file mode 100644
index 00000000000..eb396d38fd9
--- /dev/null
+++ b/apps/calendar/ajax/share/dropdown.php
@@ -0,0 +1,18 @@
+<?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');
+$user = OC_USER::getUser();
+$calid = $_GET['calid'];
+$calendar = OC_Calendar_Calendar::find($calid);
+if($calendar['userid'] != $user){
+ OC_JSON::error();
+ exit;
+}
+$tmpl = new OC_Template('calendar', 'share.dropdown');
+$tmpl->assign('calid', $calid);
+$tmpl->printPage(); \ No newline at end of file
diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php
new file mode 100644
index 00000000000..d892727701a
--- /dev/null
+++ b/apps/calendar/ajax/share/share.php
@@ -0,0 +1,51 @@
+<?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;
+}
+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));
+if($success){
+ if($sharetype == 'public'){
+ OC_JSON::success(array('message'=>$success));
+ }else{
+ OC_JSON::success(array('message'=>'shared'));
+ }
+}else{
+ OC_JSON::error(array('message'=>'can not share'));
+ exit;
+} \ No newline at end of file
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