choosable default duration of event
This commit is contained in:
parent
1ea183a0f7
commit
f9824f6108
5 changed files with 55 additions and 27 deletions
12
apps/calendar/ajax/duration.php
Normal file
12
apps/calendar/ajax/duration.php
Normal file
|
@ -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));
|
||||||
|
?>
|
|
@ -29,35 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
|
||||||
$starttime = '0';
|
$starttime = '0';
|
||||||
$startminutes = '00';
|
$startminutes = '00';
|
||||||
}else{
|
}else{
|
||||||
$starttime = date('H');
|
$starttime = date('G');
|
||||||
if(strlen($starttime) == 2 && $starttime <= 9){
|
|
||||||
$starttime = substr($starttime, 1, 1);
|
|
||||||
}
|
|
||||||
$startminutes = date('i');
|
$startminutes = date('i');
|
||||||
}
|
}
|
||||||
|
|
||||||
$endday = $startday;
|
$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear);
|
||||||
$endmonth = $startmonth;
|
$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
|
||||||
$endyear = $startyear;
|
$datetimestamp = $datetimestamp + ($duration * 60);
|
||||||
$endtime = $starttime;
|
$endmonth = date("m", $datetimestamp);
|
||||||
$endminutes = $startminutes;
|
$endday = date("d", $datetimestamp);
|
||||||
if($endtime == 23) {
|
$endyear = date("Y", $datetimestamp);
|
||||||
if($startday == date(t, mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear))){
|
$endtime = date("G", $datetimestamp);
|
||||||
$datetimestamp = mktime(0, 0, 0, $startmonth, $startday, $startyear);
|
$endminutes = date("i", $datetimestamp);
|
||||||
$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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmpl = new OC_Template('calendar', 'part.newevent');
|
$tmpl = new OC_Template('calendar', 'part.newevent');
|
||||||
$tmpl->assign('calendar_options', $calendar_options);
|
$tmpl->assign('calendar_options', $calendar_options);
|
||||||
|
|
17
apps/calendar/ajax/setduration.php
Normal file
17
apps/calendar/ajax/setduration.php
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
|
@ -46,6 +46,17 @@ $(document).ready(function(){
|
||||||
$("#" + jsondata.timeformat).attr('selected',true);
|
$("#" + jsondata.timeformat).attr('selected',true);
|
||||||
$("#timeformat").chosen();
|
$("#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(){
|
$("#weekend").change( function(){
|
||||||
var data = $("#weekend").serialize();
|
var data = $("#weekend").serialize();
|
||||||
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
|
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){
|
||||||
|
|
|
@ -50,7 +50,9 @@ OC_UTIL::addStyle('', 'jquery.multiselect');
|
||||||
<select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
|
<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="24" id="24h"><?php echo $l->t("24 h"); ?></option>
|
||||||
<option value="ampm" id="ampm"><?php echo $l->t("am/pm"); ?></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 />
|
<br />
|
||||||
Calendar CalDAV syncing address:
|
Calendar CalDAV syncing address:
|
||||||
<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />
|
<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />
|
||||||
|
|
Loading…
Reference in a new issue