From 217151eb9c2da9ab6ef0c5a3df1e5e1e4f8abd9a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 11:50:45 +0100 Subject: [PATCH 001/116] add textfield style declaration --- core/css/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/css/styles.css b/core/css/styles.css index 53af8b383e..afab1fc4cd 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -32,7 +32,7 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', end /* INPUTS */ input[type="text"], input[type="password"] { cursor:text; } -input, select, button, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; } +input, textarea, select, button, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; } input[type="text"], input[type="password"], input[type="search"] { background:#f8f8f8; color:#555; cursor:text; } input[type="text"], input[type="password"], input[type="search"] { -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; } input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active, From fc70c7094a32be06329e1674339a4d6d7329db65 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 11:57:09 +0100 Subject: [PATCH 002/116] add tabs for repeating and attendees in the event form --- apps/calendar/js/calendar.js | 1 + apps/calendar/templates/part.eventform.php | 50 +++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index afd1b692dd..6b24fbc2f9 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -52,6 +52,7 @@ Calendar={ $('#advanced_month').change(function(){ Calendar.UI.repeat('month'); }); + $( "#event" ).tabs({ selected: 0}); $('#event').dialog({ width : 500, close : function(event, ui) { diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 1f2073f4bc..fc81ebc175 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -1,3 +1,9 @@ + +
@@ -56,7 +62,27 @@
t("Title");?>:
" onclick="Calendar.UI.showadvancedoptions();" id="advanced_options_button"> +
+
+
t("Repeat");?>: @@ -200,23 +226,7 @@
+ t('Summary'); ?>:
-
- - - - - - -
t("Location");?>: - " value="" maxlength="100" name="location" /> -
- - - - - -
t("Description");?>: - -
- + +
\ No newline at end of file From 4c1fb4c2823a55bb4039484e2d8b270ee83e9cac Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 16:49:21 +0100 Subject: [PATCH 003/116] fix style of the tabs --- apps/calendar/css/style.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index cffaf35640..1701a36a1f 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -56,6 +56,8 @@ button.category{margin:0 3px;} .calendar-colorpicker-color{display:inline-block;width:20px;height:20px;margin-right:2px;cursor:pointer;border:2px solid transparent;} .calendar-colorpicker-color.active{border:2px solid black;} +#event {padding: 0;margin: 0;margin-top:-5px} + .fc-list-table { margin: 10px; From c72c4dd41282c23f5c4ea2a9c3a7cbe2876f894b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 16:59:34 +0100 Subject: [PATCH 004/116] add alarm as a tab --- apps/calendar/templates/part.eventform.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index fc81ebc175..fa588f75e2 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -2,6 +2,7 @@
  • Eventinfo
  • Repeating
  • Attendees
  • +
  • Alarm
  • @@ -229,4 +230,5 @@ t('Summary'); ?>: -
    \ No newline at end of file +
    +
    \ No newline at end of file From 149bbeb260aa0f2b2b762e0722bbf23b4cff0680 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 17:15:25 +0100 Subject: [PATCH 005/116] make tab names translatable --- apps/calendar/templates/part.eventform.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index fa588f75e2..217199fca2 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -1,8 +1,8 @@
    From 64a617b2a1016108c946cc533875a40030bbd317 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 20:46:27 +0100 Subject: [PATCH 006/116] fix all day with one day to much - bugfix for oc-126 --- apps/calendar/ajax/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 998991c2fb..73bdfcc270 100644 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -39,13 +39,13 @@ foreach($events as $event){ $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); $return_event = array(); $start_dt = $dtstart->getDateTime(); - $start_dt->setTimezone(new DateTimeZone($user_timezone)); $end_dt = $dtend->getDateTime(); - $end_dt->setTimezone(new DateTimeZone($user_timezone)); if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ $return_event['allDay'] = true; }else{ $return_event['allDay'] = false; + $start_dt->setTimezone(new DateTimeZone($user_timezone)); + $end_dt->setTimezone(new DateTimeZone($user_timezone)); } //Repeating Events if($event['repeating'] == 1){ From 32bff22dc7bf46df33b4d9d7e3a4791d21639ea8 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 21:26:09 +0100 Subject: [PATCH 007/116] change db structure of calendar for sharing calendars --- apps/calendar/appinfo/database.xml | 94 ++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/apps/calendar/appinfo/database.xml b/apps/calendar/appinfo/database.xml index 7f7b645755..5ae4dafd39 100644 --- a/apps/calendar/appinfo/database.xml +++ b/apps/calendar/appinfo/database.xml @@ -187,5 +187,99 @@
    + + + *dbprefix*calendar_share_event + + + + + owner + text + true + 255 + + + + share + text + true + 255 + + + + sharetype + text + true + 5 + + + + eventid + integer + + true + true + 11 + + + + permissions + integer + true + 1 + + + + +
    + + + + *dbprefix*calendar_share_calendar + + + + + owner + text + true + 255 + + + + share + text + true + 255 + + + + sharetype + text + true + 5 + + + + calendarid + integer + + true + true + 11 + + + + permissions + integer + true + 1 + + + + +
    + From 3a5d3dfd9720ab503c0c86208d3484833bf88fd2 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 21:33:50 +0100 Subject: [PATCH 008/116] increase version number to force db upgrade --- apps/calendar/appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml index 46292af3db..c38861e158 100644 --- a/apps/calendar/appinfo/info.xml +++ b/apps/calendar/appinfo/info.xml @@ -2,7 +2,7 @@ calendar Calendar - 0.2 + 0.3 AGPL Georg Ehrke, Bart Visscher, Jakob Sack 2 From 153467dbe0db215582a745359d824fb9cf94fad5 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 21:39:40 +0100 Subject: [PATCH 009/116] add share as a tab --- apps/calendar/templates/part.eventform.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 217199fca2..1b7aa1acb4 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -1,8 +1,9 @@
    @@ -231,4 +232,5 @@
    -
    \ No newline at end of file +
    +
    \ No newline at end of file From 2b8ec1cad048e6ae9a72710d1532a3da23f9b456 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 31 Jan 2012 22:03:08 +0100 Subject: [PATCH 010/116] Calendar: fix html of import dialog --- apps/calendar/templates/part.import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/templates/part.import.php b/apps/calendar/templates/part.import.php index 8f46484b42..90691a33e5 100644 --- a/apps/calendar/templates/part.import.php +++ b/apps/calendar/templates/part.import.php @@ -3,7 +3,7 @@ -

    t('Please choose the calendar'); ?> +

    t('Please choose the calendar'); ?>

    From f870f9efcf36a3c7e839b8c37195d94bfa92d6fe Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 2 Feb 2012 12:18:29 +0100 Subject: [PATCH 012/116] validate parameters in changeview.php --- apps/calendar/ajax/changeview.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index ef05c7cd49..df3e2827b7 100644 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -1,15 +1,24 @@ + * Copyright (c) 2012 Georg Ehrke * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ -require_once ("../../../lib/base.php"); +require_once ('../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); -$currentview = $_GET["v"]; -OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview); +$currentview = $_GET['v']; +switch($currentview){ + case 'agendaWeek': + case 'month'; + case 'list': + break; + default: + OC_JSON::error(); + exit; +} +OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $currentview); OC_JSON::success(); -?> +?> \ No newline at end of file From 91b705cc4febce2675d31b520c52bf9c39f13554 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 2 Feb 2012 12:37:58 +0100 Subject: [PATCH 013/116] remove debug file --- apps/calendar/resettimezone.php | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 apps/calendar/resettimezone.php diff --git a/apps/calendar/resettimezone.php b/apps/calendar/resettimezone.php deleted file mode 100644 index 1ef9591ae3..0000000000 --- a/apps/calendar/resettimezone.php +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file From b810380d56b41ebad4fd67a30d6789744c69deb3 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 4 Feb 2012 21:23:31 +0100 Subject: [PATCH 014/116] add sharing management for calendars --- apps/calendar/ajax/changepermission.php | 40 +++++ apps/calendar/ajax/share.dropdown.php | 18 ++ apps/calendar/ajax/share.php | 51 ++++++ apps/calendar/ajax/unshare.php | 44 +++++ apps/calendar/appinfo/app.php | 3 + apps/calendar/appinfo/database.xml | 4 +- apps/calendar/css/style.css | 4 + apps/calendar/js/calendar.js | 103 ++++++++++- apps/calendar/lib/share.php | 163 ++++++++++++++++++ apps/calendar/share.php | 1 + .../templates/part.choosecalendar.php | 23 ++- .../part.choosecalendar.rowfields.php | 10 +- .../part.choosecalendar.rowfields.shared.php | 4 + apps/calendar/templates/part.eventform.php | 6 +- apps/calendar/templates/share.dropdown.php | 71 ++++++++ 15 files changed, 535 insertions(+), 10 deletions(-) create mode 100644 apps/calendar/ajax/changepermission.php create mode 100644 apps/calendar/ajax/share.dropdown.php create mode 100644 apps/calendar/ajax/share.php create mode 100644 apps/calendar/ajax/unshare.php create mode 100644 apps/calendar/lib/share.php create mode 100644 apps/calendar/share.php create mode 100644 apps/calendar/templates/part.choosecalendar.rowfields.shared.php create mode 100644 apps/calendar/templates/share.dropdown.php diff --git a/apps/calendar/ajax/changepermission.php b/apps/calendar/ajax/changepermission.php new file mode 100644 index 0000000000..caee894521 --- /dev/null +++ b/apps/calendar/ajax/changepermission.php @@ -0,0 +1,40 @@ + + * 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 0000000000..7e78521a76 --- /dev/null +++ b/apps/calendar/ajax/share.dropdown.php @@ -0,0 +1,18 @@ + + * 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.php b/apps/calendar/ajax/share.php new file mode 100644 index 0000000000..1b75c1731b --- /dev/null +++ b/apps/calendar/ajax/share.php @@ -0,0 +1,51 @@ + + * 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/unshare.php b/apps/calendar/ajax/unshare.php new file mode 100644 index 0000000000..f69295fd07 --- /dev/null +++ b/apps/calendar/ajax/unshare.php @@ -0,0 +1,44 @@ + + * 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 diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 9c95768895..a684adb679 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -6,8 +6,11 @@ if(version_compare(PHP_VERSION, '5.3.0', '>=')){ OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php'; OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php'; + OC::$CLASSPATH['OC_Calendar_Share'] = 'apps/calendar/lib/share.php'; OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser'); OC_Util::addScript('calendar','loader'); + OC_Util::addScript('3rdparty', 'chosen/chosen.jquery.min'); + OC_Util::addStyle('3rdparty', 'chosen/chosen'); OC_App::register( array( 'order' => 10, 'id' => 'calendar', diff --git a/apps/calendar/appinfo/database.xml b/apps/calendar/appinfo/database.xml index ee672574a0..b065ab3f94 100644 --- a/apps/calendar/appinfo/database.xml +++ b/apps/calendar/appinfo/database.xml @@ -212,7 +212,7 @@ sharetype text true - 5 + 6 @@ -259,7 +259,7 @@ sharetype text true - 5 + 6 diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index 1701a36a1f..373a456563 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -58,6 +58,10 @@ button.category{margin:0 3px;} #event {padding: 0;margin: 0;margin-top:-5px} +.calendar_share_dropdown{ display:block; position:absolute; z-index:100; width:16em; right:0; margin-right:7em; background:#F8F8F8; padding:1em; +-moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777; +-moz-border-radius:0 0 1em 1em; -webkit-border-radius:0 0 1em 1em; border-radius:0 0 1em 1em;} + .fc-list-table { margin: 10px; diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 6b24fbc2f9..bbefa1bcf2 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -454,7 +454,7 @@ Calendar={ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url); $('#calendar_holder').fullCalendar('addEventSource', data.eventSource); if (calendarid == 'new'){ - $('#choosecalendar_dialog > table').append(''); + $('#choosecalendar_dialog > table:first').append(''); } }else{ $("#displayname_"+calendarid).css('background-color', '#FF2626'); @@ -493,6 +493,106 @@ Calendar={ left: -10000 }); } + }, + Share:{ + currentid: 'false', + idtype: '', + dropdown:function(userid, calid){ + $('.calendar_share_dropdown').remove(); + $('
    ').appendTo('#'+userid+'_'+calid); + $.get(OC.filePath('calendar', 'ajax', 'share.dropdown.php') + '?calid=' + calid, function(data){ + $('#'+userid+'_'+calid+' > .calendar_share_dropdown').html(data); + $('#'+userid+'_'+calid+' > .calendar_share_dropdown').show('blind'); + $('#share_user').chosen(); + $('#share_group').chosen(); + }); + Calendar.UI.Share.currentid = calid; + Calendar.UI.Share.idtype = 'calendar'; + }, + share:function(id, idtype, sharewith, sharetype){ + $.getJSON(OC.filePath('calendar', 'ajax', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){ + if(sharetype == 'public'){ + $('#public_token').val(OC.linkTo('calendar', 'share.php?t=' + data.message)); + $('#public_token').css('display', 'block'); + } + }); + }, + unshare:function(id, idtype, sharewith, sharetype){ + $.getJSON(OC.filePath('calendar', 'ajax', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){ + if(sharetype == 'public'){ + $('#public_token').val(''); + $('#public_token').css('display', 'none'); + } + }); + }, + changepermission:function(id, idtype, sharewith, sharetype, permission){ + $.getJSON(OC.filePath('calendar', 'ajax', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)}); + }, + init:function(){ + $('.calendar_share_dropdown').live('mouseleave', function(){ + $('.calendar_share_dropdown').hide('blind', function(){ + $('.calendar_share_dropdown').remove(); + }); + }); + $('#share_user').live('change', function(){ + if($('#sharewithuser_' + $('#share_user option:selected').text()).length == 0){ + Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_user option:selected').text(), 'user'); + var newitem = '
  • ' + $('#share_user option:selected').text() + '
  • '; + $('#sharewithuser_list').append(newitem); + $('#sharewithuser_' + $('#share_user option:selected').text() + ' > img').click(function(){ + $('#share_user option[value="' + $(this).parent().text() + '"]').attr('disabled', 'false'); + Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user' ); + $(this).parent().remove(); + }); + $('#share_user option:selected').attr('disabled', 'disabled'); + $("#share_user").trigger("liszt:updated"); + } + }); + $('#share_group').live('change', function(){ + if($('#sharewithgroup_' + $('#share_group option:selected').text()).length == 0){ + Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_group option:selected').text(), 'group'); + var newitem = '
  • ' + $('#share_group option:selected').text() + '
  • '; + $('#sharewithgroup_list').append(newitem); + $('#sharewithgroup_' + $('#share_user option:selected').text() + ' > img').click(function(){ + $('#share_group option[value="' + $(this).parent().text() + '"]').attr('disabled', 'false'); + Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group'); + $(this).parent().remove(); + }); + $('#share_group option:selected').attr('disabled', 'disabled'); + $("#share_group").trigger("liszt:updated"); + } + }); + $('#sharewithuser_list > li > input:checkbox').live('change', function(){ + Calendar.UI.Share.changepermission(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user', this.checked); + }); + $('#sharewithgroup_list > li > input:checkbox').live('change', function(){ + Calendar.UI.Share.changepermission(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group', this.checked); + }); + $('#publish').live('change', function(){ + if(this.checked == 1){ + Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, '', 'public'); + }else{ + Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, '', 'public'); + } + }); + $('#sharewithuser_list').live('mouseenter', function(){ + $('#sharewithuser_list > li > img').css('display', 'block'); + $('#sharewithuser_list > li > input').css('visibility', 'visible'); + }); + $('#sharewithuser_list').live('mouseleave', function(){ + $('#sharewithuser_list > li > img').css('display', 'none'); + $('#sharewithuser_list > li > input').css('visibility', 'hidden'); + }); + $('#sharewithgroup_list').live('mouseenter', function(){ + $('#sharewithgroup_list > li > img').css('display', 'block'); + $('#sharewithgroup_list > li > input').css('visibility', 'visible'); + }); + $('#sharewithgroup_list').live('mouseleave', function(){ + $('#sharewithgroup_list > li > img').css('display', 'none'); + $('#sharewithgroup_list > li > input').css('visibility', 'hidden'); + }); + /*var permissions = (this.checked) ? 1 : 0;*/ + } } } } @@ -732,4 +832,5 @@ $(document).ready(function(){ $('#datecontrol_right').click(function(){ $('#calendar_holder').fullCalendar('next'); }); + Calendar.UI.Share.init(); }); diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php new file mode 100644 index 0000000000..bbc8770f65 --- /dev/null +++ b/apps/calendar/lib/share.php @@ -0,0 +1,163 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages shared calendars + */ +class OC_Calendar_Share{ + const CALENDAR = 'calendar'; + const EVENT = 'event'; + /* + * @brief: returns informations about all calendar or events which users are sharing with the user - userid + * @param: (string) $userid - id of the user + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return: (array) $return - information about calendars + */ + public static function allSharedwithuser($userid, $type){ + $group_where = 'false'; + $groups = OC_Group::getUserGroups($userid); + $i = 0; + foreach($groups as $group){ + if($i == 0){ + $group_where = ''; + }else{ + $group_where .= ' OR '; + } + $group_where .= ' (share = "' . $group . '" and sharetype = "group") '; + $i++; + } + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE (share = ? AND sharetype = "user") OR (' . $group_where . ')'); + $result = $stmt->execute(array($userid)); + $return = array(); + while( $row = $result->fetchRow()){ + $return[] = $row; + } + return $return; + } + /* + * @brief: returns all users a calendar / event is shared with + * @param: (int) id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return: (array) $users - information about users a calendar / event is shared with + */ + public static function allUsersSharedwith($id, $type){ + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ' . $type . 'id = ? ORDER BY share'); + $result = $stmt->execute(array($id)); + $users = array(); + while( $row = $result->fetchRow()){ + $users[] = $row; + } + return $users; + } + /* + * @brief: shares a calendar / event + * @param: (string) $owner - userid of the owner + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (mixed) - token (if $sharetype == public) / bool (if $sharetype != public) + */ + public static function share($owner, $share, $sharetype, $id, $type){ + if(self::is_already_shared($owner, $share, $sharetype, $id, $type)){ + return false; + } + switch($sharetype){ + case 'user': + case 'group': + case 'public': + break; + default: + return false; + } + if($sharetype == 'public'){ + $share = self::generate_token(); + } + $stmt = OC_DB::prepare('INSERT INTO *PREFIX*calendar_share_' . $type . ' (owner,share,sharetype,' . $type . 'id,permissions' . (($type == self::CALENDAR)?', active':'') . ') VALUES(?,?,?,?,0' . (($type == self::CALENDAR)?', 1':'') . ')' ); + $result = $stmt->execute(array($owner,$share,$sharetype,$id)); + if($sharetype == 'public'){ + return $share; + }else{ + return true; + } + } + /* + * @brief: stops sharing a calendar / event + * @param: (string) $owner - userid of the owner + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function unshare($owner, $share, $sharetype, $id, $type){ + $stmt = OC_DB::prepare('DELETE FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? ' . (($sharetype != 'public')?'AND share = ?':'') . ' AND sharetype = ? AND ' . $type . 'id = ?'); + if($sharetype != 'public'){ + $stmt->execute(array($owner,$share,$sharetype,$id)); + }else{ + $stmt->execute(array($owner,$sharetype,$id)); + } + return true; + } + /* + * @brief: changes the permission for a calendar / event + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (int) $permission - permission of user the calendar / event is shared with (if $sharetype == public then $permission = 0) + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function changepermission($share, $sharetype, $id, $permission, $type){ + if($sharetype == 'public' && $permission == 1){ + $permission = 0; + } + $stmt = OC_DB::prepare('UPDATE *PREFIX*calendar_share_' . $type . ' SET permissions = ? WHERE share = ? AND sharetype = ? AND ' . $type . 'id = ?'); + $stmt->execute(array($permission, $share, $sharetype, $id)); + return true; + } + /* + * @brief: generates a token for public calendars / events + * @return: (string) $token + */ + private static function generate_token($id, $type){ + $uniqid = uniqid(); + if($type == self::CALENDAR){ + $events = OC_Calendar_Objects::all($id); + $string = ''; + foreach($events as $event){ + $string .= $event['calendardata']; + } + }else{ + $string = OC_Calendar_Object::find($id); + } + $string = sha1($string); + $id = sha1($id); + $array = array($uniqid,$string,$id); + shuffle($array); + $string = implode('', $array); + $token = md5($string); + return substr($token, rand(0,16), 15); + } + /* + * @brief: checks if it is already shared + * @param: (string) $owner - userid of the owner + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $sharetype - type of sharing (can be: user/group/public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + private static function is_already_shared($owner, $share, $sharetype, $id, $type){ + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? AND share = ? AND sharetype = ? AND ' . $type . 'id = ?'); + $result = $stmt->execute(array($owner, $share, $sharetype, $id)); + if($result->numRows() > 0){ + return true; + } + return false; + } +} \ No newline at end of file diff --git a/apps/calendar/share.php b/apps/calendar/share.php new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/apps/calendar/share.php @@ -0,0 +1 @@ + diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index 86f09d6207..21da5dd7cd 100644 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -1,4 +1,5 @@
    "> +

    t('Your calendars'); ?>:

    +
    -

    ">

    +

    ">


    +

    t('Shared calendars'); ?>:

    + +'; + $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields.shared'); + $tmpl->assign('share', $share[$i]); + $tmpl->printpage(); + echo ''; +} +?>
    +' . $l->t('No shared calendars') . '

    '; +} +?> +
    \ No newline at end of file diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php index a789be45a4..156d50bc48 100644 --- a/apps/calendar/templates/part.choosecalendar.rowfields.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.php @@ -1,4 +1,8 @@ "; - echo ""; - echo "t("CalDav Link") . "\" class=\"action\">t("Download") . "\" class=\"action\">t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\">t("Delete") . "\" class=\"action\">"; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php new file mode 100644 index 0000000000..2e1210415b --- /dev/null +++ b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php @@ -0,0 +1,4 @@ +'; +echo ''; +echo '' . $l->t('shared with you by') . ' ' . $_['share']['owner'] . ''; \ No newline at end of file diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 1b7aa1acb4..4a9a467549 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -231,6 +231,6 @@ t('Summary'); ?>:
    -
    -
    -
    \ No newline at end of file +
    //Alarm
    +
    //Attendees
    +
    //Share
    \ No newline at end of file diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php new file mode 100644 index 0000000000..6a944f1f09 --- /dev/null +++ b/apps/calendar/templates/share.dropdown.php @@ -0,0 +1,71 @@ + +t('Users');?>:
    +
    +
      + +
    • style="visibility:hidden;" title="t('Editable'); ?>">
    • + + +
    +t('Groups');?>:
    +
    +
      + +
    • style="visibility:hidden;" title="t('Editable'); ?>">
    • + + +
    +
    + >
    + +
    \ No newline at end of file From 1a0c273a201e2478cea6d3fbc0abcd43b0670bd0 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 10 Feb 2012 20:04:49 +0100 Subject: [PATCH 015/116] initial project import from KDevelop --- owncloud.php | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 owncloud.php diff --git a/owncloud.php b/owncloud.php new file mode 100644 index 0000000000..adb6e8a280 --- /dev/null +++ b/owncloud.php @@ -0,0 +1,7 @@ + Date: Sat, 11 Feb 2012 13:30:15 +0100 Subject: [PATCH 016/116] fix sharing calendar manager --- apps/calendar/js/calendar.js | 8 +++++--- apps/calendar/templates/share.dropdown.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index f6a353edd6..cf0bb079c8 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -540,9 +540,10 @@ Calendar={ var newitem = '
  • ' + $('#share_user option:selected').text() + '
  • '; $('#sharewithuser_list').append(newitem); $('#sharewithuser_' + $('#share_user option:selected').text() + ' > img').click(function(){ - $('#share_user option[value="' + $(this).parent().text() + '"]').attr('disabled', 'false'); + $('#share_user option[value="' + $(this).parent().text() + '"]').removeAttr('disabled'); Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'user' ); $(this).parent().remove(); + $("#share_user").trigger("liszt:updated"); }); $('#share_user option:selected').attr('disabled', 'disabled'); $("#share_user").trigger("liszt:updated"); @@ -553,10 +554,11 @@ Calendar={ Calendar.UI.Share.share(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $('#share_group option:selected').text(), 'group'); var newitem = '
  • ' + $('#share_group option:selected').text() + '
  • '; $('#sharewithgroup_list').append(newitem); - $('#sharewithgroup_' + $('#share_user option:selected').text() + ' > img').click(function(){ - $('#share_group option[value="' + $(this).parent().text() + '"]').attr('disabled', 'false'); + $('#sharewithgroup_' + $('#share_group option:selected').text() + ' > img').click(function(){ + $('#share_group option[value="' + $(this).parent().text() + '"]').removeAttr('disabled'); Calendar.UI.Share.unshare(Calendar.UI.Share.currentid, Calendar.UI.Share.idtype, $(this).parent().text(), 'group'); $(this).parent().remove(); + $("#share_group").trigger("liszt:updated"); }); $('#share_group option:selected').attr('disabled', 'disabled'); $("#share_group").trigger("liszt:updated"); diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php index 6a944f1f09..ca1e128ea7 100644 --- a/apps/calendar/templates/share.dropdown.php +++ b/apps/calendar/templates/share.dropdown.php @@ -53,7 +53,7 @@ echo html_select_options($allgroups, array());
      -
    • style="visibility:hidden;" title="t('Editable'); ?>">
    • +
    • style="visibility:hidden;" title="t('Editable'); ?>">
    • '); -} -OC_JSON::checkAppEnabled('calendar'); - -$id = $_GET['id']; -$data = OC_Calendar_App::getEventObject($id); -$object = OC_VObject::parse($data['calendardata']); -$vevent = $object->VEVENT; - -$dtstart = $vevent->DTSTART; -$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); -switch($dtstart->getDateType()) { - case Sabre_VObject_Element_DateTime::LOCALTZ: - case Sabre_VObject_Element_DateTime::LOCAL: - $startdate = $dtstart->getDateTime()->format('d-m-Y'); - $starttime = $dtstart->getDateTime()->format('H:i'); - $enddate = $dtend->getDateTime()->format('d-m-Y'); - $endtime = $dtend->getDateTime()->format('H:i'); - $allday = false; - break; - case Sabre_VObject_Element_DateTime::DATE: - $startdate = $dtstart->getDateTime()->format('d-m-Y'); - $starttime = ''; - $dtend->getDateTime()->modify('-1 day'); - $enddate = $dtend->getDateTime()->format('d-m-Y'); - $endtime = ''; - $allday = true; - break; -} - -$summary = $vevent->getAsString('SUMMARY'); -$location = $vevent->getAsString('LOCATION'); -$categories = $vevent->getAsArray('CATEGORIES'); -$description = $vevent->getAsString('DESCRIPTION'); -foreach($categories as $category){ - if (!in_array($category, $category_options)){ - array_unshift($category_options, $category); - } -} -$last_modified = $vevent->__get('LAST-MODIFIED'); -if ($last_modified){ - $lastmodified = $last_modified->getDateTime()->format('U'); -}else{ - $lastmodified = 0; -} -if($data['repeating'] == 1){ - $rrule = explode(';', $vevent->getAsString('RRULE')); - $rrulearr = array(); - foreach($rrule as $rule){ - list($attr, $val) = explode('=', $rule); - $rrulearr[$attr] = $val; - } - if(!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == ''){ - $rrulearr['INTERVAL'] = 1; - } - if(array_key_exists('BYDAY', $rrulearr)){ - if(substr_count($rrulearr['BYDAY'], ',') == 0){ - if(strlen($rrulearr['BYDAY']) == 2){ - $repeat['weekdays'] = array($rrulearr['BYDAY']); - }elseif(strlen($rrulearr['BYDAY']) == 3){ - $repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 1); - $repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 1, 2)); - }elseif(strlen($rrulearr['BYDAY']) == 4){ - $repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 2); - $repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 2, 2)); - } - }else{ - $byday_days = explode(',', $rrulearr['BYDAY']); - foreach($byday_days as $byday_day){ - if(strlen($byday_day) == 2){ - $repeat['weekdays'][] = $byday_day; - }elseif(strlen($byday_day) == 3){ - $repeat['weekofmonth'] = substr($byday_day , 0, 1); - $repeat['weekdays'][] = substr($byday_day , 1, 2); - }elseif(strlen($byday_day) == 4){ - $repeat['weekofmonth'] = substr($byday_day , 0, 2); - $repeat['weekdays'][] = substr($byday_day , 2, 2); - } - } - } - } - if(array_key_exists('BYMONTHDAY', $rrulearr)){ - if(substr_count($rrulearr['BYMONTHDAY'], ',') == 0){ - $repeat['bymonthday'][] = $rrulearr['BYMONTHDAY']; - }else{ - $bymonthdays = explode(',', $rrulearr['BYMONTHDAY']); - foreach($bymonthdays as $bymonthday){ - $repeat['bymonthday'][] = $bymonthday; - } - } - } - if(array_key_exists('BYYEARDAY', $rrulearr)){ - if(substr_count($rrulearr['BYYEARDAY'], ',') == 0){ - $repeat['byyearday'][] = $rrulearr['BYYEARDAY']; - }else{ - $byyeardays = explode(',', $rrulearr['BYYEARDAY']); - foreach($byyeardays as $yearday){ - $repeat['byyearday'][] = $yearday; - } - } - } - if(array_key_exists('BYWEEKNO', $rrulearr)){ - if(substr_count($rrulearr['BYWEEKNO'], ',') == 0){ - $repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO']; - }else{ - $byweekno = explode(',', $rrulearr['BYWEEKNO']); - foreach($byweekno as $weekno){ - $repeat['byweekno'][] = (string) $weekno; - } - } - } - if(array_key_exists('BYMONTH', $rrulearr)){ - $months = OC_Calendar_App::getByMonthOptions(); - if(substr_count($rrulearr['BYMONTH'], ',') == 0){ - $repeat['bymonth'][] = $months[$month]; - }else{ - $bymonth = explode(',', $rrulearr['BYMONTH']); - foreach($bymonth as $month){ - $repeat['bymonth'][] = $months[$month]; - } - } - } - switch($rrulearr['FREQ']){ - case 'DAILY': - $repeat['repeat'] = 'daily'; - break; - case 'WEEKLY': - if($rrulearr['INTERVAL'] % 2 == 0){ - $repeat['repeat'] = 'biweekly'; - $rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2; - }elseif($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR'){ - $repeat['repeat'] = 'weekday'; - }else{ - $repeat['repeat'] = 'weekly'; - } - break; - case 'MONTHLY': - $repeat['repeat'] = 'monthly'; - if(array_key_exists('BYDAY', $rrulearr)){ - $repeat['month'] = 'weekday'; - }else{ - $repeat['month'] = 'monthday'; - } - break; - case 'YEARLY': - $repeat['repeat'] = 'yearly'; - if(array_key_exists('BYMONTH', $rrulearr)){ - $repeat['year'] = 'bydaymonth'; - }elseif(array_key_exists('BYWEEKNO', $rrulearr)){ - $repeat['year'] = 'byweekno'; - }else{ - $repeat['year'] = 'byyearday'; - } - } - $repeat['interval'] = $rrulearr['INTERVAL']; - if(array_key_exists('COUNT', $rrulearr)){ - $repeat['end'] = 'count'; - $repeat['count'] = $rrulearr['COUNT']; - }elseif(array_key_exists('UNTIL', $rrulearr)){ - $repeat['end'] = 'date'; - $endbydate_day = substr($rrulearr['UNTIL'], 6, 2); - $endbydate_month = substr($rrulearr['UNTIL'], 4, 2); - $endbydate_year = substr($rrulearr['UNTIL'], 0, 4); - $repeat['date'] = $endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year; - }else{ - $repeat['end'] = 'never'; - } - if(array_key_exists('weekdays', $repeat)){ - $repeat_weekdays_ = array(); - $days = OC_Calendar_App::getWeeklyOptions(); - foreach($repeat['weekdays'] as $weekday){ - $repeat_weekdays_[] = $days[$weekday]; - } - $repeat['weekdays'] = $repeat_weekdays_; - } -}else{ - $repeat['repeat'] = 'doesnotrepeat'; -} - -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$category_options = OC_Calendar_App::getCategoryOptions(); -$repeat_options = OC_Calendar_App::getRepeatOptions(); -$repeat_end_options = OC_Calendar_App::getEndOptions(); -$repeat_month_options = OC_Calendar_App::getMonthOptions(); -$repeat_year_options = OC_Calendar_App::getYearOptions(); -$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions(); -$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth(); -$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions(); -$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); -$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); -$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); - -$tmpl = new OC_Template('calendar', 'part.editevent'); -$tmpl->assign('id', $id); -$tmpl->assign('lastmodified', $lastmodified); -$tmpl->assign('calendar_options', $calendar_options); -$tmpl->assign('category_options', $category_options); -$tmpl->assign('repeat_options', $repeat_options); -$tmpl->assign('repeat_month_options', $repeat_month_options); -$tmpl->assign('repeat_weekly_options', $repeat_weekly_options); -$tmpl->assign('repeat_end_options', $repeat_end_options); -$tmpl->assign('repeat_year_options', $repeat_year_options); -$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options); -$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options); -$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options); -$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options); -$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options); - -$tmpl->assign('title', $summary); -$tmpl->assign('location', $location); -$tmpl->assign('categories', $categories); -$tmpl->assign('calendar', $data['calendarid']); -$tmpl->assign('allday', $allday); -$tmpl->assign('startdate', $startdate); -$tmpl->assign('starttime', $starttime); -$tmpl->assign('enddate', $enddate); -$tmpl->assign('endtime', $endtime); -$tmpl->assign('description', $description); - -$tmpl->assign('repeat', $repeat['repeat']); -if($repeat['repeat'] != 'doesnotrepeat'){ - $tmpl->assign('repeat_month', $repeat['month']); - $tmpl->assign('repeat_weekdays', $repeat['weekdays']); - $tmpl->assign('repeat_interval', $repeat['interval']); - $tmpl->assign('repeat_end', $repeat['end']); - $tmpl->assign('repeat_count', $repeat['count']); - $tmpl->assign('repeat_weekofmonth', $repeat['weekofmonth']); - $tmpl->assign('repeat_date', $repeat['date']); - $tmpl->assign('repeat_year', $repeat['year']); - $tmpl->assign('repeat_byyearday', $repeat['byyearday']); - $tmpl->assign('repeat_bymonthday', $repeat['bymonthday']); - $tmpl->assign('repeat_bymonth', $repeat['bymonth']); - $tmpl->assign('repeat_byweekno', $repeat['byweekno']); -} -$tmpl->printpage(); - -?> \ No newline at end of file diff --git a/apps/calendar/ajax/gettimezonedetection.php b/apps/calendar/ajax/gettimezonedetection.php deleted file mode 100644 index ae58370712..0000000000 --- a/apps/calendar/ajax/gettimezonedetection.php +++ /dev/null @@ -1,11 +0,0 @@ - - * 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'); -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/guesstimezone.php deleted file mode 100755 index 41aea26985..0000000000 --- a/apps/calendar/ajax/guesstimezone.php +++ /dev/null @@ -1,48 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ -function make_array_out_of_xml ($xml){ - $returnarray = array(); - $xml = (array)$xml ; - foreach ($xml as $property => $value){ - $value = (array)$value; - if(!isset($value[0])){ - $returnarray[$property] = make_array_out_of_xml($value); - }else{ - $returnarray[$property] = trim($value[0]); - } - } - return $returnarray; -} -require_once ("../../../lib/base.php"); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); -$l = new OC_L10N('calendar'); -$lat = $_GET['lat']; -$long = $_GET['long']; -if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'position') == $lat . '-' . $long && OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone') != null){ - OC_JSON::success(); - exit; -} -OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'position', $lat . '-' . $long); -$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long); -//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License -$geoxml = simplexml_load_string($geolocation); -$geoarray = make_array_out_of_xml($geoxml); -if($geoarray['timezone']['timezoneId'] == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){ - OC_JSON::success(); - exit; -} -if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){ - OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']); - $message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']); - OC_JSON::success($message); -}else{ - OC_JSON::error(); -} - -?> diff --git a/apps/calendar/ajax/importdialog.php b/apps/calendar/ajax/importdialog.php deleted file mode 100644 index f6b8453fc2..0000000000 --- a/apps/calendar/ajax/importdialog.php +++ /dev/null @@ -1,17 +0,0 @@ - - * 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_Util::checkAppEnabled('calendar'); -$l10n = new OC_L10N('calendar'); -$tmpl = new OC_Template('calendar', 'part.import'); -$tmpl->assign('path', $_POST['path']); -$tmpl->assign('filename', $_POST['filename']); -$tmpl->printpage(); -?> diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php deleted file mode 100644 index f2256d4eee..0000000000 --- a/apps/calendar/ajax/moveevent.php +++ /dev/null @@ -1,43 +0,0 @@ - - * 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(); - -$id = $_POST['id']; - -$vcalendar = OC_Calendar_App::getVCalendar($id); -$vevent = $vcalendar->VEVENT; - -$allday = $_POST['allDay']; -$delta = new DateInterval('P0D'); -$delta->d = $_POST['dayDelta']; -$delta->i = $_POST['minuteDelta']; - -OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); - -$dtstart = $vevent->DTSTART; -$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); -$start_type = $dtstart->getDateType(); -$end_type = $dtend->getDateType(); -if ($allday && $start_type != Sabre_VObject_Element_DateTime::DATE){ - $start_type = $end_type = Sabre_VObject_Element_DateTime::DATE; - $dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type); -} -if (!$allday && $start_type == Sabre_VObject_Element_DateTime::DATE){ - $start_type = $end_type = Sabre_VObject_Element_DateTime::LOCALTZ; -} -$dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type); -$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); -unset($vevent->DURATION); - -$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); -$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); - -$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); -$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/newcalendar.php b/apps/calendar/ajax/newcalendar.php deleted file mode 100644 index af3ba4fbbe..0000000000 --- a/apps/calendar/ajax/newcalendar.php +++ /dev/null @@ -1,24 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -require_once('../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); -$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); -$calendar = array( - 'id' => 'new', - 'displayname' => '', - 'calendarcolor' => '', -); -$tmpl = new OC_Template('calendar', 'part.editcalendar'); -$tmpl->assign('new', true); -$tmpl->assign('calendarcolor_options', $calendarcolor_options); -$tmpl->assign('calendar', $calendar); -$tmpl->printPage(); -?> diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php deleted file mode 100644 index c7c4d29943..0000000000 --- a/apps/calendar/ajax/newevent.php +++ /dev/null @@ -1,27 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -require_once('../../../lib/base.php'); - -$l10n = new OC_L10N('calendar'); - -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); - -$errarr = OC_Calendar_Object::validateRequest($_POST); -if($errarr){ - //show validate errors - OC_JSON::error($errarr); - exit; -}else{ - $cal = $_POST['calendar']; - $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST); - $result = OC_Calendar_Object::add($cal, $vcalendar->serialize()); - OC_JSON::success(); -} -?> diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php deleted file mode 100644 index 3870c879b0..0000000000 --- a/apps/calendar/ajax/neweventform.php +++ /dev/null @@ -1,76 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -require_once('../../../lib/base.php'); - -if(!OC_USER::isLoggedIn()) { - die(''); -} -OC_JSON::checkAppEnabled('calendar'); - -if (!isset($_POST['start'])){ - OC_JSON::error(); - die; -} -$start = $_POST['start']; -$end = $_POST['end']; -$allday = $_POST['allday']; - -if (!$end){ - $duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', '60'); - $end = $start + ($duration * 60); -} -$start = new DateTime('@'.$start); -$end = new DateTime('@'.$end); -$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); -$start->setTimezone(new DateTimeZone($timezone)); -$end->setTimezone(new DateTimeZone($timezone)); - -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -$category_options = OC_Calendar_App::getCategoryOptions(); -$repeat_options = OC_Calendar_App::getRepeatOptions(); -$repeat_end_options = OC_Calendar_App::getEndOptions(); -$repeat_month_options = OC_Calendar_App::getMonthOptions(); -$repeat_year_options = OC_Calendar_App::getYearOptions(); -$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions(); -$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth(); -$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions(); -$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); -$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); -$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); - -$tmpl = new OC_Template('calendar', 'part.newevent'); -$tmpl->assign('calendar_options', $calendar_options); -$tmpl->assign('category_options', $category_options); -$tmpl->assign('repeat_options', $repeat_options); -$tmpl->assign('repeat_month_options', $repeat_month_options); -$tmpl->assign('repeat_weekly_options', $repeat_weekly_options); -$tmpl->assign('repeat_end_options', $repeat_end_options); -$tmpl->assign('repeat_year_options', $repeat_year_options); -$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options); -$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options); -$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options); -$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options); -$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options); - -$tmpl->assign('startdate', $start->format('d-m-Y')); -$tmpl->assign('starttime', $start->format('H:i')); -$tmpl->assign('enddate', $end->format('d-m-Y')); -$tmpl->assign('endtime', $end->format('H:i')); -$tmpl->assign('allday', $allday); -$tmpl->assign('repeat', 'doesnotrepeat'); -$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(); -?> diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/resizeevent.php deleted file mode 100644 index 6834790652..0000000000 --- a/apps/calendar/ajax/resizeevent.php +++ /dev/null @@ -1,32 +0,0 @@ - - * 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(); - -$id = $_POST['id']; - -$vcalendar = OC_Calendar_App::getVCalendar($id); -$vevent = $vcalendar->VEVENT; - -$delta = new DateInterval('P0D'); -$delta->d = $_POST['dayDelta']; -$delta->i = $_POST['minuteDelta']; - -OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); - -$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); -$end_type = $dtend->getDateType(); -$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); -unset($vevent->DURATION); - -$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); -$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); - -$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); -$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php deleted file mode 100644 index 7805120ba5..0000000000 --- a/apps/calendar/ajax/settimeformat.php +++ /dev/null @@ -1,17 +0,0 @@ - - * 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(); -if(isset($_POST["timeformat"])){ - OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); - OC_JSON::success(); -}else{ - OC_JSON::error(); -} -?> - diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settimezone.php deleted file mode 100644 index c726a11471..0000000000 --- a/apps/calendar/ajax/settimezone.php +++ /dev/null @@ -1,27 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -// Init owncloud -require_once('../../../lib/base.php'); - -$l=new OC_L10N('calendar'); - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); - -// Get data -if( isset( $_POST['timezone'] ) ){ - $timezone=$_POST['timezone']; - OC_Preferences::setValue( OC_User::getUser(), 'calendar', 'timezone', $timezone ); - OC_JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); -}else{ - OC_JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); -} - -?> diff --git a/apps/calendar/ajax/share.dropdown.php b/apps/calendar/ajax/share.dropdown.php deleted file mode 100644 index 7e78521a76..0000000000 --- a/apps/calendar/ajax/share.dropdown.php +++ /dev/null @@ -1,18 +0,0 @@ - - * 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.php b/apps/calendar/ajax/share.php deleted file mode 100644 index 1b75c1731b..0000000000 --- a/apps/calendar/ajax/share.php +++ /dev/null @@ -1,51 +0,0 @@ - - * 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/timeformat.php b/apps/calendar/ajax/timeformat.php deleted file mode 100644 index 3533adcf8e..0000000000 --- a/apps/calendar/ajax/timeformat.php +++ /dev/null @@ -1,12 +0,0 @@ - - * 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(); -$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/timezonedetection.php deleted file mode 100644 index 77e4c4f6eb..0000000000 --- a/apps/calendar/ajax/timezonedetection.php +++ /dev/null @@ -1,17 +0,0 @@ - - * 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'); -if($_POST['timezonedetection'] == 'on'){ - OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true'); -}else{ - OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false'); -} -OC_JSON::success(); - diff --git a/apps/calendar/ajax/unshare.php b/apps/calendar/ajax/unshare.php deleted file mode 100644 index f69295fd07..0000000000 --- a/apps/calendar/ajax/unshare.php +++ /dev/null @@ -1,44 +0,0 @@ - - * 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 diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php deleted file mode 100644 index 5add6d92bf..0000000000 --- a/apps/calendar/ajax/updatecalendar.php +++ /dev/null @@ -1,38 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -require_once('../../../lib/base.php'); - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('calendar'); - -if(trim($_POST['name']) == ''){ - OC_JSON::error(array('message'=>'empty')); - exit; -} -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); -foreach($calendars as $cal){ - if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']){ - OC_JSON::error(array('message'=>'namenotavailable')); - exit; - } -} - -$calendarid = $_POST['id']; -$calendar = OC_Calendar_App::getCalendar($calendarid);//access check -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); -$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); -$tmpl->assign('calendar', $calendar); -OC_JSON::success(array( - 'page' => $tmpl->fetchPage(), - 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), -)); From 8dff0fb58de75b05540782ea6b33b19f24be2f17 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:26:22 +0100 Subject: [PATCH 023/116] add moved files to clean up ajax folder --- apps/calendar/ajax/calendar/activation.php | 19 ++ apps/calendar/ajax/calendar/delete.php | 21 ++ apps/calendar/ajax/calendar/edit.form.php | 20 ++ apps/calendar/ajax/calendar/edit.php | 20 ++ apps/calendar/ajax/calendar/new.form.php | 24 ++ apps/calendar/ajax/calendar/new.php | 37 +++ apps/calendar/ajax/calendar/overview.php | 15 ++ .../calendar/ajax/calendar/updatecalendar.php | 38 +++ apps/calendar/ajax/event/delete.php | 19 ++ apps/calendar/ajax/event/edit.form.php | 248 ++++++++++++++++++ apps/calendar/ajax/event/edit.php | 33 +++ apps/calendar/ajax/event/move.php | 43 +++ apps/calendar/ajax/event/new.form.php | 76 ++++++ apps/calendar/ajax/event/new.php | 27 ++ apps/calendar/ajax/event/resize.php | 32 +++ apps/calendar/ajax/import/dialog.php | 17 ++ apps/calendar/ajax/import/import.php | 120 +++++++++ .../ajax/settings/gettimezonedetection.php | 11 + apps/calendar/ajax/settings/guesstimezone.php | 48 ++++ apps/calendar/ajax/settings/settimeformat.php | 17 ++ apps/calendar/ajax/settings/settimezone.php | 27 ++ apps/calendar/ajax/settings/timeformat.php | 12 + .../ajax/settings/timezonedetection.php | 17 ++ apps/calendar/ajax/share/changepermission.php | 40 +++ apps/calendar/ajax/share/dropdown.php | 18 ++ apps/calendar/ajax/share/share.php | 51 ++++ apps/calendar/ajax/share/unshare.php | 44 ++++ 27 files changed, 1094 insertions(+) create mode 100644 apps/calendar/ajax/calendar/activation.php create mode 100644 apps/calendar/ajax/calendar/delete.php create mode 100644 apps/calendar/ajax/calendar/edit.form.php create mode 100644 apps/calendar/ajax/calendar/edit.php create mode 100644 apps/calendar/ajax/calendar/new.form.php create mode 100644 apps/calendar/ajax/calendar/new.php create mode 100644 apps/calendar/ajax/calendar/overview.php create mode 100644 apps/calendar/ajax/calendar/updatecalendar.php create mode 100644 apps/calendar/ajax/event/delete.php create mode 100644 apps/calendar/ajax/event/edit.form.php create mode 100644 apps/calendar/ajax/event/edit.php create mode 100644 apps/calendar/ajax/event/move.php create mode 100644 apps/calendar/ajax/event/new.form.php create mode 100644 apps/calendar/ajax/event/new.php create mode 100644 apps/calendar/ajax/event/resize.php create mode 100644 apps/calendar/ajax/import/dialog.php create mode 100644 apps/calendar/ajax/import/import.php create mode 100644 apps/calendar/ajax/settings/gettimezonedetection.php create mode 100755 apps/calendar/ajax/settings/guesstimezone.php create mode 100644 apps/calendar/ajax/settings/settimeformat.php create mode 100644 apps/calendar/ajax/settings/settimezone.php create mode 100644 apps/calendar/ajax/settings/timeformat.php create mode 100644 apps/calendar/ajax/settings/timezonedetection.php create mode 100644 apps/calendar/ajax/share/changepermission.php create mode 100644 apps/calendar/ajax/share/dropdown.php create mode 100644 apps/calendar/ajax/share/share.php create mode 100644 apps/calendar/ajax/share/unshare.php diff --git a/apps/calendar/ajax/calendar/activation.php b/apps/calendar/ajax/calendar/activation.php new file mode 100644 index 0000000000..7677d85aff --- /dev/null +++ b/apps/calendar/ajax/calendar/activation.php @@ -0,0 +1,19 @@ + + * 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'); +$calendarid = $_POST['calendarid']; +$calendar = OC_Calendar_App::getCalendar($calendarid);//access check +OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); +$calendar = OC_Calendar_App::getCalendar($calendarid); +OC_JSON::success(array( + 'active' => $calendar['active'], + 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), +)); diff --git a/apps/calendar/ajax/calendar/delete.php b/apps/calendar/ajax/calendar/delete.php new file mode 100644 index 0000000000..a2f5311731 --- /dev/null +++ b/apps/calendar/ajax/calendar/delete.php @@ -0,0 +1,21 @@ + + * 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'); + +$cal = $_POST["calendarid"]; +$calendar = OC_Calendar_App::getCalendar($cal); +$del = OC_Calendar_Calendar::deleteCalendar($cal); +if($del == true){ + OC_JSON::success(); +}else{ + OC_JSON::error(array('error'=>'dberror')); +} +?> diff --git a/apps/calendar/ajax/calendar/edit.form.php b/apps/calendar/ajax/calendar/edit.form.php new file mode 100644 index 0000000000..8922b3eba4 --- /dev/null +++ b/apps/calendar/ajax/calendar/edit.form.php @@ -0,0 +1,20 @@ + + * 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/calendar/edit.php b/apps/calendar/ajax/calendar/edit.php new file mode 100644 index 0000000000..8922b3eba4 --- /dev/null +++ b/apps/calendar/ajax/calendar/edit.php @@ -0,0 +1,20 @@ + + * 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/calendar/new.form.php b/apps/calendar/ajax/calendar/new.form.php new file mode 100644 index 0000000000..6e7423cbe9 --- /dev/null +++ b/apps/calendar/ajax/calendar/new.form.php @@ -0,0 +1,24 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); +$l10n = new OC_L10N('calendar'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); +$calendar = array( + 'id' => 'new', + 'displayname' => '', + 'calendarcolor' => '', +); +$tmpl = new OC_Template('calendar', 'part.editcalendar'); +$tmpl->assign('new', true); +$tmpl->assign('calendarcolor_options', $calendarcolor_options); +$tmpl->assign('calendar', $calendar); +$tmpl->printPage(); +?> diff --git a/apps/calendar/ajax/calendar/new.php b/apps/calendar/ajax/calendar/new.php new file mode 100644 index 0000000000..228e624772 --- /dev/null +++ b/apps/calendar/ajax/calendar/new.php @@ -0,0 +1,37 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); + +// Check if we are a user +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +if(trim($_POST['name']) == ''){ + OC_JSON::error(array('message'=>'empty')); + exit; +} +$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +foreach($calendars as $cal){ + if($cal['displayname'] == $_POST['name']){ + OC_JSON::error(array('message'=>'namenotavailable')); + exit; + } +} + +$userid = OC_User::getUser(); +$calendarid = OC_Calendar_Calendar::addCalendar($userid, strip_tags($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); +OC_Calendar_Calendar::setCalendarActive($calendarid, 1); + +$calendar = OC_Calendar_Calendar::find($calendarid); +$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); +$tmpl->assign('calendar', $calendar); +OC_JSON::success(array( + 'page' => $tmpl->fetchPage(), + 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), +)); diff --git a/apps/calendar/ajax/calendar/overview.php b/apps/calendar/ajax/calendar/overview.php new file mode 100644 index 0000000000..2f73f5d071 --- /dev/null +++ b/apps/calendar/ajax/calendar/overview.php @@ -0,0 +1,15 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); +$l10n = new OC_L10N('calendar'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +$output = new OC_TEMPLATE("calendar", "part.choosecalendar"); +$output -> printpage(); +?> diff --git a/apps/calendar/ajax/calendar/updatecalendar.php b/apps/calendar/ajax/calendar/updatecalendar.php new file mode 100644 index 0000000000..f400c8c14b --- /dev/null +++ b/apps/calendar/ajax/calendar/updatecalendar.php @@ -0,0 +1,38 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); + +// Check if we are a user +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +if(trim($_POST['name']) == ''){ + OC_JSON::error(array('message'=>'empty')); + exit; +} +$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +foreach($calendars as $cal){ + if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']){ + OC_JSON::error(array('message'=>'namenotavailable')); + exit; + } +} + +$calendarid = $_POST['id']; +$calendar = OC_Calendar_App::getCalendar($calendarid);//access check +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); +$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); +$tmpl->assign('calendar', $calendar); +OC_JSON::success(array( + 'page' => $tmpl->fetchPage(), + 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar), +)); diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php new file mode 100644 index 0000000000..862dec6bf5 --- /dev/null +++ b/apps/calendar/ajax/event/delete.php @@ -0,0 +1,19 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../../lib/base.php'); + +$l10n = new OC_L10N('calendar'); + +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +$id = $_POST['id']; +$event_object = OC_Calendar_App::getEventObject($id); +$result = OC_Calendar_Object::delete($id); +OC_JSON::success(); +?> diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php new file mode 100644 index 0000000000..837edbbbf0 --- /dev/null +++ b/apps/calendar/ajax/event/edit.form.php @@ -0,0 +1,248 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); + +if(!OC_USER::isLoggedIn()) { + die(''); +} +OC_JSON::checkAppEnabled('calendar'); + +$id = $_GET['id']; +$data = OC_Calendar_App::getEventObject($id); +$object = OC_VObject::parse($data['calendardata']); +$vevent = $object->VEVENT; + +$dtstart = $vevent->DTSTART; +$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); +switch($dtstart->getDateType()) { + case Sabre_VObject_Element_DateTime::LOCALTZ: + case Sabre_VObject_Element_DateTime::LOCAL: + $startdate = $dtstart->getDateTime()->format('d-m-Y'); + $starttime = $dtstart->getDateTime()->format('H:i'); + $enddate = $dtend->getDateTime()->format('d-m-Y'); + $endtime = $dtend->getDateTime()->format('H:i'); + $allday = false; + break; + case Sabre_VObject_Element_DateTime::DATE: + $startdate = $dtstart->getDateTime()->format('d-m-Y'); + $starttime = ''; + $dtend->getDateTime()->modify('-1 day'); + $enddate = $dtend->getDateTime()->format('d-m-Y'); + $endtime = ''; + $allday = true; + break; +} + +$summary = $vevent->getAsString('SUMMARY'); +$location = $vevent->getAsString('LOCATION'); +$categories = $vevent->getAsArray('CATEGORIES'); +$description = $vevent->getAsString('DESCRIPTION'); +foreach($categories as $category){ + if (!in_array($category, $category_options)){ + array_unshift($category_options, $category); + } +} +$last_modified = $vevent->__get('LAST-MODIFIED'); +if ($last_modified){ + $lastmodified = $last_modified->getDateTime()->format('U'); +}else{ + $lastmodified = 0; +} +if($data['repeating'] == 1){ + $rrule = explode(';', $vevent->getAsString('RRULE')); + $rrulearr = array(); + foreach($rrule as $rule){ + list($attr, $val) = explode('=', $rule); + $rrulearr[$attr] = $val; + } + if(!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == ''){ + $rrulearr['INTERVAL'] = 1; + } + if(array_key_exists('BYDAY', $rrulearr)){ + if(substr_count($rrulearr['BYDAY'], ',') == 0){ + if(strlen($rrulearr['BYDAY']) == 2){ + $repeat['weekdays'] = array($rrulearr['BYDAY']); + }elseif(strlen($rrulearr['BYDAY']) == 3){ + $repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 1); + $repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 1, 2)); + }elseif(strlen($rrulearr['BYDAY']) == 4){ + $repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 2); + $repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 2, 2)); + } + }else{ + $byday_days = explode(',', $rrulearr['BYDAY']); + foreach($byday_days as $byday_day){ + if(strlen($byday_day) == 2){ + $repeat['weekdays'][] = $byday_day; + }elseif(strlen($byday_day) == 3){ + $repeat['weekofmonth'] = substr($byday_day , 0, 1); + $repeat['weekdays'][] = substr($byday_day , 1, 2); + }elseif(strlen($byday_day) == 4){ + $repeat['weekofmonth'] = substr($byday_day , 0, 2); + $repeat['weekdays'][] = substr($byday_day , 2, 2); + } + } + } + } + if(array_key_exists('BYMONTHDAY', $rrulearr)){ + if(substr_count($rrulearr['BYMONTHDAY'], ',') == 0){ + $repeat['bymonthday'][] = $rrulearr['BYMONTHDAY']; + }else{ + $bymonthdays = explode(',', $rrulearr['BYMONTHDAY']); + foreach($bymonthdays as $bymonthday){ + $repeat['bymonthday'][] = $bymonthday; + } + } + } + if(array_key_exists('BYYEARDAY', $rrulearr)){ + if(substr_count($rrulearr['BYYEARDAY'], ',') == 0){ + $repeat['byyearday'][] = $rrulearr['BYYEARDAY']; + }else{ + $byyeardays = explode(',', $rrulearr['BYYEARDAY']); + foreach($byyeardays as $yearday){ + $repeat['byyearday'][] = $yearday; + } + } + } + if(array_key_exists('BYWEEKNO', $rrulearr)){ + if(substr_count($rrulearr['BYWEEKNO'], ',') == 0){ + $repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO']; + }else{ + $byweekno = explode(',', $rrulearr['BYWEEKNO']); + foreach($byweekno as $weekno){ + $repeat['byweekno'][] = (string) $weekno; + } + } + } + if(array_key_exists('BYMONTH', $rrulearr)){ + $months = OC_Calendar_App::getByMonthOptions(); + if(substr_count($rrulearr['BYMONTH'], ',') == 0){ + $repeat['bymonth'][] = $months[$month]; + }else{ + $bymonth = explode(',', $rrulearr['BYMONTH']); + foreach($bymonth as $month){ + $repeat['bymonth'][] = $months[$month]; + } + } + } + switch($rrulearr['FREQ']){ + case 'DAILY': + $repeat['repeat'] = 'daily'; + break; + case 'WEEKLY': + if($rrulearr['INTERVAL'] % 2 == 0){ + $repeat['repeat'] = 'biweekly'; + $rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2; + }elseif($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR'){ + $repeat['repeat'] = 'weekday'; + }else{ + $repeat['repeat'] = 'weekly'; + } + break; + case 'MONTHLY': + $repeat['repeat'] = 'monthly'; + if(array_key_exists('BYDAY', $rrulearr)){ + $repeat['month'] = 'weekday'; + }else{ + $repeat['month'] = 'monthday'; + } + break; + case 'YEARLY': + $repeat['repeat'] = 'yearly'; + if(array_key_exists('BYMONTH', $rrulearr)){ + $repeat['year'] = 'bydaymonth'; + }elseif(array_key_exists('BYWEEKNO', $rrulearr)){ + $repeat['year'] = 'byweekno'; + }else{ + $repeat['year'] = 'byyearday'; + } + } + $repeat['interval'] = $rrulearr['INTERVAL']; + if(array_key_exists('COUNT', $rrulearr)){ + $repeat['end'] = 'count'; + $repeat['count'] = $rrulearr['COUNT']; + }elseif(array_key_exists('UNTIL', $rrulearr)){ + $repeat['end'] = 'date'; + $endbydate_day = substr($rrulearr['UNTIL'], 6, 2); + $endbydate_month = substr($rrulearr['UNTIL'], 4, 2); + $endbydate_year = substr($rrulearr['UNTIL'], 0, 4); + $repeat['date'] = $endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year; + }else{ + $repeat['end'] = 'never'; + } + if(array_key_exists('weekdays', $repeat)){ + $repeat_weekdays_ = array(); + $days = OC_Calendar_App::getWeeklyOptions(); + foreach($repeat['weekdays'] as $weekday){ + $repeat_weekdays_[] = $days[$weekday]; + } + $repeat['weekdays'] = $repeat_weekdays_; + } +}else{ + $repeat['repeat'] = 'doesnotrepeat'; +} + +$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$category_options = OC_Calendar_App::getCategoryOptions(); +$repeat_options = OC_Calendar_App::getRepeatOptions(); +$repeat_end_options = OC_Calendar_App::getEndOptions(); +$repeat_month_options = OC_Calendar_App::getMonthOptions(); +$repeat_year_options = OC_Calendar_App::getYearOptions(); +$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions(); +$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth(); +$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions(); +$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); +$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); +$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); + +$tmpl = new OC_Template('calendar', 'part.editevent'); +$tmpl->assign('id', $id); +$tmpl->assign('lastmodified', $lastmodified); +$tmpl->assign('calendar_options', $calendar_options); +$tmpl->assign('category_options', $category_options); +$tmpl->assign('repeat_options', $repeat_options); +$tmpl->assign('repeat_month_options', $repeat_month_options); +$tmpl->assign('repeat_weekly_options', $repeat_weekly_options); +$tmpl->assign('repeat_end_options', $repeat_end_options); +$tmpl->assign('repeat_year_options', $repeat_year_options); +$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options); +$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options); +$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options); +$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options); +$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options); + +$tmpl->assign('title', $summary); +$tmpl->assign('location', $location); +$tmpl->assign('categories', $categories); +$tmpl->assign('calendar', $data['calendarid']); +$tmpl->assign('allday', $allday); +$tmpl->assign('startdate', $startdate); +$tmpl->assign('starttime', $starttime); +$tmpl->assign('enddate', $enddate); +$tmpl->assign('endtime', $endtime); +$tmpl->assign('description', $description); + +$tmpl->assign('repeat', $repeat['repeat']); +if($repeat['repeat'] != 'doesnotrepeat'){ + $tmpl->assign('repeat_month', $repeat['month']); + $tmpl->assign('repeat_weekdays', $repeat['weekdays']); + $tmpl->assign('repeat_interval', $repeat['interval']); + $tmpl->assign('repeat_end', $repeat['end']); + $tmpl->assign('repeat_count', $repeat['count']); + $tmpl->assign('repeat_weekofmonth', $repeat['weekofmonth']); + $tmpl->assign('repeat_date', $repeat['date']); + $tmpl->assign('repeat_year', $repeat['year']); + $tmpl->assign('repeat_byyearday', $repeat['byyearday']); + $tmpl->assign('repeat_bymonthday', $repeat['bymonthday']); + $tmpl->assign('repeat_bymonth', $repeat['bymonth']); + $tmpl->assign('repeat_byweekno', $repeat['byweekno']); +} +$tmpl->printpage(); + +?> \ No newline at end of file diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php new file mode 100644 index 0000000000..64daffddef --- /dev/null +++ b/apps/calendar/ajax/event/edit.php @@ -0,0 +1,33 @@ + + * 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'); + +$errarr = OC_Calendar_Object::validateRequest($_POST); +if($errarr){ + //show validate errors + OC_JSON::error($errarr); + exit; +}else{ + $id = $_POST['id']; + $cal = $_POST['calendar']; + $data = OC_Calendar_App::getEventObject($id); + $vcalendar = OC_VObject::parse($data['calendardata']); + + OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']); + OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar); + + $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); + if ($data['calendarid'] != $cal) { + OC_Calendar_Object::moveToCalendar($id, $cal); + } + OC_JSON::success(); +} +?> diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php new file mode 100644 index 0000000000..8150fdbaa3 --- /dev/null +++ b/apps/calendar/ajax/event/move.php @@ -0,0 +1,43 @@ + + * 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(); + +$id = $_POST['id']; + +$vcalendar = OC_Calendar_App::getVCalendar($id); +$vevent = $vcalendar->VEVENT; + +$allday = $_POST['allDay']; +$delta = new DateInterval('P0D'); +$delta->d = $_POST['dayDelta']; +$delta->i = $_POST['minuteDelta']; + +OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); + +$dtstart = $vevent->DTSTART; +$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); +$start_type = $dtstart->getDateType(); +$end_type = $dtend->getDateType(); +if ($allday && $start_type != Sabre_VObject_Element_DateTime::DATE){ + $start_type = $end_type = Sabre_VObject_Element_DateTime::DATE; + $dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type); +} +if (!$allday && $start_type == Sabre_VObject_Element_DateTime::DATE){ + $start_type = $end_type = Sabre_VObject_Element_DateTime::LOCALTZ; +} +$dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type); +$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); +unset($vevent->DURATION); + +$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); +$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); + +$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); +$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); +OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php new file mode 100644 index 0000000000..c19928a727 --- /dev/null +++ b/apps/calendar/ajax/event/new.form.php @@ -0,0 +1,76 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); + +if(!OC_USER::isLoggedIn()) { + die(''); +} +OC_JSON::checkAppEnabled('calendar'); + +if (!isset($_POST['start'])){ + OC_JSON::error(); + die; +} +$start = $_POST['start']; +$end = $_POST['end']; +$allday = $_POST['allday']; + +if (!$end){ + $duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', '60'); + $end = $start + ($duration * 60); +} +$start = new DateTime('@'.$start); +$end = new DateTime('@'.$end); +$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$start->setTimezone(new DateTimeZone($timezone)); +$end->setTimezone(new DateTimeZone($timezone)); + +$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +$category_options = OC_Calendar_App::getCategoryOptions(); +$repeat_options = OC_Calendar_App::getRepeatOptions(); +$repeat_end_options = OC_Calendar_App::getEndOptions(); +$repeat_month_options = OC_Calendar_App::getMonthOptions(); +$repeat_year_options = OC_Calendar_App::getYearOptions(); +$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions(); +$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth(); +$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions(); +$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); +$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); +$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); + +$tmpl = new OC_Template('calendar', 'part.newevent'); +$tmpl->assign('calendar_options', $calendar_options); +$tmpl->assign('category_options', $category_options); +$tmpl->assign('repeat_options', $repeat_options); +$tmpl->assign('repeat_month_options', $repeat_month_options); +$tmpl->assign('repeat_weekly_options', $repeat_weekly_options); +$tmpl->assign('repeat_end_options', $repeat_end_options); +$tmpl->assign('repeat_year_options', $repeat_year_options); +$tmpl->assign('repeat_byyearday_options', $repeat_byyearday_options); +$tmpl->assign('repeat_bymonth_options', $repeat_bymonth_options); +$tmpl->assign('repeat_byweekno_options', $repeat_byweekno_options); +$tmpl->assign('repeat_bymonthday_options', $repeat_bymonthday_options); +$tmpl->assign('repeat_weekofmonth_options', $repeat_weekofmonth_options); + +$tmpl->assign('startdate', $start->format('d-m-Y')); +$tmpl->assign('starttime', $start->format('H:i')); +$tmpl->assign('enddate', $end->format('d-m-Y')); +$tmpl->assign('endtime', $end->format('H:i')); +$tmpl->assign('allday', $allday); +$tmpl->assign('repeat', 'doesnotrepeat'); +$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(); +?> diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php new file mode 100644 index 0000000000..59fda79da7 --- /dev/null +++ b/apps/calendar/ajax/event/new.php @@ -0,0 +1,27 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +require_once('../../../../lib/base.php'); + +$l10n = new OC_L10N('calendar'); + +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +$errarr = OC_Calendar_Object::validateRequest($_POST); +if($errarr){ + //show validate errors + OC_JSON::error($errarr); + exit; +}else{ + $cal = $_POST['calendar']; + $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST); + $result = OC_Calendar_Object::add($cal, $vcalendar->serialize()); + OC_JSON::success(); +} +?> diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php new file mode 100644 index 0000000000..aa2d420e77 --- /dev/null +++ b/apps/calendar/ajax/event/resize.php @@ -0,0 +1,32 @@ + + * 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(); + +$id = $_POST['id']; + +$vcalendar = OC_Calendar_App::getVCalendar($id); +$vevent = $vcalendar->VEVENT; + +$delta = new DateInterval('P0D'); +$delta->d = $_POST['dayDelta']; +$delta->i = $_POST['minuteDelta']; + +OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); + +$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); +$end_type = $dtend->getDateType(); +$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type); +unset($vevent->DURATION); + +$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); +$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); + +$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); +$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); +OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); diff --git a/apps/calendar/ajax/import/dialog.php b/apps/calendar/ajax/import/dialog.php new file mode 100644 index 0000000000..2e00209215 --- /dev/null +++ b/apps/calendar/ajax/import/dialog.php @@ -0,0 +1,17 @@ + + * 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_Util::checkAppEnabled('calendar'); +$l10n = new OC_L10N('calendar'); +$tmpl = new OC_Template('calendar', 'part.import'); +$tmpl->assign('path', $_POST['path']); +$tmpl->assign('filename', $_POST['filename']); +$tmpl->printpage(); +?> diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php new file mode 100644 index 0000000000..96d7af4834 --- /dev/null +++ b/apps/calendar/ajax/import/import.php @@ -0,0 +1,120 @@ + + * 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/settings/gettimezonedetection.php b/apps/calendar/ajax/settings/gettimezonedetection.php new file mode 100644 index 0000000000..11255fe8ef --- /dev/null +++ b/apps/calendar/ajax/settings/gettimezonedetection.php @@ -0,0 +1,11 @@ + + * 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'); +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/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php new file mode 100755 index 0000000000..cfa92e1aee --- /dev/null +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -0,0 +1,48 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +function make_array_out_of_xml ($xml){ + $returnarray = array(); + $xml = (array)$xml ; + foreach ($xml as $property => $value){ + $value = (array)$value; + if(!isset($value[0])){ + $returnarray[$property] = make_array_out_of_xml($value); + }else{ + $returnarray[$property] = trim($value[0]); + } + } + return $returnarray; +} +require_once('../../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); +$l = new OC_L10N('calendar'); +$lat = $_GET['lat']; +$long = $_GET['long']; +if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'position') == $lat . '-' . $long && OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone') != null){ + OC_JSON::success(); + exit; +} +OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'position', $lat . '-' . $long); +$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long); +//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License +$geoxml = simplexml_load_string($geolocation); +$geoarray = make_array_out_of_xml($geoxml); +if($geoarray['timezone']['timezoneId'] == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){ + OC_JSON::success(); + exit; +} +if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']); + $message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']); + OC_JSON::success($message); +}else{ + OC_JSON::error(); +} + +?> diff --git a/apps/calendar/ajax/settings/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php new file mode 100644 index 0000000000..8f65447065 --- /dev/null +++ b/apps/calendar/ajax/settings/settimeformat.php @@ -0,0 +1,17 @@ + + * 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(); +if(isset($_POST["timeformat"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php new file mode 100644 index 0000000000..c639753fe2 --- /dev/null +++ b/apps/calendar/ajax/settings/settimezone.php @@ -0,0 +1,27 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +// Init owncloud +require_once('../../../../lib/base.php'); + +$l=new OC_L10N('calendar'); + +// Check if we are a user +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); + +// Get data +if( isset( $_POST['timezone'] ) ){ + $timezone=$_POST['timezone']; + OC_Preferences::setValue( OC_User::getUser(), 'calendar', 'timezone', $timezone ); + OC_JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') ))); +}else{ + OC_JSON::error(array('data' => array( 'message' => $l->t('Invalid request') ))); +} + +?> diff --git a/apps/calendar/ajax/settings/timeformat.php b/apps/calendar/ajax/settings/timeformat.php new file mode 100644 index 0000000000..e0dbe8d3cd --- /dev/null +++ b/apps/calendar/ajax/settings/timeformat.php @@ -0,0 +1,12 @@ + + * 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(); +$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24"); +OC_JSON::encodedPrint(array("timeformat" => $timeformat)); +?> diff --git a/apps/calendar/ajax/settings/timezonedetection.php b/apps/calendar/ajax/settings/timezonedetection.php new file mode 100644 index 0000000000..f67bab901e --- /dev/null +++ b/apps/calendar/ajax/settings/timezonedetection.php @@ -0,0 +1,17 @@ + + * 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'); +if($_POST['timezonedetection'] == 'on'){ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true'); +}else{ + OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false'); +} +OC_JSON::success(); + diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php new file mode 100644 index 0000000000..d91f87b613 --- /dev/null +++ b/apps/calendar/ajax/share/changepermission.php @@ -0,0 +1,40 @@ + + * 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 0000000000..eb396d38fd --- /dev/null +++ b/apps/calendar/ajax/share/dropdown.php @@ -0,0 +1,18 @@ + + * 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 0000000000..d892727701 --- /dev/null +++ b/apps/calendar/ajax/share/share.php @@ -0,0 +1,51 @@ + + * 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 0000000000..ec3150a89a --- /dev/null +++ b/apps/calendar/ajax/share/unshare.php @@ -0,0 +1,44 @@ + + * 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 From 1cf7fc261f1a6a9b7307735ee4808970ebff9073 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:26:43 +0100 Subject: [PATCH 024/116] better var name in changeview.php --- apps/calendar/ajax/changeview.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index df3e2827b7..034c7129ca 100644 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -9,16 +9,16 @@ require_once ('../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); -$currentview = $_GET['v']; -switch($currentview){ +$view = $_GET['v']; +switch($view){ case 'agendaWeek': case 'month'; case 'list': break; default: - OC_JSON::error(); + OC_JSON::error(array('message'=>'unexspected parameter: ' . $view)); exit; } -OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $currentview); +OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $view); OC_JSON::success(); ?> \ No newline at end of file From 3efa69bc848dc99754f788893cc82cd11fc4316f Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:27:25 +0100 Subject: [PATCH 025/116] update js files for new ajax pathes --- apps/calendar/js/calendar.js | 30 +++++++++++++++--------------- apps/calendar/js/geo.js | 2 +- apps/calendar/js/loader.js | 6 +++--- apps/calendar/js/settings.js | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index cf0bb079c8..e9c33f7c45 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -70,7 +70,7 @@ Calendar={ $('#event').dialog('destroy').remove(); }else{ Calendar.UI.loading(true); - $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog); + $('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'new.form.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog); } }, editEvent:function(calEvent, jsEvent, view){ @@ -80,7 +80,7 @@ Calendar={ $('#event').dialog('destroy').remove(); }else{ Calendar.UI.loading(true); - $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog); + $('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'edit.form.php') + '?id=' + id, Calendar.UI.startEventDialog); } }, submitDeleteEventForm:function(url){ @@ -142,7 +142,7 @@ Calendar={ moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){ $('.tipsy').remove(); Calendar.UI.loading(true); - $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified}, + $.post(OC.filePath('calendar', 'ajax/event', 'move.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified}, function(data) { Calendar.UI.loading(false); if (data.status == 'success'){ @@ -157,7 +157,7 @@ Calendar={ resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){ $('.tipsy').remove(); Calendar.UI.loading(true); - $.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified}, + $.post(OC.filePath('calendar', 'ajax/event', 'resize.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified}, function(data) { Calendar.UI.loading(false); if (data.status == 'success'){ @@ -374,7 +374,7 @@ Calendar={ $('#choosecalendar_dialog').dialog('moveToTop'); }else{ Calendar.UI.loading(true); - $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){ + $('#dialog_holder').load(OC.filePath('calendar', 'ajax/calendar', 'overview.php'), function(){ $('#choosecalendar_dialog').dialog({ width : 600, close : function(event, ui) { @@ -388,7 +388,7 @@ Calendar={ activation:function(checkbox, calendarid) { Calendar.UI.loading(true); - $.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 }, + $.post(OC.filePath('calendar', 'ajax/calendar', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 }, function(data) { Calendar.UI.loading(false); if (data.status == 'success'){ @@ -403,13 +403,13 @@ Calendar={ }, newCalendar:function(object){ var tr = $(document.createElement('tr')) - .load(OC.filePath('calendar', 'ajax', 'newcalendar.php'), + .load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'), function(){Calendar.UI.Calendar.colorPicker(this)}); $(object).closest('tr').after(tr).hide(); }, edit:function(object, calendarid){ var tr = $(document.createElement('tr')) - .load(OC.filePath('calendar', 'ajax', 'editcalendar.php') + "?calendarid="+calendarid, + .load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php') + "?calendarid="+calendarid, function(){Calendar.UI.Calendar.colorPicker(this)}); $(object).closest('tr').after(tr).hide(); }, @@ -418,7 +418,7 @@ Calendar={ if(check == false){ return false; }else{ - $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid}, + $.post(OC.filePath('calendar', 'ajax/calendar', 'delete.php'), { calendarid: calid}, function(data) { if (data.status == 'success'){ var url = 'ajax/events.php?calendar_id='+calid; @@ -443,9 +443,9 @@ Calendar={ var url; if (calendarid == 'new'){ - url = OC.filePath('calendar', 'ajax', 'createcalendar.php'); + url = OC.filePath('calendar', 'ajax/calendar', 'new.php'); }else{ - url = OC.filePath('calendar', 'ajax', 'updatecalendar.php'); + url = OC.filePath('calendar', 'ajax/calendar', 'update.php'); } $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor }, function(data){ @@ -500,7 +500,7 @@ Calendar={ dropdown:function(userid, calid){ $('.calendar_share_dropdown').remove(); $('
      ').appendTo('#'+userid+'_'+calid); - $.get(OC.filePath('calendar', 'ajax', 'share.dropdown.php') + '?calid=' + calid, function(data){ + $.get(OC.filePath('calendar', 'ajax/share', 'dropdown.php') + '?calid=' + calid, function(data){ $('#'+userid+'_'+calid+' > .calendar_share_dropdown').html(data); $('#'+userid+'_'+calid+' > .calendar_share_dropdown').show('blind'); $('#share_user').chosen(); @@ -510,7 +510,7 @@ Calendar={ Calendar.UI.Share.idtype = 'calendar'; }, share:function(id, idtype, sharewith, sharetype){ - $.getJSON(OC.filePath('calendar', 'ajax', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){ + $.getJSON(OC.filePath('calendar', 'ajax/share', 'share.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(data){ if(sharetype == 'public'){ $('#public_token').val(OC.linkTo('calendar', 'share.php?t=' + data.message)); $('#public_token').css('display', 'block'); @@ -518,7 +518,7 @@ Calendar={ }); }, unshare:function(id, idtype, sharewith, sharetype){ - $.getJSON(OC.filePath('calendar', 'ajax', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){ + $.getJSON(OC.filePath('calendar', 'ajax/share', 'unshare.php'),{id:id, idtype:idtype, sharewith:sharewith, sharetype:sharetype}, function(){ if(sharetype == 'public'){ $('#public_token').val(''); $('#public_token').css('display', 'none'); @@ -526,7 +526,7 @@ Calendar={ }); }, changepermission:function(id, idtype, sharewith, sharetype, permission){ - $.getJSON(OC.filePath('calendar', 'ajax', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)}); + $.getJSON(OC.filePath('calendar', 'ajax/share', 'changepermission.php'),{id:id, idtype:idtype, sharewith: sharewith, sharetype:sharetype, permission: (permission?1:0)}); }, init:function(){ $('.calendar_share_dropdown').live('mouseleave', function(){ diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js index ae6a971e93..c9cc5dd095 100755 --- a/apps/calendar/js/geo.js +++ b/apps/calendar/js/geo.js @@ -6,7 +6,7 @@ */ if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { - $.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''), + $.getJSON(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''), function(data){ if (data.status == 'success' && typeof(data.message) != 'undefined'){ $('#notification').html(data.message); diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index 4e483f9864..5400387975 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -8,7 +8,7 @@ Calendar_Import={ importdialog: function(filename){ var path = $('#dir').val(); $('body').append('
      '); - $('#calendar_import').load(OC.filePath('calendar', 'ajax', 'importdialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);}); + $('#calendar_import').load(OC.filePath('calendar', 'ajax/import', 'dialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);}); }, initdialog: function(filename){ $('#calendar_import_dialog').dialog({ @@ -68,7 +68,7 @@ Calendar_Import={ if(percent < 100){ window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500); }else{ - $('#import_done').css('display', 'block'); + $('#import_done').css('display', 'block'); } }); } @@ -78,4 +78,4 @@ $(document).ready(function(){ FileActions.register('text/calendar','importcal', '', Calendar_Import.importdialog); FileActions.setDefault('text/calendar','importcal'); }; -}); \ No newline at end of file +}); diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 7330088556..fcbfc423db 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -3,7 +3,7 @@ $(document).ready(function(){ OC.msg.startSaving('#calendar .msg') // Serialize the data var post = $( '#timezone' ).serialize(); - $.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){ + $.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){ //OC.msg.finishedSaving('#calendar .msg', data); }); return false; @@ -11,7 +11,7 @@ $(document).ready(function(){ $('#timezone').chosen(); $('#timeformat').change( function(){ var data = $('#timeformat').serialize(); - $.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){ + $.post( OC.filePath('calendar', 'ajax/settings', 'settimeformat.php'), data, function(data){ if(data == 'error'){ console.log('saving timeformat failed'); } @@ -19,15 +19,15 @@ $(document).ready(function(){ }); $('#timezonedetection').change( function(){ var post = $('#timezonedetection').serialize(); - $.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){ + $.post( OC.filePath('calendar', 'ajax/settings', 'timezonedetection.php'), post, function(data){ }); }); - $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { + $.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) { $('#' + jsondata.timeformat).attr('selected',true); $('#timeformat').chosen(); }); - $.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){ + $.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){ if(jsondata.detection == 'true'){ $('#timezonedetection').attr('checked', 'checked'); } From 548a2e6263121b63102bffb8e2558763a9234eba Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:28:20 +0100 Subject: [PATCH 026/116] add readonly calendar to the eventsources --- apps/calendar/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 3a7d09c98a..9f8a495579 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -19,7 +19,8 @@ $eventSources = array(); foreach($calendars as $calendar){ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar); } -$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'false'); +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_readwrite', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true'); +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=calendar_readonly, 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); //Fix currentview for fullcalendar if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek"); From 619c62e681307b769af4aca56acb117de9768995 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:31:41 +0100 Subject: [PATCH 027/116] change parameter names for shared calendars --- apps/calendar/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 9f8a495579..117272ebc4 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -19,8 +19,8 @@ $eventSources = array(); foreach($calendars as $calendar){ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar); } -$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_readwrite', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true'); -$eventSources[] = array('url' => 'ajax/events.php?calendar_id=calendar_readonly, 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true'); +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_r, 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); //Fix currentview for fullcalendar if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek"); From ec7ed3c88228063af3221ccbdfe9add28eac0422 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:35:19 +0100 Subject: [PATCH 028/116] add rw and r to events.php --- apps/calendar/ajax/events.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 96ee6775f7..1747b2ac1a 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -13,8 +13,8 @@ OC_JSON::checkAppEnabled('calendar'); $start = DateTime::createFromFormat('U', $_GET['start']); $end = DateTime::createFromFormat('U', $_GET['end']); -if($_GET['calendar_id'] == 'shared'){ - $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1); +if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ + $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); $events = array(); foreach($calendars as $calendar){ $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end); @@ -80,4 +80,4 @@ foreach($events as $event){ } } OC_JSON::encodedPrint($return); -?> \ No newline at end of file +?> From a069d83f4438ddbbde05bc80f9790be7b0781957 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:46:10 +0100 Subject: [PATCH 029/116] fix unexspected T-String in calendars index.php --- apps/calendar/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 117272ebc4..e3f108afc0 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -20,7 +20,7 @@ foreach($calendars as $calendar){ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar); } $eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_rw', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable'=>'true'); -$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_r, 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); +$eventSources[] = array('url' => 'ajax/events.php?calendar_id=shared_r', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); //Fix currentview for fullcalendar if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek"); From 0ae2e250f5179991b58c2ebff94e206e5a628e73 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 20 Feb 2012 11:52:19 +0100 Subject: [PATCH 030/116] change pathes in calendar/templates/* files to make them work with the new folder structure in /calendar/ajax --- apps/calendar/templates/part.editevent.php | 2 +- apps/calendar/templates/part.newevent.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index b3acfc4a07..7631d298be 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -5,7 +5,7 @@ inc("part.eventform"); ?>
      - " onclick="Calendar.UI.validateEventForm('ajax/editevent.php');"> + " onclick="Calendar.UI.validateEventForm('ajax/events/edit.php');"> " onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');"> " onclick="window.location='export.php?eventid=';"> diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php index b1e2a5eab8..85cce80287 100644 --- a/apps/calendar/templates/part.newevent.php +++ b/apps/calendar/templates/part.newevent.php @@ -3,7 +3,7 @@ inc("part.eventform"); ?>
      - " onclick="Calendar.UI.validateEventForm('ajax/newevent.php');"> + " onclick="Calendar.UI.validateEventForm('ajax/events/new.php');"> From 70a369e16d9499ed76e3bf18713beb0176a528fd Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 21 Feb 2012 19:16:14 +0100 Subject: [PATCH 031/116] change links in the event form for the new ajax folders --- apps/calendar/templates/part.editevent.php | 4 ++-- apps/calendar/templates/part.newevent.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index 7631d298be..6e319e1b4e 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -5,8 +5,8 @@ inc("part.eventform"); ?>
      - " onclick="Calendar.UI.validateEventForm('ajax/events/edit.php');"> - " onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');"> + " onclick="Calendar.UI.validateEventForm('ajax/event/edit.php');"> + " onclick="Calendar.UI.submitDeleteEventForm('ajax/event/delete.php');"> " onclick="window.location='export.php?eventid=';"> diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php index 85cce80287..1141626034 100644 --- a/apps/calendar/templates/part.newevent.php +++ b/apps/calendar/templates/part.newevent.php @@ -3,7 +3,7 @@ inc("part.eventform"); ?>
      - " onclick="Calendar.UI.validateEventForm('ajax/events/new.php');"> + " onclick="Calendar.UI.validateEventForm('ajax/event/new.php');"> From 236d2aa5b8d1cf7700d2996b11ec8e3bd4c153c3 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 21 Feb 2012 19:42:48 +0100 Subject: [PATCH 032/116] rename updatecalendar to update --- apps/calendar/ajax/calendar/{updatecalendar.php => update.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/calendar/ajax/calendar/{updatecalendar.php => update.php} (100%) diff --git a/apps/calendar/ajax/calendar/updatecalendar.php b/apps/calendar/ajax/calendar/update.php similarity index 100% rename from apps/calendar/ajax/calendar/updatecalendar.php rename to apps/calendar/ajax/calendar/update.php From 3d8d6d718b65a972648ce7678cda13b2e1117272 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 21 Feb 2012 20:10:52 +0100 Subject: [PATCH 033/116] add 'permissions' as a sql condition in allSharedwithuser --- apps/calendar/lib/share.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index d66095b977..be2b440c64 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -17,7 +17,7 @@ class OC_Calendar_Share{ * @param: (string) $type - use const self::CALENDAR or self::EVENT * @return: (array) $return - information about calendars */ - public static function allSharedwithuser($userid, $type, $active=null){ + public static function allSharedwithuser($userid, $type, $active=null, $permission=null){ $group_where = ''; $groups = OC_Group::getUserGroups($userid); $i = 0; @@ -30,7 +30,12 @@ class OC_Calendar_Share{ $group_where .= ' (share = \'' . $group . '\' AND sharetype = \'group\') '; $i++; } - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = \'user\') ' . $group_where . ') AND owner <> ?' . ((!is_null($active) && $active)?' AND active = 1)':')')); + $permission_where = ''; + if(!is_null($permission)){ + $permission_where = 'AND permissions = '; + $permission_where .= ($permission=='rw')?'1':'0'; + } + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = \'user\') ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . ((!is_null($active) && $active)?' AND active = 1)':')')); $result = $stmt->execute(array($userid, $userid)); $return = array(); while( $row = $result->fetchRow()){ From d20b8399c395605da8a5c908c21963f1f4bdca97 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 Feb 2012 10:20:58 +0100 Subject: [PATCH 034/116] clean up sql commands in OC_Calendar_Share --- apps/calendar/lib/share.php | 54 ++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index be2b440c64..621ff8ce21 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -18,24 +18,10 @@ class OC_Calendar_Share{ * @return: (array) $return - information about calendars */ public static function allSharedwithuser($userid, $type, $active=null, $permission=null){ - $group_where = ''; - $groups = OC_Group::getUserGroups($userid); - $i = 0; - foreach($groups as $group){ - if($i == 0){ - $group_where = 'OR ('; - }else{ - $group_where .= ' OR '; - } - $group_where .= ' (share = \'' . $group . '\' AND sharetype = \'group\') '; - $i++; - } - $permission_where = ''; - if(!is_null($permission)){ - $permission_where = 'AND permissions = '; - $permission_where .= ($permission=='rw')?'1':'0'; - } - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = \'user\') ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . ((!is_null($active) && $active)?' AND active = 1)':')')); + $group_where = self::group_sql(OC_Group::getUserGroups($userid)); + $permission_where = self::permission_sql($permission); + $active_where = self::active_sql($active); + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where . ')'); $result = $stmt->execute(array($userid, $userid)); $return = array(); while( $row = $result->fetchRow()){ @@ -157,7 +143,7 @@ class OC_Calendar_Share{ * @param: (string) $type - use const self::CALENDAR or self::EVENT * @return (bool) */ - private static function is_already_shared($owner, $share, $sharetype, $id, $type){ + public static function is_already_shared($owner, $share, $sharetype, $id, $type){ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE owner = ? AND share = ? AND sharetype = ? AND ' . $type . 'id = ?'); $result = $stmt->execute(array($owner, $share, $sharetype, $id)); if($result->numRows() > 0){ @@ -165,4 +151,34 @@ class OC_Calendar_Share{ } return false; } + private static function group_sql($groups){ + $group_where = ''; + $i = 0; + foreach($groups as $group){ + if($i == 0){ + $group_where = 'OR ('; + }else{ + $group_where .= ' OR '; + } + $group_where .= ' (share = "' . $group . '" AND sharetype = "group") '; + $i++; + } + return $group_where; + } + private static function permission_sql($permission = null){ + $permission_where = ''; + if(!is_null($permission)){ + $permission_where = 'AND permissions = '; + $permission_where .= ($permission=='rw')?'1':'0'; + } + return $permission_where; + } + private static function active_sql($active = null){ + $active_where = ''; + if(!is_null($active)){ + $active_where = 'AND active = '; + $active_where .= (!is_null($active) && $active)?'1':'0'; + } + return $active_where; + } } \ No newline at end of file From 48f42176cdc1d75f2b9cd7b5c6d0cc4ee9050ced Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 Feb 2012 10:41:16 +0100 Subject: [PATCH 035/116] add is_editing_allowed function to OC_Calendar_Share --- apps/calendar/lib/share.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index 621ff8ce21..a5ca0a6e73 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -181,4 +181,21 @@ class OC_Calendar_Share{ } return $active_where; } + /* + * @brief: checks the permission for editing an event + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function is_editing_allowed($share, $id, $type){ + $group_where = self::group_sql(OC_Group::getUserGroups($share)); + $permission_where = self::permission_sql('rw'); + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where . ')'); + $result = $stmt->execute(array($share)); + if($result->numRows() == 1){ + return true; + } + return false; + } } \ No newline at end of file From 0ae088a50a42fa73b2afb87d0fe80dea2129c430 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 Feb 2012 10:42:01 +0100 Subject: [PATCH 036/116] add getowner function to OC_Calendar_Object --- apps/calendar/lib/object.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index cbb1badf80..a7ee5bd108 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -816,4 +816,9 @@ class OC_Calendar_Object{ return $vcalendar; } + public static function getowner($id){ + $event = self::find($id); + $cal = OC_Calendar_Calendar::find($event['calendarid']); + return $cal['userid']; + } } \ No newline at end of file From cff0ac2bf99c9655f0ff792ec16bc0c624b07194 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 Feb 2012 10:42:33 +0100 Subject: [PATCH 037/116] better permission check in resize.php --- apps/calendar/ajax/event/resize.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php index aa2d420e77..1136273b70 100644 --- a/apps/calendar/ajax/event/resize.php +++ b/apps/calendar/ajax/event/resize.php @@ -10,6 +10,11 @@ OC_JSON::checkLoggedIn(); $id = $_POST['id']; +if(!OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT) && OC_Calendar_Object::getowner($id) != OC_User::getUser()){ + OC_JSON::error(array('message'=>'permissiondenied')); + exit; +} + $vcalendar = OC_Calendar_App::getVCalendar($id); $vevent = $vcalendar->VEVENT; From 9460c9e907f1dd80e4978e23911975bc775e7260 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 Feb 2012 11:53:28 +0100 Subject: [PATCH 038/116] remove old import.php --- apps/calendar/import.php | 120 --------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 apps/calendar/import.php diff --git a/apps/calendar/import.php b/apps/calendar/import.php deleted file mode 100644 index b1c6f91df8..0000000000 --- a/apps/calendar/import.php +++ /dev/null @@ -1,120 +0,0 @@ - - * 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 = '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 From b7a5ae38c58cc9a1973febfce40c5f076ff5d772 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 09:48:58 +0200 Subject: [PATCH 039/116] fix sql command in calendar's share lib --- apps/calendar/lib/share.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index a5ca0a6e73..def1026c5e 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -21,7 +21,7 @@ class OC_Calendar_Share{ $group_where = self::group_sql(OC_Group::getUserGroups($userid)); $permission_where = self::permission_sql($permission); $active_where = self::active_sql($active); - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where . ')'); + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where); $result = $stmt->execute(array($userid, $userid)); $return = array(); while( $row = $result->fetchRow()){ @@ -168,8 +168,8 @@ class OC_Calendar_Share{ private static function permission_sql($permission = null){ $permission_where = ''; if(!is_null($permission)){ - $permission_where = 'AND permissions = '; - $permission_where .= ($permission=='rw')?'1':'0'; + $permission_where = ' AND permissions = '; + $permission_where .= ($permission=='rw')?'"1"':'"0"'; } return $permission_where; } From 71b32f7ad4684360f460726977fb3d803f7bb48a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 15:24:43 +0200 Subject: [PATCH 040/116] add read only 'form' for shared events --- apps/calendar/ajax/event/edit.form.php | 18 +- apps/calendar/lib/app.php | 25 ++- apps/calendar/lib/share.php | 26 ++- apps/calendar/templates/part.eventform.php | 1 + apps/calendar/templates/part.showevent.php | 249 +++++++++++++++++++++ 5 files changed, 308 insertions(+), 11 deletions(-) create mode 100644 apps/calendar/templates/part.showevent.php diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 837edbbbf0..ab77a747f1 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -18,6 +18,12 @@ $data = OC_Calendar_App::getEventObject($id); $object = OC_VObject::parse($data['calendardata']); $vevent = $object->VEVENT; +$access = OC_Calendar_App::check_access($id); +if(!$access){ + OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); + exit; +} + $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); switch($dtstart->getDateType()) { @@ -187,8 +193,9 @@ if($data['repeating'] == 1){ }else{ $repeat['repeat'] = 'doesnotrepeat'; } - -$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +if($access == 'owner'){ + $calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); +} $category_options = OC_Calendar_App::getCategoryOptions(); $repeat_options = OC_Calendar_App::getRepeatOptions(); $repeat_end_options = OC_Calendar_App::getEndOptions(); @@ -201,7 +208,12 @@ $repeat_bymonth_options = OC_Calendar_App::getByMonthOptions(); $repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions(); $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions(); -$tmpl = new OC_Template('calendar', 'part.editevent'); +if($access == 'owner' || $access == 'rw'){ + $tmpl = new OC_Template('calendar', 'part.editevent'); +}elseif($access == 'r'){ + $tmpl = new OC_Template('calendar', 'part.showevent'); +} + $tmpl->assign('id', $id); $tmpl->assign('lastmodified', $lastmodified); $tmpl->assign('calendar_options', $calendar_options); diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index f50c65ab4f..b4d9f844c1 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -14,12 +14,7 @@ class OC_Calendar_App{ public static $l10n; public static function getCalendar($id){ - $calendar = OC_Calendar_Calendar::find( $id ); - if( $calendar === false || $calendar['userid'] != OC_User::getUser()){ - OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); - exit(); - } - return $calendar; + return OC_Calendar_Calendar::find( $id ); } public static function getEventObject($id){ @@ -29,10 +24,26 @@ class OC_Calendar_App{ exit(); } - self::getCalendar( $event_object['calendarid'] );//access check + //self::getCalendar( $event_object['calendarid'] );//access check return $event_object; } + public static function check_access($id){ + $event_object = self::getEventObject($id); + $calendar = self::getCalendar($event_object['calendarid']); + if($calendar['userid'] == OC_User::getUser()){ + return 'owner'; + } + if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){ + if(OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){ + return 'rw'; + }else{ + return 'r'; + } + } + return false; + } + public static function getVCalendar($id){ $event_object = self::getEventObject( $id ); diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index def1026c5e..7117607ebb 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -191,11 +191,35 @@ class OC_Calendar_Share{ public static function is_editing_allowed($share, $id, $type){ $group_where = self::group_sql(OC_Group::getUserGroups($share)); $permission_where = self::permission_sql('rw'); - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where . ')'); + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where); $result = $stmt->execute(array($share)); if($result->numRows() == 1){ return true; } + if($type == self::EVENT){ + $calendar == OC_Calendar_App::getCalendar($id); + return self::is_editing_allowed($share, $calendar['id'], self::CALENDAR); + } + return false; + } + /* + * @brief: checks the access of + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function check_access($share, $id, $type){ + $group_where = self::group_sql(OC_Group::getUserGroups($share)); + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ')'); + $result = $stmt->execute(array($share)); + if($result->numRows() > 0){ + return true; + } + if($type == self::EVENT){ + $calendar == OC_Calendar_App::getCalendar($id); + return self::check_access($share, $calendar['id'], self::CALENDAR); + } return false; } } \ No newline at end of file diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index b67f8c02c3..c87e1ec9de 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -217,6 +217,7 @@ diff --git a/apps/calendar/templates/part.showevent.php b/apps/calendar/templates/part.showevent.php new file mode 100644 index 0000000000..1be13bf1f6 --- /dev/null +++ b/apps/calendar/templates/part.showevent.php @@ -0,0 +1,249 @@ +
      "> + +
      + + + + + +
      t("Title");?>: + +
      + + + + + + + + + +
      t("Category");?>: + t('No categories selected'); + }else{ + echo ''; + } + ?> +    t("Calendar");?>: + +   + +
      +
      + + + + + + + + + + + + + +
      + id="allday_checkbox" name="allday" disabled="disabled"> + t("All Day Event");?> +
      t("From");?>: + +    t('at'):''; ?>    + +
      t("To");?>: + +    t('at'):''; ?>    + +
      + " onclick="Calendar.UI.showadvancedoptions();" id="advanced_options_button"> + +
      +
      + + + + + + +
      t("Repeat");?>: + " onclick="Calendar.UI.showadvancedoptionsforrepeating();" id="advanced_options_button">
      + +
      +
      //Alarm
      +
      //Attendees
      +
      //Share
      + +
      \ No newline at end of file From 179bf15dafcd322354b4cdb4a8d044598b6e89a9 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 15:30:04 +0200 Subject: [PATCH 041/116] fix group sql generator in calendar's share lib --- apps/calendar/lib/share.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index 7117607ebb..42dfc8a310 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -155,11 +155,7 @@ class OC_Calendar_Share{ $group_where = ''; $i = 0; foreach($groups as $group){ - if($i == 0){ - $group_where = 'OR ('; - }else{ - $group_where .= ' OR '; - } + $group_where .= ' OR '; $group_where .= ' (share = "' . $group . '" AND sharetype = "group") '; $i++; } From 8b9d439841e8f74d4efebfdec24d515782ce8d9a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 15:37:47 +0200 Subject: [PATCH 042/116] Calendar: fix address for import file --- apps/calendar/js/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index 5400387975..60d92f448e 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -44,7 +44,7 @@ Calendar_Import={ $('#newcalendar').attr('readonly', 'readonly'); $('#calendar').attr('disabled', 'disabled'); var progressfile = $('#progressfile').val(); - $.post(OC.filePath('calendar', '', 'import.php'), {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ + $.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ if(data.status == 'success'){ $('#progressbar').progressbar('option', 'value', 100); $('#import_done').css('display', 'block'); From 10ef01b04be2bb6dd15303c9d641647d515e5556 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 15:44:24 +0200 Subject: [PATCH 043/116] fix displayed username of person who shares --- apps/calendar/templates/part.showevent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calendar/templates/part.showevent.php b/apps/calendar/templates/part.showevent.php index 1be13bf1f6..d8443bd06e 100644 --- a/apps/calendar/templates/part.showevent.php +++ b/apps/calendar/templates/part.showevent.php @@ -35,7 +35,7 @@ From f479105f5e50ba915b9dbed3dd049f08e35fa591 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 16:01:55 +0200 Subject: [PATCH 044/116] optimize choosecalendar dialog for shared calendars --- apps/calendar/templates/part.choosecalendar.php | 1 + .../calendar/templates/part.choosecalendar.rowfields.shared.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index 21da5dd7cd..3c6799d892 100644 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -28,6 +28,7 @@ for($i = 0; $i < count($option_calendars); $i++){ $share = OC_Calendar_Share::allSharedwithuser(OC_User::getUser(), OC_Calendar_Share::CALENDAR); $count = count($share); for($i = 0; $i < $count; $i++){ + $share[$i]['calendar'] = OC_Calendar_App::getCalendar($share[$i]['calendarid']); echo ''; $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields.shared'); $tmpl->assign('share', $share[$i]); diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php index 2e1210415b..a23266da0c 100644 --- a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php @@ -1,4 +1,4 @@ '; echo ''; -echo '' . $l->t('shared with you by') . ' ' . $_['share']['owner'] . ''; \ No newline at end of file +echo '' . $l->t('shared with you by') . ' ' . $_['share']['owner'] . ''; \ No newline at end of file From c384e3ba4f01718af35a47e8470a7458424be954 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 27 Mar 2012 09:24:55 +0200 Subject: [PATCH 045/116] fix width of dropdown to select monthdays - bugfix oc-354 --- apps/calendar/templates/part.eventform.php | 2 +- apps/calendar/templates/part.showevent.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index c87e1ec9de..c4c3ae1c1e 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -144,7 +144,7 @@ - "> true)); diff --git a/apps/calendar/templates/part.showevent.php b/apps/calendar/templates/part.showevent.php index d8443bd06e..ae3d55e074 100644 --- a/apps/calendar/templates/part.showevent.php +++ b/apps/calendar/templates/part.showevent.php @@ -147,7 +147,7 @@ - "> true)); From a88305b4cbe6aa3772384a96f56b207996bfe960 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 13:11:30 +0200 Subject: [PATCH 046/116] remove share tab from read only event dialog --- apps/calendar/templates/part.showevent.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/calendar/templates/part.showevent.php b/apps/calendar/templates/part.showevent.php index ae3d55e074..c052183056 100644 --- a/apps/calendar/templates/part.showevent.php +++ b/apps/calendar/templates/part.showevent.php @@ -4,7 +4,6 @@
    • t('Repeating'); ?>
    • t('Alarm'); ?>
    • t('Attendees'); ?>
    • -
    • t('Share'); ?>
    @@ -244,6 +243,5 @@
    //Alarm
    //Attendees
    -
    //Share
    \ No newline at end of file From 1f8cf2d8f256535ca86d9e01afcf13114c6bd70b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 13:37:44 +0200 Subject: [PATCH 047/116] fix name of constants --- apps/calendar/ajax/share/changepermission.php | 2 +- apps/calendar/ajax/share/share.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php index d91f87b613..41d49e7b52 100644 --- a/apps/calendar/ajax/share/changepermission.php +++ b/apps/calendar/ajax/share/changepermission.php @@ -36,5 +36,5 @@ 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)); +$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/share.php b/apps/calendar/ajax/share/share.php index d892727701..92c3eb90d3 100644 --- a/apps/calendar/ajax/share/share.php +++ b/apps/calendar/ajax/share/share.php @@ -38,7 +38,7 @@ if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){ 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)); +$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)); From 4b3f074309fe9075119a56c337d7e8ad30d2c73a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 17:27:30 +0100 Subject: [PATCH 048/116] add new parameters to export file --- apps/calendar/export.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calendar/export.php b/apps/calendar/export.php index 2736eec96c..e4caa1bde7 100644 --- a/apps/calendar/export.php +++ b/apps/calendar/export.php @@ -13,7 +13,7 @@ $cal = isset($_GET['calid']) ? $_GET['calid'] : NULL; $event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL; $nl = "\n\r"; if(isset($cal)){ - $calendar = OC_Calendar_App::getCalendar($cal); + $calendar = OC_Calendar_App::getCalendar($cal, true); $calobjects = OC_Calendar_Object::all($cal); header('Content-Type: text/Calendar'); header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics'); @@ -21,11 +21,11 @@ if(isset($cal)){ echo $calobject['calendardata'] . $nl; } }elseif(isset($event)){ - $data = OC_Calendar_App::getEventObject($_GET['eventid']); + $data = OC_Calendar_App::getEventObject($_GET['eventid'], true); $calendarid = $data['calendarid']; $calendar = OC_Calendar_App::getCalendar($calendarid); header('Content-Type: text/Calendar'); header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics'); echo $data['calendardata']; } -?> +?> \ No newline at end of file From cf26f8a6a7751bd32eeb449ef39b743248ae3d1a Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 17:32:43 +0100 Subject: [PATCH 049/116] add public sharing for calendars and events --- apps/calendar/share.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/calendar/share.php b/apps/calendar/share.php index 8d1c8b69c3..3e45fdeee1 100644 --- a/apps/calendar/share.php +++ b/apps/calendar/share.php @@ -1 +1,21 @@ - + Date: Sat, 31 Mar 2012 16:12:27 -0400 Subject: [PATCH 050/116] add public sharing fir calendars and events - add function in Share class --- apps/calendar/lib/share.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index 42dfc8a310..3e03a2d7cc 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -218,4 +218,27 @@ class OC_Calendar_Share{ } return false; } + /* + * @brief: returns the calendardata of an event or a calendar + * @param: (string) $token - token which should be searched + * @return: mixed - bool if false, array with type and id if true + */ + public static function getElementByToken($token){ + $stmt_calendar = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::CALENDAR . ' WHERE sharetype = "public" AND share = ?'); + $result_calendar = $stmt_calendar->execute(array($token)); + $stmt_event = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::EVENT . ' WHERE sharetype = "public" AND share = ?'); + $result_event = $stmt_calendar->execute(array($token)); + $return = array(); + if($result_calendar->numRows() == 0 && $result_event->numRows() == 0){ + return false; + }elseif($result_calendar->numRows() != 0){ + $return ['type'] = 'calendar'; + $calendar = $result_calendar->fetchRow(); + $return ['id'] = $calendar['calendarid']; + }else{ + $return ['type'] = 'event'; + $event = $result_event->fetchRow(); + $return ['id'] = $event['eventid']; + } + } } \ No newline at end of file From 70237f7eccebbc83c57df3e7bc3585e285e52579 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 16:13:04 -0400 Subject: [PATCH 051/116] rewrite OC_Calendar_APP class --- apps/calendar/lib/app.php | 227 ++++++++++++++++++++++++-------------- 1 file changed, 147 insertions(+), 80 deletions(-) diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index b4d9f844c1..8bc416d2ce 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -1,143 +1,210 @@ + * Copyright (c) 2012 Georg Ehrke * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. - */ - -/** + * * This class manages our app actions */ OC_Calendar_App::$l10n = new OC_L10N('calendar'); class OC_Calendar_App{ + /* + * @brief: language object for calendar app + */ public static $l10n; - public static function getCalendar($id){ - return OC_Calendar_Calendar::find( $id ); - } - - public static function getEventObject($id){ - $event_object = OC_Calendar_Object::find( $id ); - if( $event_object === false ){ - OC_JSON::error(); - exit(); - } - - //self::getCalendar( $event_object['calendarid'] );//access check - return $event_object; - } - - public static function check_access($id){ - $event_object = self::getEventObject($id); - $calendar = self::getCalendar($event_object['calendarid']); - if($calendar['userid'] == OC_User::getUser()){ - return 'owner'; - } - if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){ - if(OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){ - return 'rw'; - }else{ - return 'r'; + /* + * @brief: returns informations about a calendar + * @param: int $id - id of the calendar + * @param: bool $security - check access rights or not + * @param: bool $shared - check if the user got access via sharing + * @return: mixed - bool / array + */ + public static function getCalendar($id, $security = true, $shared = false){ + $calendar = OC_Calendar_Object::find($id); + if($shared === true){ + if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR)){ + return $calendar; } } - return false; - } - - public static function getVCalendar($id){ - $event_object = self::getEventObject( $id ); - - $vcalendar = OC_VObject::parse($event_object['calendardata']); - // Check if the vcalendar is valid - if(is_null($vcalendar)){ - OC_JSON::error(); - exit(); + if($security === true){ + if($calendar['userid'] != OC_User::getUser()){ + return false; + } } - return $vcalendar; + if($calendar === false){ + return false; + } + return OC_Calendar_Calendar::find($id); } - - public static function isNotModified($vevent, $lastmodified) - { + + /* + * @brief: returns informations about an event + * @param: int $id - id of the event + * @param: bool $security - check access rights or not + * @param: bool $shared - check if the user got access via sharing + * @return: mixed - bool / array + */ + public static function getEventObject($id, $security = true, $shared = false){ + $event = OC_Calendar_Object::find($id); + if($shared === true){ + if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){ + return $calendar; + } + } + if($security === true){ + $calendar = self::getCalendar($event['calendarid'], false); + if($calendar['userid'] != OC_User::getUser()){ + return false; + } + } + if($event === false){ + return false; + } + return $event; + } + + /* + * @brief: returns the parsed calendar data + * @param: int $id - id of the event + * @param: bool $security - check access rights or not + * @return: mixed - bool / object + */ + public static function getVCalendar($id, $security = true){ + $event_object = self::getEventObject($id, $security); + if($event_object === false){ + return false; + } + $vobject = OC_VObject::parse($event_object['calendardata']); + if(is_null($vobject)){ + return false; + } + return $vobject; + } + + /* + * + */ + public static function isNotModified($vevent, $lastmodified){ $last_modified = $vevent->__get('LAST-MODIFIED'); if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){ OC_JSON::error(array('modified'=>true)); exit; } } - - public static function getCategoryOptions() - { - return array( - self::$l10n->t('Birthday'), - self::$l10n->t('Business'), - self::$l10n->t('Call'), - self::$l10n->t('Clients'), - self::$l10n->t('Deliverer'), - self::$l10n->t('Holidays'), - self::$l10n->t('Ideas'), - self::$l10n->t('Journey'), - self::$l10n->t('Jubilee'), - self::$l10n->t('Meeting'), - self::$l10n->t('Other'), - self::$l10n->t('Personal'), - self::$l10n->t('Projects'), - self::$l10n->t('Questions'), - self::$l10n->t('Work'), - ); + /* + * THIS FUNCTION IS DEPRECATED AND WILL BE REMOVED SOON + * @brief: returns the valid categories + * @return: array - categories + */ + public static function getCategoryOptions(){ + return OC_Calendar_Object::getCategoryOptions(self::$l10n); } - + + /* + * @brief: returns the options for an repeating event + * @return: array - valid inputs for repeating events + */ public static function getRepeatOptions(){ return OC_Calendar_Object::getRepeatOptions(self::$l10n); } - + + /* + * @brief: returns the options for the end of an repeating event + * @return: array - valid inputs for the end of an repeating events + */ public static function getEndOptions(){ return OC_Calendar_Object::getEndOptions(self::$l10n); } - + + /* + * @brief: returns the options for an monthly repeating event + * @return: array - valid inputs for monthly repeating events + */ public static function getMonthOptions(){ return OC_Calendar_Object::getMonthOptions(self::$l10n); } - + + /* + * @brief: returns the options for an weekly repeating event + * @return: array - valid inputs for weekly repeating events + */ public static function getWeeklyOptions(){ return OC_Calendar_Object::getWeeklyOptions(self::$l10n); } - + + /* + * @brief: returns the options for an yearly repeating event + * @return: array - valid inputs for yearly repeating events + */ public static function getYearOptions(){ return OC_Calendar_Object::getYearOptions(self::$l10n); } - + + /* + * @brief: returns the options for an yearly repeating event which occurs on specific days of the year + * @return: array - valid inputs for yearly repeating events + */ public static function getByYearDayOptions(){ return OC_Calendar_Object::getByYearDayOptions(); } - + + /* + * @brief: returns the options for an yearly repeating event which occurs on specific month of the year + * @return: array - valid inputs for yearly repeating events + */ public static function getByMonthOptions(){ return OC_Calendar_Object::getByMonthOptions(self::$l10n); } + /* + * @brief: returns the options for an yearly repeating event which occurs on specific week numbers of the year + * @return: array - valid inputs for yearly repeating events + */ public static function getByWeekNoOptions(){ return OC_Calendar_Object::getByWeekNoOptions(); } - + + /* + * @brief: returns the options for an yearly or monthly repeating event which occurs on specific days of the month + * @return: array - valid inputs for yearly or monthly repeating events + */ public static function getByMonthDayOptions(){ return OC_Calendar_Object::getByMonthDayOptions(); } + /* + * @brief: returns the options for an monthly repeating event which occurs on specific weeks of the month + * @return: array - valid inputs for monthly repeating events + */ public static function getWeekofMonth(){ return OC_Calendar_Object::getWeekofMonth(self::$l10n); } - public static function prepareForOutput($event, $vevent){ - $return_event = array(); - $return_event['id'] = (int)$event['id']; - $return_event['title'] = htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: self::$l10n->t('unnamed')); - $return_event['description'] = isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):''; - $last_modified = $vevent->__get('LAST-MODIFIED'); + /* + * @brief: returns the prepared output for the json calendar data + * @param: array $event - array with event informations (self::getEventObject) + * @return: array - prepared output + */ + public static function prepareForOutput($event){ + if(isset($event['calendardata'])){ + $object = self::getVCalendar($event['calendardata'], false); + $vevent = $object->VEVENT; + }else{ + $vevent = $event['vevent']; + }$last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified){ $lastmodified = $last_modified->getDateTime()->format('U'); }else{ $lastmodified = 0; } - $return_event['lastmodified'] = (int)$lastmodified; - return $return_event; + $last_modified = ($vevent->__get('LAST-MODIFIED'))?$last_modified->getDateTime()->format('U'):0; + $return = array('id'=>(int)$event['id'], + 'title' => htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: self::$l10n->t('unnamed')), + 'description' => isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):'', + 'lastmodified'=>(int)$lastmodified); + return $return; } } From ca2c7001c49a01d00b7d2f9ab924aa82366ad1ba Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 16:15:04 -0400 Subject: [PATCH 052/116] remove unused code in OC_Calendar_App class --- apps/calendar/lib/app.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 8bc416d2ce..f8bdbd4a36 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -194,11 +194,6 @@ class OC_Calendar_App{ $vevent = $object->VEVENT; }else{ $vevent = $event['vevent']; - }$last_modified = $vevent->__get('LAST-MODIFIED'); - if ($last_modified){ - $lastmodified = $last_modified->getDateTime()->format('U'); - }else{ - $lastmodified = 0; } $last_modified = ($vevent->__get('LAST-MODIFIED'))?$last_modified->getDateTime()->format('U'):0; $return = array('id'=>(int)$event['id'], From 0fd8b1a04430fc36bd62a0828530dc2bc3910e81 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 31 Mar 2012 16:16:34 -0400 Subject: [PATCH 053/116] fix events.php for rewritten OC_Caledar_App class --- apps/calendar/ajax/events.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 196b2c3394..94c05f5808 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -1,12 +1,13 @@ + * Copyright (c) 2011, 2012 Georg Ehrke * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ require_once ('../../../lib/base.php'); +//IS THERE A NATIVE SUPPORT IN SABREDAV ??? require_once('when/When.php'); OC_JSON::checkLoggedIn(); @@ -43,14 +44,7 @@ if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $return = array(); foreach($events as $event){ - if (isset($event['calendardata'])) { - $object = OC_VObject::parse($event['calendardata']); - $vevent = $object->VEVENT; - } else { - $vevent = $event['vevent']; - } - - $return_event = OC_Calendar_App::prepareForOutput($event, $vevent); + $return_event = OC_Calendar_App::prepareForOutput($event); $dtstart = $vevent->DTSTART; $start_dt = $dtstart->getDateTime(); From d896c19011d1cb74440e78bf6ff2aca4a999dd7c Mon Sep 17 00:00:00 2001 From: Scott Shambarger Date: Sat, 31 Mar 2012 20:16:42 -0700 Subject: [PATCH 054/116] cal import should group events by uid, export should have correct newlines, fix for oc-384 --- apps/calendar/export.php | 2 +- apps/calendar/import.php | 128 +++++++++++++++++++++------------------ 2 files changed, 70 insertions(+), 60 deletions(-) diff --git a/apps/calendar/export.php b/apps/calendar/export.php index 2736eec96c..db3a83c92e 100644 --- a/apps/calendar/export.php +++ b/apps/calendar/export.php @@ -11,7 +11,7 @@ OC_Util::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); $cal = isset($_GET['calid']) ? $_GET['calid'] : NULL; $event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL; -$nl = "\n\r"; +$nl = "\r\n"; if(isset($cal)){ $calendar = OC_Calendar_App::getCalendar($cal); $calobjects = OC_Calendar_Object::all($cal); diff --git a/apps/calendar/import.php b/apps/calendar/import.php index b1c6f91df8..e5a5f0837f 100644 --- a/apps/calendar/import.php +++ b/apps/calendar/import.php @@ -10,7 +10,8 @@ ob_start(); require_once ('../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); -$nl = "\n"; +$nl="\r\n"; +$comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); $progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); @@ -29,85 +30,94 @@ if($_POST['method'] == 'new'){ } $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(); +// normalize the newlines +$file = str_replace(array("\r","\n\n"), array("\n","\n"), $file); +$lines = explode("\n", $file); +unset($file); +if(is_writable('import_tmp/')){ + $progressfopen = fopen($progressfile, 'w'); + fwrite($progressfopen, '30'); + fclose($progressfopen); +} +// analyze the file, group components by uid, and keep refs to originating calendar object +// $cals is array calendar objects, keys are 1st line# $cal, ie array( $cal => $caldata ) +// $caldata is array( 'first' => 1st component line#, 'last' => last comp line#, 'end' => end line# ) +// $caldata is used to create prefix/suffix strings when building import text +// $uids is array of component arrays, keys are $uid, ie array( $uid => array( $beginlineno => $component ) ) +// $component is array( 'end' => end line#, 'cal'=> $cal ) +$comp=$uid=$cal=false; +$cals=$uids=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; +foreach($lines as $line) { + + if(strpos($line, ':')!==false) { + list($attr, $val) = explode(':', strtoupper($line)); + if ($attr == 'BEGIN' && $val == 'VCALENDAR') { + $cal = $i; + $cals[$cal] = array('first'=>$i,'last'=>$i,'end'=>$i); + } elseif ($attr =='BEGIN' && $cal!==false && isset($comps[$val])) { + $comp = $val; + $beginNo = $i; + } elseif ($attr == 'END' && $cal!==false && $val == 'VCALENDAR') { + if($comp!==false) { + unset($cals[$cal]); // corrupt calendar, unset it + } else { + $cals[$cal]['end'] = $i; } - if($attr == 'END'){ - $parts[count($parts) - 1]['end'] = $i; - $inelement = false; + $comp=$uid=$cal=false; // reset calendar + } elseif ($attr == 'END' && $comp!==false && $val == $comp) { + if(! $uid) { + $uid = OC_Calendar_Object::createUID(); } + $uids[$uid][$beginNo] = array('end'=>$i, 'cal'=>$cal); + if ($cals[$cal]['first'] == $cal) { + $cals[$cal]['first'] = $beginNo; + } + $cals[$cal]['last'] = $i; + $comp=$uid=false; // reset component + } elseif ($attr =="UID" && $comp!==false) { + list($attr, $uid) = explode(':', $line); } } $i++; } -//import the calendar +// import the calendar if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '40'); + fwrite($progressfopen, '60'); 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]; +foreach($uids as $uid) { + + $prefix=$suffix=$content=array(); + foreach($uid as $begin=>$details) { + + $cal = $details['cal']; + if(!isset($cals[$cal])) { + continue; // from corrupt/incomplete calendar } + $cdata = $cals[$cal]; + // if we have multiple components from different calendar objects, + // we should really merge their elements (enhancement?) -- 1st one wins for now. + if(! count($prefix)) { + $prefix = array_slice($lines, $cal, $cdata['first'] - $cal); + } + if(! count($suffix)) { + $suffix = array_slice($lines, $cdata['last']+1, $cdata['end'] - $cdata['last']); + } + $content = array_merge($content, array_slice($lines, $begin, $details['end'] - $begin + 1)); } - $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){ + if(count($content)) { + $import = join($nl, array_merge($prefix, $content, $suffix)) . $nl; OC_Calendar_Object::add($id, $import); } } -//done the import +// finished import if(is_writable('import_tmp/')){ $progressfopen = fopen($progressfile, 'w'); fwrite($progressfopen, '100'); From 72a43b39291046637c17071c6bb48510ae1c7826 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 2 Apr 2012 08:32:27 -0400 Subject: [PATCH 055/116] revert 0fd8b1a04430fc36bd62a0828530dc2bc3910e81 --- apps/calendar/ajax/events.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 94c05f5808..196b2c3394 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -1,13 +1,12 @@ + * Copyright (c) 2011 Georg Ehrke * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ require_once ('../../../lib/base.php'); -//IS THERE A NATIVE SUPPORT IN SABREDAV ??? require_once('when/When.php'); OC_JSON::checkLoggedIn(); @@ -44,7 +43,14 @@ if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $return = array(); foreach($events as $event){ - $return_event = OC_Calendar_App::prepareForOutput($event); + if (isset($event['calendardata'])) { + $object = OC_VObject::parse($event['calendardata']); + $vevent = $object->VEVENT; + } else { + $vevent = $event['vevent']; + } + + $return_event = OC_Calendar_App::prepareForOutput($event, $vevent); $dtstart = $vevent->DTSTART; $start_dt = $dtstart->getDateTime(); From e18c0d54f6f424614cc6e4da3beb704efaab702f Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 7 Apr 2012 22:35:29 -0400 Subject: [PATCH 056/116] add output functions and access function to app.php of calendar --- apps/calendar/lib/app.php | 248 ++++++++++++++++++++++++++++++-------- 1 file changed, 196 insertions(+), 52 deletions(-) diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index f8bdbd4a36..40de6deb43 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -8,22 +8,30 @@ * * This class manages our app actions */ -OC_Calendar_App::$l10n = new OC_L10N('calendar'); +self::$l10n = new OC_L10N('calendar'); +self::$tz = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); class OC_Calendar_App{ + const CALENDAR = 'calendar'; + const EVENT = 'event'; /* - * @brief: language object for calendar app + * @brief language object for calendar app */ public static $l10n; /* - * @brief: returns informations about a calendar - * @param: int $id - id of the calendar - * @param: bool $security - check access rights or not - * @param: bool $shared - check if the user got access via sharing - * @return: mixed - bool / array + * @brief timezone of the user + */ + public static $tz; + + /* + * @brief returns informations about a calendar + * @param int $id - id of the calendar + * @param bool $security - check access rights or not + * @param bool $shared - check if the user got access via sharing + * @return mixed - bool / array */ public static function getCalendar($id, $security = true, $shared = false){ - $calendar = OC_Calendar_Object::find($id); + $calendar = OC_Calendar_Calendar::find($id); if($shared === true){ if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR)){ return $calendar; @@ -41,17 +49,17 @@ class OC_Calendar_App{ } /* - * @brief: returns informations about an event - * @param: int $id - id of the event - * @param: bool $security - check access rights or not - * @param: bool $shared - check if the user got access via sharing - * @return: mixed - bool / array + * @brief returns informations about an event + * @param int $id - id of the event + * @param bool $security - check access rights or not + * @param bool $shared - check if the user got access via sharing + * @return mixed - bool / array */ public static function getEventObject($id, $security = true, $shared = false){ $event = OC_Calendar_Object::find($id); if($shared === true){ if(OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT)){ - return $calendar; + return $event; } } if($security === true){ @@ -67,10 +75,10 @@ class OC_Calendar_App{ } /* - * @brief: returns the parsed calendar data - * @param: int $id - id of the event - * @param: bool $security - check access rights or not - * @return: mixed - bool / object + * @brief returns the parsed calendar data + * @param int $id - id of the event + * @param bool $security - check access rights or not + * @return mixed - bool / object */ public static function getVCalendar($id, $security = true){ $event_object = self::getEventObject($id, $security); @@ -85,7 +93,10 @@ class OC_Calendar_App{ } /* - * + * @brief checks if an event was edited and dies if it was + * @param (object) $vevent - vevent object of the event + * @param (int) $lastmodified - time of last modification as unix timestamp + * @return (bool) */ public static function isNotModified($vevent, $lastmodified){ $last_modified = $vevent->__get('LAST-MODIFIED'); @@ -93,113 +104,246 @@ class OC_Calendar_App{ OC_JSON::error(array('modified'=>true)); exit; } + return true; } /* * THIS FUNCTION IS DEPRECATED AND WILL BE REMOVED SOON - * @brief: returns the valid categories - * @return: array - categories + * @brief returns the valid categories + * @return array - categories */ public static function getCategoryOptions(){ return OC_Calendar_Object::getCategoryOptions(self::$l10n); } /* - * @brief: returns the options for an repeating event - * @return: array - valid inputs for repeating events + * @brief returns the options for an repeating event + * @return array - valid inputs for repeating events */ public static function getRepeatOptions(){ return OC_Calendar_Object::getRepeatOptions(self::$l10n); } /* - * @brief: returns the options for the end of an repeating event - * @return: array - valid inputs for the end of an repeating events + * @brief returns the options for the end of an repeating event + * @return array - valid inputs for the end of an repeating events */ public static function getEndOptions(){ return OC_Calendar_Object::getEndOptions(self::$l10n); } /* - * @brief: returns the options for an monthly repeating event - * @return: array - valid inputs for monthly repeating events + * @brief returns the options for an monthly repeating event + * @return array - valid inputs for monthly repeating events */ public static function getMonthOptions(){ return OC_Calendar_Object::getMonthOptions(self::$l10n); } /* - * @brief: returns the options for an weekly repeating event - * @return: array - valid inputs for weekly repeating events + * @brief returns the options for an weekly repeating event + * @return array - valid inputs for weekly repeating events */ public static function getWeeklyOptions(){ return OC_Calendar_Object::getWeeklyOptions(self::$l10n); } /* - * @brief: returns the options for an yearly repeating event - * @return: array - valid inputs for yearly repeating events + * @brief returns the options for an yearly repeating event + * @return array - valid inputs for yearly repeating events */ public static function getYearOptions(){ return OC_Calendar_Object::getYearOptions(self::$l10n); } /* - * @brief: returns the options for an yearly repeating event which occurs on specific days of the year - * @return: array - valid inputs for yearly repeating events + * @brief returns the options for an yearly repeating event which occurs on specific days of the year + * @return array - valid inputs for yearly repeating events */ public static function getByYearDayOptions(){ return OC_Calendar_Object::getByYearDayOptions(); } /* - * @brief: returns the options for an yearly repeating event which occurs on specific month of the year - * @return: array - valid inputs for yearly repeating events + * @brief returns the options for an yearly repeating event which occurs on specific month of the year + * @return array - valid inputs for yearly repeating events */ public static function getByMonthOptions(){ return OC_Calendar_Object::getByMonthOptions(self::$l10n); } /* - * @brief: returns the options for an yearly repeating event which occurs on specific week numbers of the year - * @return: array - valid inputs for yearly repeating events + * @brief returns the options for an yearly repeating event which occurs on specific week numbers of the year + * @return array - valid inputs for yearly repeating events */ public static function getByWeekNoOptions(){ return OC_Calendar_Object::getByWeekNoOptions(); } /* - * @brief: returns the options for an yearly or monthly repeating event which occurs on specific days of the month - * @return: array - valid inputs for yearly or monthly repeating events + * @brief returns the options for an yearly or monthly repeating event which occurs on specific days of the month + * @return array - valid inputs for yearly or monthly repeating events */ public static function getByMonthDayOptions(){ return OC_Calendar_Object::getByMonthDayOptions(); } /* - * @brief: returns the options for an monthly repeating event which occurs on specific weeks of the month - * @return: array - valid inputs for monthly repeating events + * @brief returns the options for an monthly repeating event which occurs on specific weeks of the month + * @return array - valid inputs for monthly repeating events */ public static function getWeekofMonth(){ return OC_Calendar_Object::getWeekofMonth(self::$l10n); } /* - * @brief: returns the prepared output for the json calendar data - * @param: array $event - array with event informations (self::getEventObject) - * @return: array - prepared output + * @brief checks the access for a calendar / an event + * @param (int) $id - id of the calendar / event + * @param (string) $type - type of the id (calendar/event) + * @return (string) $access - level of access */ - public static function prepareForOutput($event){ - if(isset($event['calendardata'])){ - $object = self::getVCalendar($event['calendardata'], false); + public static function getaccess($id, $type){ + if($type == self::CALENDAR){ + $calendar = self::getCalendar($id, false, false); + if($calendar['userid'] == OC_User::getUser()){ + return 'owner'; + } + $isshared = OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR); + if($isshared){ + $writeaccess = OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::CALENDAR); + if($writeaccess){ + return 'rw'; + }else{ + return 'r'; + } + }else{ + return false; + } + }elseif($type == self::EVENT){ + if(OC_Calendar_Object::getowner($id) == OC_User::getUser()){ + return 'owner'; + } + $isshared = OC_Calendar_Share::check_access(OC_User::getUser(), $id, OC_Calendar_Share::EVENT); + if($isshared){ + $writeaccess = OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT); + if($writeaccess){ + return 'rw'; + }else{ + return 'r'; + } + }else{ + return false; + } + } + } + + /* + * @brief analyses the parameter for calendar parameter and returns the objects + * @param (string) $calendarid - calendarid + * @param (int) $start - unixtimestamp of start + * @param (int) $end - unixtimestamp of end + * @return (array) $events + */ + public static function getrequestedEvents($calendarid, $start, $end){ + + $events = array(); + if($calendarid == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ + $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); + foreach($calendars as $calendar){ + $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end); + $events = array_merge($events, $calendarevents); + } + $singleevents = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::EVENT, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); + foreach($singleevents as $singleevent){ + $event = OC_Calendar_Object::find($singleevent['eventid']); + $events = array_merge($events, $event); + } + }else{ + $calendar_id = $_GET['calendar_id']; + if (is_numeric($calendar_id)) { + $calendar = self::getCalendar($calendar_id); + OC_Response::enableCaching(0); + OC_Response::setETagHeader($calendar['ctag']); + $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end); + } else { + OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events)); + } + } + return $events; + } + + /* + * @brief generates the output for an event which will be readable for our js + * @param (mixed) $event - event object / array + * @param (int) $start - unixtimestamp of start + * @param (int) $end - unixtimestamp of end + * @return (array) $output - readable output + */ + public static function generateEventOutput($event, $start, $end){ + $output = array(); + + if(array_key_exists('calendardata', $event)){ + $object = OC_VObject::parse($event['calendardata']); $vevent = $object->VEVENT; }else{ $vevent = $event['vevent']; } - $last_modified = ($vevent->__get('LAST-MODIFIED'))?$last_modified->getDateTime()->format('U'):0; - $return = array('id'=>(int)$event['id'], + + $last_modified = @$vevent->__get('LAST-MODIFIED'); + $lastmodified = ($last_modified)?$last_modified->getDateTime()->format('U'):0; + + $output = array('id'=>(int)$event['id'], 'title' => htmlspecialchars(($event['summary']!=NULL || $event['summary'] != '')?$event['summary']: self::$l10n->t('unnamed')), 'description' => isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):'', - 'lastmodified'=>(int)$lastmodified); - return $return; + 'lastmodified'=>$lastmodified); + + $dtstart = $vevent->DTSTART; + $start_dt = $dtstart->getDateTime(); + $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); + $end_dt = $dtend->getDateTime(); + + if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ + $output['allDay'] = true; + }else{ + $output['allDay'] = false; + $start_dt->setTimezone(new DateTimeZone(self::$tz)); + $end_dt->setTimezone(new DateTimeZone(self::$tz)); + } + + if($event['repeating'] == 1){ + $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U'); + $r = new When(); + $r->recur($start_dt)->rrule((string) $vevent->RRULE); + /*$r = new iCal_Repeat_Generator(array('RECUR' => $start_dt, + * 'RRULE' => (string)$vevent->RRULE + * 'RDATE' => (string)$vevent->RDATE + * 'EXRULE' => (string)$vevent->EXRULE + * 'EXDATE' => (string)$vevent->EXDATE));*/ + while($result = $r->next()){ + if($result < $start){ + continue; + } + if($result > $end){ + break; + } + if($output['allDay'] == true){ + $output['start'] = $result->format('Y-m-d'); + $output['end'] = date('Y-m-d', $result->format('U') + --$duration); + }else{ + $output['start'] = $result->format('Y-m-d H:i:s'); + $output['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration); + } + $output[] = $output; + } + }else{ + if($output['allDay'] == true){ + $output['start'] = $start_dt->format('Y-m-d'); + $end_dt->modify('-1 sec'); + $output['end'] = $end_dt->format('Y-m-d'); + }else{ + $output['start'] = $start_dt->format('Y-m-d H:i:s'); + $output['end'] = $end_dt->format('Y-m-d H:i:s'); + } + $output[] = $output; + } } -} +} \ No newline at end of file From eef9a1e7ed63a3d6506afd0dbf84d16fbf8c1064 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 7 Apr 2012 22:37:26 -0400 Subject: [PATCH 057/116] add access check to ajax files --- apps/calendar/ajax/event/delete.php | 11 ++++++----- apps/calendar/ajax/event/edit.form.php | 13 ++++++------- apps/calendar/ajax/event/edit.php | 9 ++++++++- apps/calendar/ajax/event/move.php | 9 ++++++--- apps/calendar/ajax/event/resize.php | 5 +++-- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php index 862dec6bf5..6307e1a0f2 100644 --- a/apps/calendar/ajax/event/delete.php +++ b/apps/calendar/ajax/event/delete.php @@ -7,13 +7,14 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $id = $_POST['id']; -$event_object = OC_Calendar_App::getEventObject($id); +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OC_JSON::error(array('message'=>'permission denied')); + exit; +} $result = OC_Calendar_Object::delete($id); -OC_JSON::success(); -?> +OC_JSON::success(); \ No newline at end of file diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index ab77a747f1..a2e3fe6163 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -14,15 +14,14 @@ if(!OC_USER::isLoggedIn()) { OC_JSON::checkAppEnabled('calendar'); $id = $_GET['id']; -$data = OC_Calendar_App::getEventObject($id); -$object = OC_VObject::parse($data['calendardata']); -$vevent = $object->VEVENT; - -$access = OC_Calendar_App::check_access($id); -if(!$access){ +$data = OC_Calendar_App::getEventObject($id, true, true); +if(!$data){ OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar')))); exit; } +$access = OC_Calendar_App::getaccess($id, OC_Calendar_Share::EVENT); +$object = OC_VObject::parse($data['calendardata']); +$vevent = $object->VEVENT; $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); @@ -214,7 +213,7 @@ if($access == 'owner' || $access == 'rw'){ $tmpl = new OC_Template('calendar', 'part.showevent'); } -$tmpl->assign('id', $id); +$tmpl->assign('eventid', $id); $tmpl->assign('lastmodified', $lastmodified); $tmpl->assign('calendar_options', $calendar_options); $tmpl->assign('category_options', $category_options); diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php index 64daffddef..8dd99b2b10 100644 --- a/apps/calendar/ajax/event/edit.php +++ b/apps/calendar/ajax/event/edit.php @@ -10,13 +10,20 @@ require_once('../../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); +$id = $_POST['id']; + +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OC_JSON::error(array('message'=>'permission denied')); + exit; +} + $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ //show validate errors OC_JSON::error($errarr); exit; }else{ - $id = $_POST['id']; $cal = $_POST['calendar']; $data = OC_Calendar_App::getEventObject($id); $vcalendar = OC_VObject::parse($data['calendardata']); diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php index 8150fdbaa3..c6743e2354 100644 --- a/apps/calendar/ajax/event/move.php +++ b/apps/calendar/ajax/event/move.php @@ -9,7 +9,11 @@ require_once('../../../../lib/base.php'); OC_JSON::checkLoggedIn(); $id = $_POST['id']; - +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OC_JSON::error(array('message'=>'permission denied')); + exit; +} $vcalendar = OC_Calendar_App::getVCalendar($id); $vevent = $vcalendar->VEVENT; @@ -17,7 +21,6 @@ $allday = $_POST['allDay']; $delta = new DateInterval('P0D'); $delta->d = $_POST['dayDelta']; $delta->i = $_POST['minuteDelta']; - OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']); $dtstart = $vevent->DTSTART; @@ -40,4 +43,4 @@ $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); $result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); $lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime(); -OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); +OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U'))); \ No newline at end of file diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php index 1136273b70..a2ae83111b 100644 --- a/apps/calendar/ajax/event/resize.php +++ b/apps/calendar/ajax/event/resize.php @@ -10,8 +10,9 @@ OC_JSON::checkLoggedIn(); $id = $_POST['id']; -if(!OC_Calendar_Share::is_editing_allowed(OC_User::getUser(), $id, OC_Calendar_Share::EVENT) && OC_Calendar_Object::getowner($id) != OC_User::getUser()){ - OC_JSON::error(array('message'=>'permissiondenied')); +$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT); +if($access != 'owner' && $access != 'rw'){ + OC_JSON::error(array('message'=>'permission denied')); exit; } From e940152bcef6394e3a4bc75d0d3054f6a18e0ce4 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 7 Apr 2012 22:39:02 -0400 Subject: [PATCH 058/116] fix bugs in share lib of calendar --- apps/calendar/lib/share.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index 3e03a2d7cc..b4abcc08dd 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -20,7 +20,11 @@ class OC_Calendar_Share{ public static function allSharedwithuser($userid, $type, $active=null, $permission=null){ $group_where = self::group_sql(OC_Group::getUserGroups($userid)); $permission_where = self::permission_sql($permission); - $active_where = self::active_sql($active); + if($type == self::CALENDAR){ + $active_where = self::active_sql($active); + }else{ + $active_where = ''; + } $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . $active_where); $result = $stmt->execute(array($userid, $userid)); $return = array(); @@ -66,7 +70,7 @@ class OC_Calendar_Share{ return false; } if($sharetype == 'public'){ - $share = self::generate_token(); + $share = self::generate_token($id, $type); } $stmt = OC_DB::prepare('INSERT INTO *PREFIX*calendar_share_' . $type . ' (owner,share,sharetype,' . $type . 'id,permissions' . (($type == self::CALENDAR)?', active':'') . ') VALUES(?,?,?,?,0' . (($type == self::CALENDAR)?', 1':'') . ')' ); $result = $stmt->execute(array($owner,$share,$sharetype,$id)); @@ -193,8 +197,8 @@ class OC_Calendar_Share{ return true; } if($type == self::EVENT){ - $calendar == OC_Calendar_App::getCalendar($id); - return self::is_editing_allowed($share, $calendar['id'], self::CALENDAR); + $event = OC_Calendar_App::getEventObject($id, false, false); + return self::is_editing_allowed($share, $event['calendarid'], self::CALENDAR); } return false; } @@ -213,8 +217,8 @@ class OC_Calendar_Share{ return true; } if($type == self::EVENT){ - $calendar == OC_Calendar_App::getCalendar($id); - return self::check_access($share, $calendar['id'], self::CALENDAR); + $event = OC_Calendar_App::getEventObject($id, false, false); + return self::is_editing_allowed($share, $event['calendarid'], self::CALENDAR); } return false; } From 4d884c384968ce5df49669dc9ca28c177e4f2399 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 7 Apr 2012 22:39:37 -0400 Subject: [PATCH 059/116] clean up events.php of calendar --- apps/calendar/ajax/events.php | 93 ++++------------------------------- 1 file changed, 10 insertions(+), 83 deletions(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index 196b2c3394..21e816b127 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -1,99 +1,26 @@ + * Copyright (c) 2011, 2012 Georg Ehrke * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ require_once ('../../../lib/base.php'); -require_once('when/When.php'); +require_once(OC::$THIRDPARTYROOT . 'when/When.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); -if(version_compare(PHP_VERSION, '5.3.0', '>=')){ - $start = DateTime::createFromFormat('U', $_GET['start']); - $end = DateTime::createFromFormat('U', $_GET['end']); -}else{ - $start = new DateTime('@' . $_GET['start']); - $end = new DateTime('@' . $_GET['end']); -} +$start = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['start']):new DateTime('@' . $_GET['start']); +$end = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['end']):new DateTime('@' . $_GET['end']); -if($_GET['calendar_id'] == 'shared_rw' || $_GET['calendar_id'] == 'shared_r'){ - $calendars = OC_Calendar_Share::allSharedwithuser(OC_USER::getUser(), OC_Calendar_Share::CALENDAR, 1, ($_GET['calendar_id'] == 'shared_rw')?'rw':'r'); - $events = array(); - foreach($calendars as $calendar){ - $calendarevents = OC_Calendar_Object::allInPeriod($calendar['calendarid'], $start, $end); - $events = array_merge($events, $calendarevents); - } -}else{ - $calendar_id = $_GET['calendar_id']; - if (is_numeric($calendar_id)) { - $calendar = OC_Calendar_App::getCalendar($calendar_id); - OC_Response::enableCaching(0); - OC_Response::setETagHeader($calendar['ctag']); - $events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end); - } else { - $events = array(); - OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events)); - } -} +$events = OC_Calendar_App::getrequestedEvents($_GET['calendar_id'], $start, $end); -$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); -$return = array(); +$output = array(); foreach($events as $event){ - if (isset($event['calendardata'])) { - $object = OC_VObject::parse($event['calendardata']); - $vevent = $object->VEVENT; - } else { - $vevent = $event['vevent']; - } - - $return_event = OC_Calendar_App::prepareForOutput($event, $vevent); - - $dtstart = $vevent->DTSTART; - $start_dt = $dtstart->getDateTime(); - $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); - $end_dt = $dtend->getDateTime(); - if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){ - $return_event['allDay'] = true; - }else{ - $return_event['allDay'] = false; - $start_dt->setTimezone(new DateTimeZone($user_timezone)); - $end_dt->setTimezone(new DateTimeZone($user_timezone)); - } - if($event['repeating'] == 1){ - $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U'); - $r = new When(); - $r->recur($start_dt)->rrule((string) $vevent->RRULE); - while($result = $r->next()){ - if($result < $start){ - continue; - } - if($result > $end){ - break; - } - if($return_event['allDay'] == true){ - $return_event['start'] = $result->format('Y-m-d'); - $return_event['end'] = date('Y-m-d', $result->format('U') + --$duration); - }else{ - $return_event['start'] = $result->format('Y-m-d H:i:s'); - $return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration); - } - $return[] = $return_event; - } - }else{ - if($return_event['allDay'] == true){ - $return_event['start'] = $start_dt->format('Y-m-d'); - $end_dt->modify('-1 sec'); - $return_event['end'] = $end_dt->format('Y-m-d'); - }else{ - $return_event['start'] = $start_dt->format('Y-m-d H:i:s'); - $return_event['end'] = $end_dt->format('Y-m-d H:i:s'); - } - $return[] = $return_event; - } + $output[] = OC_Calendar_App::generateEventOutput($event, $start, $end); } -OC_JSON::encodedPrint($return); -?> + +OC_JSON::encodedPrint($output); +?> \ No newline at end of file From 97d216c94d20ec23f8e88ecf490cdaae51ce3b7b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 7 Apr 2012 22:40:20 -0400 Subject: [PATCH 060/116] add dropdown to eventform --- apps/calendar/templates/part.eventform.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index c4c3ae1c1e..e4bae3d4f8 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -1,3 +1,9 @@ + + @@ -241,4 +247,6 @@
    //Alarm
    //Attendees
    -
    //Share
    +
    + inc('share.dropdown'); ?> +
    From 5a4237a31dd326b6ce46a6a7f1e9f45d103f51b6 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 7 Apr 2012 22:41:24 -0400 Subject: [PATCH 061/116] make dropdown menu work with single event sharing --- apps/calendar/templates/share.dropdown.php | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/apps/calendar/templates/share.dropdown.php b/apps/calendar/templates/share.dropdown.php index ca1e128ea7..4e9f41ead1 100644 --- a/apps/calendar/templates/share.dropdown.php +++ b/apps/calendar/templates/share.dropdown.php @@ -1,13 +1,19 @@ @@ -31,7 +37,7 @@ echo html_select_options($allusers, array());
      - +