nextcloud/settings/ajax/setlanguage.php

27 lines
710 B
PHP
Raw Normal View History

2011-06-20 16:33:02 +04:00
<?php
// Init owncloud
require_once('../../lib/base.php');
2011-06-20 16:51:33 +04:00
$l=new OC_L10N('settings');
2011-06-20 16:33:02 +04:00
// We send json data
header( "Content-Type: application/jsonrequest" );
// Check if we are a user
2011-07-29 23:36:03 +04:00
if( !OC_User::isLoggedIn()){
2011-06-20 16:51:33 +04:00
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Authentication error") )));
2011-06-20 16:33:02 +04:00
exit();
}
// Get data
if( isset( $_POST['lang'] ) ){
$lang=$_POST['lang'];
2011-07-29 23:36:03 +04:00
OC_Preferences::setValue( OC_User::getUser(), 'core', 'lang', $lang );
2011-06-20 16:51:33 +04:00
echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Language changed") )));
2011-06-20 16:33:02 +04:00
}else{
2011-06-20 16:51:33 +04:00
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Invalid request") )));
2011-06-20 16:33:02 +04:00
}
?>