From ef073a148f2dfcefc9f1bd2bd68fcb9c33aba3cf Mon Sep 17 00:00:00 2001
From: Georg Ehrke <dev@georgswebsite.de>
Date: Mon, 7 May 2012 15:48:41 +0200
Subject: [PATCH] make calendar compatible with public.php

---
 apps/calendar/appinfo/app.php              | 2 +-
 apps/calendar/js/calendar.js               | 5 ++++-
 apps/calendar/share.php                    | 1 -
 apps/calendar/templates/share.dropdown.php | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 06fb9257735..0c91bf8f135 100755
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -24,4 +24,4 @@ OCP\App::addNavigationEntry( array(
 OCP\App::registerPersonal('calendar', 'settings');
 OC_Search::registerProvider('OC_Search_Provider_Calendar');
 OCP\CONFIG::setAppValue('core', 'remote_caldav', '/apps/calendar/appinfo/remote.php');
-OCP\CONFIG::setAppValue('core', 'public_calendar', '/apps/calendar/appinfo/share.php');
\ No newline at end of file
+OCP\CONFIG::setAppValue('core', 'public_calendar', '/apps/calendar/share.php');
\ No newline at end of file
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index a16856938ce..b3beb8d44cb 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -517,7 +517,10 @@ Calendar={
 			},
 			share:function(id, idtype, sharewith, sharetype){
 				$.getJSON(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){
-
+					if(sharetype == 'public'){
+						$('#public_token').val(parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=calendar&t='+data.message);
+						$('#public_token').css('display', 'block');
+					}
 				});
 			},
 			unshare:function(id, idtype, sharewith, sharetype){
diff --git a/apps/calendar/share.php b/apps/calendar/share.php
index 1cc8a2ef15e..68c7d0ffae2 100644
--- a/apps/calendar/share.php
+++ b/apps/calendar/share.php
@@ -1,5 +1,4 @@
 <?php
-require_once('../../lib/base.php');
 $token = strip_tags($_GET['t']);
 $shared = OC_Calendar_Share::getElementByToken($token);
 $nl = "\n\r";
diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php
index e0dabebf257..0796a880f1f 100755
--- a/apps/calendar/templates/share.dropdown.php
+++ b/apps/calendar/templates/share.dropdown.php
@@ -73,5 +73,5 @@ echo OCP\html_select_options($allgroups, array());
 </ul>
 <div id="public">
 	<input type="checkbox" id="publish" <?php echo ($public['share'])?'checked="checked"':'' ?>><label for="publish"><?php echo $l->t('make public'); ?></label><br>
-	<input type="text" id="public_token" value="<?php echo OCP\Util::linkToAbsolute('apps/calendar', 'share.php?t=' . $public['share'], null, true) ; ?>" onmouseover="$('#public_token').select();" style="<?php echo (!$public['share'])?'display:none':'' ?>">
+	<input type="text" id="public_token" value="<?php echo OCP\Util::linkToAbsolute('', 'public.php?service=calendar&t=' . $public['share'], null, true) ; ?>" onmouseover="$('#public_token').select();" style="<?php echo (!$public['share'])?'display:none':'' ?>">
 </div>
\ No newline at end of file
-- 
GitLab