add option to turn on websockets for winkey

这个提交包含在:
Peter Goodhall 2025-05-28 13:38:25 +01:00
父节点 e2006a936f
当前提交 7156b185e1
共有 5 个文件被更改,包括 56 次插入15 次删除

查看文件

@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 196;
$config['migration_version'] = 197;
/*
|--------------------------------------------------------------------------

查看文件

@ -215,7 +215,7 @@ class User extends CI_Controller
$this->input->post('user_callbook_username'),
$this->input->post('user_callbook_password')
)) {
// Check for errors
// Check for errors
case EUSERNAMEEXISTS:
$data['username_error'] = 'Username <b>' . $this->input->post('user_name') . '</b> already in use!';
break;
@ -225,7 +225,7 @@ class User extends CI_Controller
case EPASSWORDINVALID:
$data['password_error'] = 'Invalid password!';
break;
// All okay, return to user screen
// All okay, return to user screen
case OK:
$this->session->set_flashdata('notice', 'User ' . $this->input->post('user_name') . ' added');
redirect('user');
@ -576,6 +576,12 @@ class User extends CI_Controller
$data['user_winkey'] = $q->winkey;
}
if ($this->input->post('user_winkey_websocket')) {
$data['user_winkey_websocket'] = $this->input->post('user_winkey_websocket', true);
} else {
$data['user_winkey_websocket'] = $q->winkey_websocket;
}
$this->load->model('user_options_model');
$callbook_type_object = $this->user_options_model->get_options('callbook')->result();
@ -730,8 +736,14 @@ class User extends CI_Controller
$this->load->view('interface_assets/footer');
} else {
unset($data);
switch ($this->user_model->edit($this->input->post())) {
// Check for errors
$post_data = $this->input->post();
if (!isset($post_data['user_winkey_websocket'])) {
$post_data['user_winkey_websocket'] = '0';
}
switch ($this->user_model->edit($post_data)) {
// Check for errors
case EUSERNAMEEXISTS:
$data['username_error'] = 'Username <b>' . $this->input->post('user_name', true) . '</b> already in use!';
break;
@ -741,7 +753,7 @@ class User extends CI_Controller
case EPASSWORDINVALID:
$data['password_error'] = 'Invalid password!';
break;
// All okay, return to user screen
// 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(
@ -892,6 +904,7 @@ class User extends CI_Controller
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter');
$data['language'] = $this->input->post('language');
$data['user_winkey'] = $this->input->post('user_winkey');
$data['user_winkey_websocket'] = $this->input->post('user_winkey_websocket');
$data['user_hamsat_key'] = $this->input->post('user_hamsat_key');
$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only');

查看文件

@ -0,0 +1,30 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
* This adds a field to user-table to hold winkey websocket setting
*/
// Migration: 197_add_winkey_websocket
class Migration_add_winkey_websocket extends CI_Migration {
public function up()
{
// Check if winkey_websocket exists in the user table if not create a boolean field
if (!$this->db->field_exists('winkey_websocket', 'users')) {
$fields = array(
'winkey_websocket boolean default 0',
);
$this->dbforge->add_column('users', $fields);
}
}
public function down()
{
if ($this->db->field_exists('winkey_websocket', 'users')) {
$this->dbforge->drop_column('users', 'winkey_websocket');
}
}
}

查看文件

@ -267,6 +267,7 @@ class User_Model extends CI_Model {
'user_quicklog_enter' => xss_clean($fields['user_quicklog_enter']),
'language' => xss_clean($fields['language']),
'winkey' => xss_clean($fields['user_winkey']),
'winkey_websocket' => xss_clean($fields['user_winkey_websocket']),
);
$this->db->query("replace into user_options (user_id, option_type, option_name, option_key, option_value) values (" . $fields['id'] . ", 'hamsat','hamsat_key','api','".xss_clean($fields['user_hamsat_key'])."');");

查看文件

@ -1205,10 +1205,7 @@
<hr />
<div class="mb-3">
<div class="form-check form-switch">
<?php if (!isset($user_winkey_websocket)) {
$user_winkey_websocket = '0';
} ?>
<input name="user_winkey_websocket" class="form-check-input" type="checkbox" role="switch" id="user_winkey_websocket" value="1" <?php if (isset($user_winkey_websocket) && $user_winkey_websocket == 1) {
<input name="user_winkey_websocket" class="form-check-input" type="checkbox" role="switch" id="user_winkey_websocket" value="1" <?php if ($user_winkey_websocket == 1) {
echo 'checked';
} ?>>
<label class="form-check-label" for="user_winkey_websocket">Winkey Web Sockets</label>