kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #2361 from int2001/user_lang
Implemented Userlanguages with a lot of help from @AndreasK79pull/2368/head
commit
8f2ed595e9
|
@ -151,9 +151,62 @@ $config['url_suffix'] = '';
|
|||
| there is an available translation if you intend to use something other
|
||||
| than english.
|
||||
|
|
||||
*/
|
||||
$config['language'] = 'english';
|
||||
*/
|
||||
$lang = 'english'; // this language will be used per default
|
||||
|
||||
if (isset($_COOKIE["language"])) {
|
||||
$tmp_value = $_COOKIE["language"];
|
||||
if (!empty($tmp_value)) { $lang = $tmp_value; }
|
||||
}
|
||||
switch ($lang) { // do this for security-reasons! parse only langs, which are known to us
|
||||
case 'dutch':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'chinese_simplified':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'spanish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'czech':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'bulgarian':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'turkish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'swedish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'polish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'italian':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'greek':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'french':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'finnish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'russian':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'english':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'german':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
}
|
||||
|
||||
$config['cl_multilanguage']=true;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Character Set
|
||||
|
|
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
|||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 132;
|
||||
$config['migration_version'] = 133;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -6,7 +6,6 @@ class User extends CI_Controller {
|
|||
{
|
||||
parent::__construct();
|
||||
|
||||
// Load language files
|
||||
$this->lang->load(array(
|
||||
'account',
|
||||
'lotw',
|
||||
|
@ -33,6 +32,8 @@ class User extends CI_Controller {
|
|||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$data['existing_languages'] = $this->find();
|
||||
|
||||
$this->load->model('bands');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
|
@ -54,15 +55,14 @@ class User extends CI_Controller {
|
|||
|
||||
// Get timezones
|
||||
$data['timezones'] = $this->user_model->timezones();
|
||||
$data['language'] = 'english';
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
{
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data['page_title'] = "Add User";
|
||||
$data['measurement_base'] = $this->config->item('measurement_base');
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
if($this->input->post('user_name'))
|
||||
{
|
||||
if($this->input->post('user_name')) {
|
||||
$data['user_name'] = $this->input->post('user_name');
|
||||
$data['user_email'] = $this->input->post('user_email');
|
||||
$data['user_password'] = $this->input->post('user_password');
|
||||
|
@ -90,14 +90,13 @@ class User extends CI_Controller {
|
|||
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url');
|
||||
$data['user_gridmap_default_band'] = $this->input->post('user_gridmap_default_band');
|
||||
$data['user_gridmap_confirmation'] = ($this->input->post('user_gridmap_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_gridmap_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_gridmap_confirmation_eqsl') !== null ? 'E' : '');
|
||||
$data['language'] = $this->input->post('language');
|
||||
$this->load->view('user/add', $data);
|
||||
} else {
|
||||
$this->load->view('user/add', $data);
|
||||
}
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
switch($this->user_model->add($this->input->post('user_name'),
|
||||
$this->input->post('user_password'),
|
||||
$this->input->post('user_email'),
|
||||
|
@ -125,7 +124,9 @@ class User extends CI_Controller {
|
|||
$this->input->post('user_amsat_status_upload'),
|
||||
$this->input->post('user_mastodon_url'),
|
||||
$this->input->post('user_gridmap_default_band'),
|
||||
($this->input->post('user_gridmap_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_gridmap_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_gridmap_confirmation_eqsl') !== null ? 'E' : ''))) {
|
||||
($this->input->post('user_gridmap_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_gridmap_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_gridmap_confirmation_eqsl') !== null ? 'E' : ''),
|
||||
$this->input->post('language'),
|
||||
)) {
|
||||
// Check for errors
|
||||
case EUSERNAMEEXISTS:
|
||||
$data['username_error'] = 'Username <b>'.$this->input->post('user_name').'</b> already in use!';
|
||||
|
@ -171,16 +172,35 @@ class User extends CI_Controller {
|
|||
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url');
|
||||
$data['user_gridmap_default_band'] = $this->input->post('user_gridmap_default_band');
|
||||
$data['user_gridmap_confirmation'] = ($this->input->post('user_gridmap_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_gridmap_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_gridmap_confirmation_eqsl') !== null ? 'E' : '');
|
||||
$data['language'] = $this->input->post('language');
|
||||
$this->load->view('user/add', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
}
|
||||
|
||||
function find() {
|
||||
$existing_langs = array();
|
||||
$lang_path = APPPATH.'language';
|
||||
|
||||
$results = scandir($lang_path);
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result === '.' or $result === '..') continue;
|
||||
|
||||
if (is_dir(APPPATH.'language' . '/' . $result)) {
|
||||
$dirs[] = $result;
|
||||
}
|
||||
}
|
||||
return $dirs;
|
||||
}
|
||||
|
||||
function edit() {
|
||||
$this->load->model('user_model');
|
||||
if ( ($this->session->userdata('user_id') == '') || ((!$this->user_model->authorize(99)) && ($this->session->userdata('user_id') != $this->uri->segment(3))) ) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
$query = $this->user_model->get_by_id($this->uri->segment(3));
|
||||
|
||||
$data['existing_languages'] = $this->find();
|
||||
|
||||
$this->load->model('bands');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
|
@ -208,7 +228,6 @@ class User extends CI_Controller {
|
|||
{
|
||||
$data['page_title'] = "Edit User";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$q = $query->row();
|
||||
|
||||
$data['id'] = $q->user_id;
|
||||
|
@ -327,6 +346,13 @@ class User extends CI_Controller {
|
|||
$data['user_date_format'] = $q->user_date_format;
|
||||
}
|
||||
|
||||
if($this->input->post('language')) {
|
||||
$data['language'] = $this->input->post('language', true);
|
||||
} else {
|
||||
$data['language'] = $q->language;
|
||||
}
|
||||
|
||||
|
||||
if($this->input->post('user_stylesheet')) {
|
||||
$data['user_stylesheet'] = $this->input->post('user_stylesheet', true);
|
||||
} else {
|
||||
|
@ -429,11 +455,10 @@ class User extends CI_Controller {
|
|||
$data['user_column5'] = $q->user_column5;
|
||||
}
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('user/edit', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
unset($data);
|
||||
switch($this->user_model->edit($this->input->post())) {
|
||||
// Check for errors
|
||||
|
@ -448,6 +473,17 @@ class User extends CI_Controller {
|
|||
break;
|
||||
// All okay, return to user screen
|
||||
case OK:
|
||||
if ($this->session->userdata('user_id') == $this->uri->segment(3)) { // Editing own User? Set cookie!
|
||||
$cookie= array(
|
||||
|
||||
'name' => 'language',
|
||||
'value' => $this->input->post('language', true),
|
||||
'expire' => time()+1000,
|
||||
'secure' => FALSE
|
||||
|
||||
);
|
||||
$this->input->set_cookie($cookie);
|
||||
}
|
||||
if($this->session->userdata('user_id') == $this->input->post('id', true)) {
|
||||
$this->session->set_flashdata('success', 'User '.$this->input->post('user_name', true).' edited');
|
||||
redirect('user/edit/'.$this->uri->segment(3));
|
||||
|
@ -487,6 +523,7 @@ class User extends CI_Controller {
|
|||
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url');
|
||||
$data['user_gridmap_default_band'] = $this->input->post('user_gridmap_default_band');
|
||||
$data['user_gridmap_confirmation'] = ($this->input->post('user_gridmap_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_gridmap_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_gridmap_confirmation_eqsl') !== null ? 'E' : '');
|
||||
$data['language'] = $this->input->post('language');
|
||||
$this->load->view('user/edit');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
@ -557,19 +594,26 @@ class User extends CI_Controller {
|
|||
|
||||
$data['user'] = $query->row();
|
||||
|
||||
if ($this->form_validation->run() == FALSE)
|
||||
{
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$data['page_title'] = "Login";
|
||||
$this->load->view('interface_assets/mini_header', $data);
|
||||
$this->load->view('user/login');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if($this->user_model->login() == 1) {
|
||||
$this->session->set_flashdata('notice', 'User logged in');
|
||||
$this->user_model->update_session($data['user']->user_id);
|
||||
$cookie= array(
|
||||
|
||||
'name' => 'language',
|
||||
'value' => $data['user']->language,
|
||||
'expire' => time()+1000,
|
||||
'secure' => FALSE
|
||||
|
||||
);
|
||||
$this->input->set_cookie($cookie);
|
||||
redirect('dashboard');
|
||||
} else {
|
||||
$this->session->set_flashdata('error', 'Incorrect username or password!');
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* This adds a field to user-table to hold/persist language-setting per user
|
||||
*/
|
||||
|
||||
class Migration_add_user_language extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
if (!$this->db->field_exists('language', 'users')) {
|
||||
$fields = array(
|
||||
'language varchar(32) default "english"',
|
||||
);
|
||||
|
||||
$this->dbforge->add_column('users', $fields);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if ($this->db->field_exists('language', 'users')) {
|
||||
$this->dbforge->drop_column('users', 'language');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -124,7 +124,7 @@ class User_Model extends CI_Model {
|
|||
$measurement, $user_date_format, $user_stylesheet, $user_qth_lookup, $user_sota_lookup, $user_wwff_lookup,
|
||||
$user_pota_lookup, $user_show_notes, $user_column1, $user_column2, $user_column3, $user_column4, $user_column5,
|
||||
$user_show_profile_image, $user_previous_qsl_type, $user_amsat_status_upload, $user_mastodon_url,
|
||||
$user_gridmap_default_band, $user_gridmap_confirmation) {
|
||||
$user_gridmap_default_band, $user_gridmap_confirmation, $language) {
|
||||
// Check that the user isn't already used
|
||||
if(!$this->exists($username)) {
|
||||
$data = array(
|
||||
|
@ -156,6 +156,7 @@ class User_Model extends CI_Model {
|
|||
'user_mastodon_url' => xss_clean($user_mastodon_url),
|
||||
'user_gridmap_default_band' => xss_clean($user_gridmap_default_band),
|
||||
'user_gridmap_confirmation' => xss_clean($user_gridmap_confirmation),
|
||||
'language' => xss_clean($language),
|
||||
);
|
||||
|
||||
// Check the password is valid
|
||||
|
@ -215,6 +216,7 @@ class User_Model extends CI_Model {
|
|||
'user_mastodon_url' => xss_clean($fields['user_mastodon_url']),
|
||||
'user_gridmap_default_band' => xss_clean($fields['user_gridmap_default_band']),
|
||||
'user_gridmap_confirmation' => (isset($fields['user_gridmap_confirmation_qsl']) ? 'Q' : '').(isset($fields['user_gridmap_confirmation_lotw']) ? 'L' : '').(isset($fields['user_gridmap_confirmation_eqsl']) ? 'E' : ''),
|
||||
'language' => xss_clean($fields['language']),
|
||||
);
|
||||
|
||||
// Check to see if the user is allowed to change user levels
|
||||
|
@ -339,6 +341,7 @@ class User_Model extends CI_Model {
|
|||
'user_gridmap_default_band' => $u->row()->user_gridmap_default_band,
|
||||
'user_gridmap_confirmation' => $u->row()->user_gridmap_confirmation,
|
||||
'active_station_logbook' => $u->row()->active_station_logbook,
|
||||
'language' => isset($u->row()->language) ? $u->row()->language: 'english',
|
||||
);
|
||||
|
||||
$this->session->set_userdata($userdata);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="container">
|
||||
<br>
|
||||
<br>
|
||||
<?php if($this->session->flashdata('message')) { ?>
|
||||
<!-- Display Message -->
|
||||
<div class="alert-message error">
|
||||
|
@ -7,13 +7,13 @@
|
|||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<div class="card">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Maintenance
|
||||
QSO-DB Maintenance
|
||||
</div>
|
||||
<?php if($is_there_qsos_with_no_station_id >= 1) { ?>
|
||||
<?php if($is_there_qsos_with_no_station_id >= 1) { ?>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span class="badge badge-pill badge-warning">Warning</span> The Database contains QSOs without a station-profile (location)<br/>
|
||||
</div>
|
||||
|
@ -40,7 +40,8 @@
|
|||
}
|
||||
echo $options.'</select></td><td><button class="btn btn-warning" onClick="reassign(\''.$call['COL_STATION_CALLSIGN'].'\',$(\'#station_profile option:selected\').val());"><i class="fas fa-sync"></i>Reassign</a></button></td></tr>';
|
||||
} ?>
|
||||
</tbody></table>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -49,9 +50,29 @@
|
|||
<span class="badge badge-pill badge-success">Everything ok</span> Every QSO in your Database is assigned to a station-profile (location)
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Settings Maintenance
|
||||
</div>
|
||||
<?php if(!$this->config->item('cl_multilanguage')) { ?>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<span class="badge badge-pill badge-warning">Warning</span> You didn't enabled Multilanguage support in your config.php
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text">Please edit your ./application/config/config.php File and add some rows to it:</br></br>
|
||||
Go to your application/config Folder and compare config.sample.php with your config.php</br>
|
||||
You'll probably find a block with language-settings. Please include this block into your current config.php
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
} else { ?>
|
||||
<div class="alert alert-secondary" role="alert">
|
||||
<span class="badge badge-pill badge-success">Everything ok</span> You have enabled Multuser-Language support
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -190,6 +190,18 @@
|
|||
</select>
|
||||
<small id="user_measurement_base_Help" class="form-text text-muted"><?php echo lang('account_choose_which_unit_distances_will_be_shown_in'); ?></small>
|
||||
</div>
|
||||
<?php if ($this->config->item('cl_multilanguage')) { ?>
|
||||
<div class="form-group">
|
||||
<label for="language">Cloudlog Language</label>
|
||||
<?php
|
||||
foreach($existing_languages as $lang){
|
||||
$options[$lang] = ucfirst($lang);
|
||||
}
|
||||
echo form_dropdown('language', $options, $language);
|
||||
?>
|
||||
<small id="language_Help" class="form-text text-muted">Choose Cloudlog language.</small>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -191,6 +191,19 @@
|
|||
</select>
|
||||
<small id="user_measurement_base_Help" class="form-text text-muted"><?php echo lang('account_choose_which_unit_distances_will_be_shown_in'); ?></small>
|
||||
</div>
|
||||
|
||||
<?php if ($this->config->item('cl_multilanguage')) { ?>
|
||||
<div class="form-group">
|
||||
<label for="language">Cloudlog Language</label>
|
||||
<?php
|
||||
foreach($existing_languages as $lang){
|
||||
$options[$lang] = ucfirst($lang);
|
||||
}
|
||||
echo form_dropdown('language', $options, $language);
|
||||
?>
|
||||
<small id="language_Help" class="form-text text-muted">Choose Cloudlog language.</small>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -153,8 +153,62 @@ $config['url_suffix'] = '';
|
|||
| there is an available translation if you intend to use something other
|
||||
| than english.
|
||||
|
|
||||
*/
|
||||
$config['language'] = 'english';
|
||||
*/
|
||||
$lang = 'english'; // this language will be used per default
|
||||
|
||||
if (isset($_COOKIE["language"])) {
|
||||
$tmp_value = $_COOKIE["language"];
|
||||
if (!empty($tmp_value)) { $lang = $tmp_value; }
|
||||
}
|
||||
switch ($lang) { // do this for security-reasons! parse only langs, which are known to us
|
||||
case 'dutch':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'chinese_simplified':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'spanish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'czech':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'bulgarian':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'turkish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'swedish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'polish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'italian':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'greek':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'french':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'finnish':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'russian':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'english':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
case 'german':
|
||||
$config['language'] = $lang;
|
||||
break;
|
||||
}
|
||||
|
||||
$config['cl_multilanguage']=true;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
Ładowanie…
Reference in New Issue