diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settimezone.php new file mode 100644 index 0000000000000000000000000000000000000000..62e171c66b9bae983368cc9c6e1bf88fb239c99a --- /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 0e3d9c9379eaa2bc3e1c2242f274ff4fec9ff061..5ec2177e20cff91f27849ab96857185019349cea 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 0000000000000000000000000000000000000000..b2da81b0d0f9a291d42f70499d97f023c521bb0c --- /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 0000000000000000000000000000000000000000..bdf997eef70e9cbddc17f665c33b7fccffd5c7b9 --- /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 0000000000000000000000000000000000000000..0b0a4f1c265584e3db1daa60e45a230553c935b9 --- /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>