give users the possibility to choose between monday and sunday as first day of the week

This commit is contained in:
Georg Ehrke 2012-02-26 21:23:20 +01:00
parent a501d4b61e
commit 04c9cc6034
6 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,12 @@
<?php
/**
* Copyright (c) 2012 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();
$firstday = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstday', 'mo');
OC_JSON::encodedPrint(array('firstday' => $firstday));
?>

View File

@ -0,0 +1,17 @@
<?php
/**
* Copyright (c) 2012 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["firstday"])){
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstday', $_POST["firstday"]);
OC_JSON::success();
}else{
OC_JSON::error();
}
?>

View File

@ -661,7 +661,7 @@ $(document).ready(function(){
Calendar.UI.initScroll();
$('#calendar_holder').fullCalendar({
header: false,
firstDay: 1,
firstDay: firstDay,
editable: true,
defaultView: defaultView,
timeFormat: {

View File

@ -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();
});
});

View File

@ -19,6 +19,7 @@
var missing_field_startsbeforeends = '<?php echo addslashes($l->t('The event ends before it starts')) ?>';
var missing_field_dberror = '<?php echo addslashes($l->t('There was a database fail')) ?>';
var totalurl = '<?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars';
var firstDay = '<?php echo (OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'firstday', 'mo') == 'mo' ? '1' : '0'); ?>';
$(document).ready(function() {
<?php
if(array_key_exists('showevent', $_)){

View File

@ -37,6 +37,13 @@
</select>
</td></tr>
<tr><td><label for="firstday" class="bold"><?php echo $l->t('First day of the week');?></label></td><td>
<select style="display: none;" id="firstday" title="<?php echo "First day"; ?>" name="firstday">
<option value="mo" id="mo"><?php echo $l->t("Monday"); ?></option>
<option value="su" id="su"><?php echo $l->t("Sunday"); ?></option>
</select>
</td></tr>
</table>
<?php echo $l->t('Calendar CalDAV syncing address:');?>