Files
wavelog/application/models/Usermodes.php
2025-06-23 10:00:07 +00:00

58 lines
1.4 KiB
PHP

<?php
class Usermodes extends CI_Model {
function all() {
$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 ?? '[]');
$this->db->where('active', 1); // Show only those which are not globally deactivated
$this->db->order_by('mode', 'ASC');
$this->db->order_by('submode', 'ASC');
$modes=$this->db->get('adif_modes');
$retmodes=[];
foreach ($modes->result() as $row) {
if (count($usermodes)>0) {
if (in_array($row->mode.'/'.($row_submode ?? ''), $usermodes)) {
$row->active=1;
} else {
$row->active=0;
}
}
$retmodes[]=$row;
}
return $retmodes;
}
function mode($id) {
// Clean ID
$clean_id = $this->security->xss_clean($id);
$this->db->where('id', $clean_id);
return $this->db->get('adif_modes');
}
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;
}
function deactivate($id) {
// Clean ID
$clean_id = $this->security->xss_clean($id);
$data = array(
'active' => '0',
);
$this->db->where('id', $clean_id);
$this->db->update('adif_modes', $data);
return true;
}
}
?>