diff --git a/application/models/Usermodes.php b/application/models/Usermodes.php index 90ea491f0..a5fa2044c 100644 --- a/application/models/Usermodes.php +++ b/application/models/Usermodes.php @@ -57,12 +57,10 @@ class Usermodes extends CI_Model { function activate($id) { // Clean ID $clean_id = $this->security->xss_clean($id); - $data = array( - 'active' => '1', - ); - $this->db->where('id', $clean_id); - $this->db->update('adif_modes', $data); - return true; + $options_object = $this->user_options_model->get_options('usermodes', array('option_name' => 'enabled_usermodes', 'option_key' => 'json_modes'))->result(); + $usermodes = json_decode($options_object[0]->option_value ?? '[]'); + $mode2act=$this->mode($id)->result()->mode.'/'.($this->mode($id)->result()->submode ?? ''); + return $mode2act; } function deactivate($id) { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index c24b27b30..70179fc3e 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2348,6 +2348,10 @@ $('#sats').change(function(){ + uri->segment(1) == "usermode") { ?> + + + uri->segment(1) == "mode") { ?> diff --git a/application/views/usermode/index.php b/application/views/usermode/index.php index 521dc89d6..78b6abd34 100644 --- a/application/views/usermode/index.php +++ b/application/views/usermode/index.php @@ -62,8 +62,6 @@ - - <--- diff --git a/assets/js/sections/usermode.js b/assets/js/sections/usermode.js new file mode 100644 index 000000000..8e8ac99d4 --- /dev/null +++ b/assets/js/sections/usermode.js @@ -0,0 +1,140 @@ +$('.modetable').DataTable({ + "pageLength": 25, + responsive: false, + ordering: false, + "scrollY": "500px", + "scrollCollapse": true, + "paging": false, + "scrollX": true, + "language": { + url: getDataTablesLanguageUrl(), + }, + initComplete: function () { + this.api() + .columns('.select-filter') + .every(function () { + var column = this; + var select = $('') + .appendTo($(column.footer()).empty()) + .on('change', function () { + var val = $.fn.dataTable.util.escapeRegex($(this).val()); + + column.search(val ? '^' + val + '$' : '', true, false).draw(); + }); + + column + .data() + .unique() + .sort() + .each(function (d, j) { + select.append(''); + }); + }); + }, +}); + + +function deactivateMode(modeid) { + $.ajax({ + url: base_url + 'index.php/mode/deactivate', + type: 'post', + data: { 'id': modeid }, + success: function (html) { + $(".mode_" + modeid).text(lang_mode_not_active); + $('.btn_' + modeid).html(lang_activate_mode); + $('.btn_' + modeid).removeClass('btn-secondary'); + $('.btn_' + modeid).addClass('btn-primary'); + $('.btn_' + modeid).attr('onclick', 'activateMode(' + modeid + ')') + } + }); +} + +function activateMode(modeid) { + $.ajax({ + url: base_url + 'index.php/mode/activate', + type: 'post', + data: { 'id': modeid }, + success: function (html) { + $('.mode_' + modeid).text(lang_mode_active); + $('.btn_' + modeid).html(lang_deactivate_mode); + $('.btn_' + modeid).removeClass('btn-primary'); + $('.btn_' + modeid).addClass('btn-secondary'); + $('.btn_' + modeid).attr('onclick', 'deactivateMode(' + modeid + ')') + } + }); +} + +function deleteMode(id, mode) { + BootstrapDialog.confirm({ + title: lang_general_word_danger, + message: lang_mode_deletion_confirm + ' ' + mode, + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + btnCancelLabel: lang_general_word_cancel, + btnOKLabel: lang_general_word_ok, + callback: function (result) { + if (result) { + $.ajax({ + url: base_url + 'index.php/mode/delete', + type: 'post', + data: { + 'id': id + }, + success: function (data) { + $(".mode_" + id).parent("tr:first").remove(); // removes mode from table + } + }); + } + } + }); +} + +function activateAllModes() { + BootstrapDialog.confirm({ + title: lang_general_word_danger, + message: lang_active_all_confirm, + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + btnCancelLabel: lang_general_word_cancel, + btnOKLabel: lang_general_word_ok, + callback: function (result) { + if (result) { + $.ajax({ + url: base_url + 'index.php/mode/activateall', + type: 'post', + success: function (data) { + location.reload(); + } + }); + } + } + }); +} + +function deactivateAllModes() { + BootstrapDialog.confirm({ + title: lang_general_word_danger, + message: lang_deactive_all_confirm, + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + btnCancelLabel: lang_general_word_cancel, + btnOKLabel: lang_general_word_ok, + callback: function (result) { + if (result) { + $.ajax({ + url: base_url + 'index.php/mode/deactivateall', + type: 'post', + success: function (data) { + location.reload(); + } + }); + } + } + }); +}