From 04c9cc60349fe8d6899a42781ccacaf6d9df5bf5 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 26 Feb 2012 21:23:20 +0100 Subject: [PATCH] give users the possibility to choose between monday and sunday as first day of the week --- apps/calendar/ajax/settings/getfirstday.php | 12 ++++++++++++ apps/calendar/ajax/settings/setfirstday.php | 17 +++++++++++++++++ apps/calendar/js/calendar.js | 2 +- apps/calendar/js/settings.js | 12 ++++++++++++ apps/calendar/templates/calendar.php | 1 + apps/calendar/templates/settings.php | 7 +++++++ 6 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 apps/calendar/ajax/settings/getfirstday.php create mode 100644 apps/calendar/ajax/settings/setfirstday.php diff --git a/apps/calendar/ajax/settings/getfirstday.php b/apps/calendar/ajax/settings/getfirstday.php new file mode 100644 index 0000000000..cab5870509 --- /dev/null +++ b/apps/calendar/ajax/settings/getfirstday.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(); +$firstday = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstday', 'mo'); +OC_JSON::encodedPrint(array('firstday' => $firstday)); +?> diff --git a/apps/calendar/ajax/settings/setfirstday.php b/apps/calendar/ajax/settings/setfirstday.php new file mode 100644 index 0000000000..3b65221220 --- /dev/null +++ b/apps/calendar/ajax/settings/setfirstday.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["firstday"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstday', $_POST["firstday"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 84b76a3c88..a1b25780b7 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -661,7 +661,7 @@ $(document).ready(function(){ Calendar.UI.initScroll(); $('#calendar_holder').fullCalendar({ header: false, - firstDay: 1, + firstDay: firstDay, editable: true, defaultView: defaultView, timeFormat: { diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index fcbfc423db..c768a47a79 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -17,6 +17,14 @@ $(document).ready(function(){ } }); }); + $('#firstday').change( function(){ + var data = $('#firstday').serialize(); + $.post( OC.filePath('calendar', 'ajax/settings', 'setfirstday.php'), data, function(data){ + if(data == 'error'){ + console.log('saving firstday failed'); + } + }); + }); $('#timezonedetection').change( function(){ var post = $('#timezonedetection').serialize(); $.post( OC.filePath('calendar', 'ajax/settings', 'timezonedetection.php'), post, function(data){ @@ -32,4 +40,8 @@ $(document).ready(function(){ $('#timezonedetection').attr('checked', 'checked'); } }); + $.getJSON(OC.filePath('calendar', 'ajax/settings', 'getfirstday.php'), function(jsondata, status) { + $('#' + jsondata.firstday).attr('selected',true); + $('#firstday').chosen(); + }); }); diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index eb82d0d02a..63c3b50029 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -19,6 +19,7 @@ var missing_field_startsbeforeends = 't('The event ends before it starts')) ?>'; var missing_field_dberror = 't('There was a database fail')) ?>'; var totalurl = '/calendars'; + var firstDay = ''; $(document).ready(function() { + + + + t('Calendar CalDAV syncing address:');?>