add option to turn on websockets for winkey
这个提交包含在:
父节点
e2006a936f
当前提交
7156b185e1
共有 5 个文件被更改,包括 56 次插入 和 15 次删除
|
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['migration_version'] = 196;
|
$config['migration_version'] = 197;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class User extends CI_Controller
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
|
|
||||||
// Check if the user is authorized
|
// Check if the user is authorized
|
||||||
if (!$this->user_model->authorize(99)) {
|
if (!$this->user_model->authorize(99)) {
|
||||||
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
|
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
|
||||||
|
|
@ -215,7 +215,7 @@ class User extends CI_Controller
|
||||||
$this->input->post('user_callbook_username'),
|
$this->input->post('user_callbook_username'),
|
||||||
$this->input->post('user_callbook_password')
|
$this->input->post('user_callbook_password')
|
||||||
)) {
|
)) {
|
||||||
// Check for errors
|
// Check for errors
|
||||||
case EUSERNAMEEXISTS:
|
case EUSERNAMEEXISTS:
|
||||||
$data['username_error'] = 'Username <b>' . $this->input->post('user_name') . '</b> already in use!';
|
$data['username_error'] = 'Username <b>' . $this->input->post('user_name') . '</b> already in use!';
|
||||||
break;
|
break;
|
||||||
|
|
@ -225,7 +225,7 @@ class User extends CI_Controller
|
||||||
case EPASSWORDINVALID:
|
case EPASSWORDINVALID:
|
||||||
$data['password_error'] = 'Invalid password!';
|
$data['password_error'] = 'Invalid password!';
|
||||||
break;
|
break;
|
||||||
// All okay, return to user screen
|
// All okay, return to user screen
|
||||||
case OK:
|
case OK:
|
||||||
$this->session->set_flashdata('notice', 'User ' . $this->input->post('user_name') . ' added');
|
$this->session->set_flashdata('notice', 'User ' . $this->input->post('user_name') . ' added');
|
||||||
redirect('user');
|
redirect('user');
|
||||||
|
|
@ -576,6 +576,12 @@ class User extends CI_Controller
|
||||||
$data['user_winkey'] = $q->winkey;
|
$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');
|
$this->load->model('user_options_model');
|
||||||
$callbook_type_object = $this->user_options_model->get_options('callbook')->result();
|
$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');
|
$this->load->view('interface_assets/footer');
|
||||||
} else {
|
} else {
|
||||||
unset($data);
|
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:
|
case EUSERNAMEEXISTS:
|
||||||
$data['username_error'] = 'Username <b>' . $this->input->post('user_name', true) . '</b> already in use!';
|
$data['username_error'] = 'Username <b>' . $this->input->post('user_name', true) . '</b> already in use!';
|
||||||
break;
|
break;
|
||||||
|
|
@ -741,7 +753,7 @@ class User extends CI_Controller
|
||||||
case EPASSWORDINVALID:
|
case EPASSWORDINVALID:
|
||||||
$data['password_error'] = 'Invalid password!';
|
$data['password_error'] = 'Invalid password!';
|
||||||
break;
|
break;
|
||||||
// All okay, return to user screen
|
// All okay, return to user screen
|
||||||
case OK:
|
case OK:
|
||||||
if ($this->session->userdata('user_id') == $this->uri->segment(3)) { // Editing own User? Set cookie!
|
if ($this->session->userdata('user_id') == $this->uri->segment(3)) { // Editing own User? Set cookie!
|
||||||
$cookie = array(
|
$cookie = array(
|
||||||
|
|
@ -755,25 +767,25 @@ class User extends CI_Controller
|
||||||
$this->input->set_cookie($cookie);
|
$this->input->set_cookie($cookie);
|
||||||
}
|
}
|
||||||
if ($this->session->userdata('user_id') == $this->input->post('id', true)) {
|
if ($this->session->userdata('user_id') == $this->input->post('id', true)) {
|
||||||
|
|
||||||
// Handle user_callbook_password
|
// Handle user_callbook_password
|
||||||
|
|
||||||
if (isset($_POST['user_callbook_password']) && !empty($_POST['user_callbook_password'])) {
|
if (isset($_POST['user_callbook_password']) && !empty($_POST['user_callbook_password'])) {
|
||||||
|
|
||||||
// Handle user_callbook_type
|
// Handle user_callbook_type
|
||||||
if (isset($_POST['user_callbook_type'])) {
|
if (isset($_POST['user_callbook_type'])) {
|
||||||
$this->user_options_model->set_option('callbook', 'callbook_type', array('value' => $_POST['user_callbook_type']));
|
$this->user_options_model->set_option('callbook', 'callbook_type', array('value' => $_POST['user_callbook_type']));
|
||||||
} else {
|
} else {
|
||||||
$this->user_options_model->set_option('callbook', 'callbook_type', array('value' => ''));
|
$this->user_options_model->set_option('callbook', 'callbook_type', array('value' => ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle user_callbook_username
|
// Handle user_callbook_username
|
||||||
if (isset($_POST['user_callbook_username'])) {
|
if (isset($_POST['user_callbook_username'])) {
|
||||||
$this->user_options_model->set_option('callbook', 'callbook_username', array('value' => $_POST['user_callbook_username']));
|
$this->user_options_model->set_option('callbook', 'callbook_username', array('value' => $_POST['user_callbook_username']));
|
||||||
} else {
|
} else {
|
||||||
$this->user_options_model->set_option('callbook', 'callbook_username', array('value' => ''));
|
$this->user_options_model->set_option('callbook', 'callbook_username', array('value' => ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the encryption library
|
// Load the encryption library
|
||||||
$this->load->library('encryption');
|
$this->load->library('encryption');
|
||||||
|
|
||||||
|
|
@ -892,6 +904,7 @@ class User extends CI_Controller
|
||||||
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter');
|
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter');
|
||||||
$data['language'] = $this->input->post('language');
|
$data['language'] = $this->input->post('language');
|
||||||
$data['user_winkey'] = $this->input->post('user_winkey');
|
$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_key'] = $this->input->post('user_hamsat_key');
|
||||||
$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only');
|
$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']),
|
'user_quicklog_enter' => xss_clean($fields['user_quicklog_enter']),
|
||||||
'language' => xss_clean($fields['language']),
|
'language' => xss_clean($fields['language']),
|
||||||
'winkey' => xss_clean($fields['user_winkey']),
|
'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'])."');");
|
$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 />
|
<hr />
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
<?php if (!isset($user_winkey_websocket)) {
|
<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) {
|
||||||
$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) {
|
|
||||||
echo 'checked';
|
echo 'checked';
|
||||||
} ?>>
|
} ?>>
|
||||||
<label class="form-check-label" for="user_winkey_websocket">Winkey Web Sockets</label>
|
<label class="form-check-label" for="user_winkey_websocket">Winkey Web Sockets</label>
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用