diff options
author | Georg Ehrke <georg.stefan.germany@googlemail.com> | 2011-10-01 22:53:18 +0200 |
---|---|---|
committer | Georg Ehrke <georg.stefan.germany@googlemail.com> | 2011-10-01 22:53:18 +0200 |
commit | f9824f61087f7a1c7f449c9fb09bcf3acd119aab (patch) | |
tree | 1d1c9fdf605d00bffb5d443c3c3e3a112d1d2ec8 /apps | |
parent | 1ea183a0f7b3e70ed5c1a682605b5dc1265041f2 (diff) | |
download | nextcloud-server-f9824f61087f7a1c7f449c9fb09bcf3acd119aab.tar.gz nextcloud-server-f9824f61087f7a1c7f449c9fb09bcf3acd119aab.zip |
choosable default duration of event
Diffstat (limited to 'apps')
-rw-r--r-- | apps/calendar/ajax/duration.php | 12 | ||||
-rw-r--r-- | apps/calendar/ajax/neweventform.php | 38 | ||||
-rw-r--r-- | apps/calendar/ajax/setduration.php | 17 | ||||
-rw-r--r-- | apps/calendar/js/settings.js | 11 | ||||
-rw-r--r-- | apps/calendar/templates/settings.php | 4 |
5 files changed, 55 insertions, 27 deletions
diff --git a/apps/calendar/ajax/duration.php b/apps/calendar/ajax/duration.php new file mode 100644 index 00000000000..cdc41388abd --- /dev/null +++ b/apps/calendar/ajax/duration.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60"); +OC_JSON::encodedPrint(array("duration" => $duration)); +?> diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php index 9bab2cd4846..9d4dcfa2e13 100644 --- a/apps/calendar/ajax/neweventform.php +++ b/apps/calendar/ajax/neweventform.php @@ -29,35 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){ $starttime = '0'; $startminutes = '00'; }else{ - $starttime = date('H'); - if(strlen($starttime) == 2 && $starttime <= 9){ - $starttime = substr($starttime, 1, 1); - } + $starttime = date('G'); + $startminutes = date('i'); } -$endday = $startday; -$endmonth = $startmonth; -$endyear = $startyear; -$endtime = $starttime; -$endminutes = $startminutes; -if($endtime == 23) { - if($startday == date(t, mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear))){ - $datetimestamp = mktime(0, 0, 0, $startmonth, $startday, $startyear); - $datetimestamp = $datetimestamp + 86400; - $endmonth = date("m", $datetimestamp); - $endday = date("d", $datetimestamp); - $endyear = date("Y", $datetimestamp); - }else{ - $endday++; - if($endday <= 9){ - $endday = "0" . $endday; - } - } - $endtime = 0; -} else { - $endtime++; -} +$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear); +$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60"); +$datetimestamp = $datetimestamp + ($duration * 60); +$endmonth = date("m", $datetimestamp); +$endday = date("d", $datetimestamp); +$endyear = date("Y", $datetimestamp); +$endtime = date("G", $datetimestamp); +$endminutes = date("i", $datetimestamp); + + $tmpl = new OC_Template('calendar', 'part.newevent'); $tmpl->assign('calendar_options', $calendar_options); diff --git a/apps/calendar/ajax/setduration.php b/apps/calendar/ajax/setduration.php new file mode 100644 index 00000000000..a75c8faea42 --- /dev/null +++ b/apps/calendar/ajax/setduration.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +if(isset($_POST["duration"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index fc5fc7377a6..07e912aaa7a 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -46,6 +46,17 @@ $(document).ready(function(){ $("#" + jsondata.timeformat).attr('selected',true); $("#timeformat").chosen(); }); + $("#duration").blur( function(){ + var data = $("#duration").val(); + $.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){ + if(data == "error"){ + console.log("saving duration failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) { + $("#duration").val(jsondata.duration); + }); $("#weekend").change( function(){ var data = $("#weekend").serialize(); $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index d3e3e3c525e..75f094aab47 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -50,7 +50,9 @@ OC_UTIL::addStyle('', 'jquery.multiselect'); <select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat"> <option value="24" id="24h"><?php echo $l->t("24 h"); ?></option> <option value="ampm" id="ampm"><?php echo $l->t("am/pm"); ?></option> - </select> + </select> + <label for="duration"><strong><?php echo $l->t('Event duration');?></strong></label> + <input type="text" maxlength="3" size="3" style="width: 2em;" id="duration" name="duration" /> <strong><?php echo $l->t("Minutes");?></strong> <br /> Calendar CalDAV syncing address: <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br /> |