diff --git a/apps/calendar/ajax/settings/getfirstday.php b/apps/calendar/ajax/settings/getfirstday.php new file mode 100644 index 00000000000..cab5870509a --- /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 00000000000..3b652212205 --- /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 84b76a3c88f..a1b25780b76 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 fcbfc423db3..c768a47a797 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 eb82d0d02ad..63c3b500296 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:');?>