From bf6414d3ad2a19bc9bf5174abd82d8ffaee02ef4 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 1 Oct 2011 10:39:07 +0200 Subject: [PATCH] choosable time format --- apps/calendar/ajax/settimeformat.php | 17 ++++++++++++++ apps/calendar/ajax/timeformat.php | 12 ++++++++++ apps/calendar/js/settings.js | 12 ++++++++++ apps/calendar/templates/calendar.php | 34 ++++------------------------ apps/calendar/templates/settings.php | 7 +++++- 5 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 apps/calendar/ajax/settimeformat.php create mode 100644 apps/calendar/ajax/timeformat.php diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php new file mode 100644 index 00000000000..7805120ba5e --- /dev/null +++ b/apps/calendar/ajax/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/timeformat.php b/apps/calendar/ajax/timeformat.php new file mode 100644 index 00000000000..3533adcf8e0 --- /dev/null +++ b/apps/calendar/ajax/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/js/settings.js b/apps/calendar/js/settings.js index 5d048b83c36..fc5fc7377a6 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -34,6 +34,18 @@ $(document).ready(function(){ minWidth:'auto', }); }); + $("#timeformat").change( function(){ + var data = $("#timeformat").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){ + if(data == "error"){ + console.log("saving timeformat failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { + $("#" + jsondata.timeformat).attr('selected',true); + $("#timeformat").chosen(); + }); $("#weekend").change( function(){ var data = $("#weekend").serialize(); $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index 25d92b0c7e4..317bb17ddbc 100644 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -1,32 +1,4 @@ $l->t('All day'), - 0 => '0', - 1 => '1', - 2 => '2', - 3 => '3', - 4 => '4', - 5 => '5', - 6 => '6', - 7 => '7', - 8 => '8', - 9 => '9', - 10 => '10', - 11 => '11', - 12 => '12', - 13 => '13', - 14 => '14', - 15 => '15', - 16 => '16', - 17 => '17', - 18 => '18', - 19 => '19', - 20 => '20', - 21 => '21', - 22 => '22', - 23 => '23', -); -/* $hours24 = array( 'allday' => $l->t('All day'), 0 => '0', @@ -81,7 +53,11 @@ $hoursampm = array( 22 => '10 p.m.', 23 => '11 p.m.', ); -*/ +if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){ + $hours = $hours24; +}else{ + $hours = $hoursampm; +} $weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); $dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); $weekdays = array(); diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index 7df357099e8..d3e3e3c525e 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -38,13 +38,18 @@ OC_UTIL::addStyle('', 'jquery.multiselect'); ?>    - "> ' . $l->t($weekdays[$i]) . ''; } ?> +    + +
Calendar CalDAV syncing address: -- 2.39.5