diff options
author | Bart Visscher <bartv@thisnet.nl> | 2011-08-30 09:28:25 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2011-08-30 09:28:25 +0200 |
commit | a469d15bc8aa6d8b3df7a9697fe384b40e3f4ffb (patch) | |
tree | e91f9b3ad1cd188ef635f383f5edb98e2a12a213 | |
parent | c769f961ab7acbcf38c2c0c53bda17c579cb7678 (diff) | |
download | nextcloud-server-a469d15bc8aa6d8b3df7a9697fe384b40e3f4ffb.tar.gz nextcloud-server-a469d15bc8aa6d8b3df7a9697fe384b40e3f4ffb.zip |
Add timezone setting to personal settings page
-rw-r--r-- | apps/calendar/ajax/settimezone.php | 26 | ||||
-rw-r--r-- | apps/calendar/appinfo/app.php | 2 | ||||
-rw-r--r-- | apps/calendar/js/settings.js | 15 | ||||
-rw-r--r-- | apps/calendar/settings.php | 10 | ||||
-rw-r--r-- | apps/calendar/templates/settings.php | 19 |
5 files changed, 72 insertions, 0 deletions
diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settimezone.php new file mode 100644 index 00000000000..62e171c66b9 --- /dev/null +++ b/apps/calendar/ajax/settimezone.php @@ -0,0 +1,26 @@ +<?php + +// Init owncloud +require_once('../../../lib/base.php'); + +$l=new OC_L10N('calendar'); + +// We send json data +header( "Content-Type: application/jsonrequest" ); + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( "status" => "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 0e3d9c9379e..5ec2177e20c 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 00000000000..b2da81b0d0f --- /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 00000000000..bdf997eef70 --- /dev/null +++ b/apps/calendar/settings.php @@ -0,0 +1,10 @@ +<?php + +$tmpl = new OC_Template( 'calendar', 'settings'); +$timezone=OC_Preferences::getValue(OC_User::getUser(),'calendar','timezone',''); +$tmpl->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 00000000000..0b0a4f1c265 --- /dev/null +++ b/apps/calendar/templates/settings.php @@ -0,0 +1,19 @@ +<form id="calendar"> + <fieldset class="personalblock"> + <label for="timezone"><strong><?php echo $l->t('Timezone');?></strong></label> + <select id="timezone" name="timezone"> + <?php foreach($_['timezones'] as $timezone): + if ( preg_match( '/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $timezone ) ): + $ex=explode('/', $timezone, 2);//obtain continent,city + if ($continent!=$ex[0]): + if ($continent!="") echo '</optgroup>'; + echo '<optgroup label="'.$ex[0].'">'; + endif; + $city=$ex[1]; + $continent=$ex[0]; + echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>'; + endif; + endforeach;?> + </select><span id="timezoneerror"></span> + </fieldset> +</form> |