From a469d15bc8aa6d8b3df7a9697fe384b40e3f4ffb Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 30 Aug 2011 09:28:25 +0200 Subject: [PATCH] Add timezone setting to personal settings page --- apps/calendar/ajax/settimezone.php | 26 ++++++++++++++++++++++++++ apps/calendar/appinfo/app.php | 2 ++ apps/calendar/js/settings.js | 15 +++++++++++++++ apps/calendar/settings.php | 10 ++++++++++ apps/calendar/templates/settings.php | 19 +++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 apps/calendar/ajax/settimezone.php create mode 100644 apps/calendar/js/settings.js create mode 100644 apps/calendar/settings.php create mode 100644 apps/calendar/templates/settings.php diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settimezone.php new file mode 100644 index 0000000000..62e171c66b --- /dev/null +++ b/apps/calendar/ajax/settimezone.php @@ -0,0 +1,26 @@ + "error", "data" => array( "message" => $l->t("Authentication error") ))); + exit(); +} + +// Get data +if( isset( $_POST['timezone'] ) ){ + $timezone=$_POST['timezone']; + OC_Preferences::setValue( OC_User::getUser(), 'calendar', 'timezone', $timezone ); + echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Timezone changed") ))); +}else{ + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Invalid request") ))); +} + +?> diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 0e3d9c9379..5ec2177e20 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -16,3 +16,5 @@ OC_App::addNavigationEntry( array( 'href' => OC_Helper::linkTo( 'calendar', 'index.php' ), 'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ), 'name' => $l->t('Calendar'))); + +OC_App::registerPersonal('calendar', 'settings'); diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js new file mode 100644 index 0000000000..b2da81b0d0 --- /dev/null +++ b/apps/calendar/js/settings.js @@ -0,0 +1,15 @@ +$(document).ready(function(){ + $("#timezone").change( function(){ + // Serialize the data + var post = $( "#timezone" ).serialize(); + // Ajax foo + $.post( oc_webroot + '/apps/calendar/ajax/settimezone.php', post, function(data){ + if( data.status == "success" ){ + } + else{ + $('#timezoneerror').html( data.data.message ); + } + }); + return false; + }); +}); diff --git a/apps/calendar/settings.php b/apps/calendar/settings.php new file mode 100644 index 0000000000..bdf997eef7 --- /dev/null +++ b/apps/calendar/settings.php @@ -0,0 +1,10 @@ +assign('timezone',$timezone); +$tmpl->assign('timezones',DateTimeZone::listIdentifiers()); + +OC_Util::addScript('calendar','settings'); + +return $tmpl->fetchPage(); diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php new file mode 100644 index 0000000000..0b0a4f1c26 --- /dev/null +++ b/apps/calendar/templates/settings.php @@ -0,0 +1,19 @@ +
+
+ + +
+