Do stuff only if config is set (+re-add line at dashboard)

This commit is contained in:
int2001
2025-04-16 19:10:22 +00:00
parent 32f6ffa23e
commit 8ef85db129
3 changed files with 26 additions and 17 deletions

View File

@@ -67,11 +67,13 @@
$data['mode_rx'] = NULL;
}
$this->load->library('Mh');
$eventdata=$data;
$h_user=$this->User_model->get_by_id($user_id);
$eventdata['user_name']=$h_user->row()->user_name;
$eventdata['user_id']=$h_user->row()->user_id ?? '';
if (($this->config->item('mqtt_server') ?? '') != '') {
$h_user=$this->User_model->get_by_id($user_id);
$this->load->library('Mh');
$eventdata=$data;
$eventdata['user_name']=$h_user->row()->user_name;
$eventdata['user_id']=$h_user->row()->user_id ?? '';
}
if ($query->num_rows() > 0) {
// Update the record
foreach ($query->result() as $row) {
@@ -79,7 +81,9 @@
$this->db->where('id', $radio_id);
$this->db->where('user_id', $user_id);
$this->db->update('cat', $data);
$this->mh->wl_event('cat/'.$user_id, json_encode(array_merge($data,$eventdata)));
if (($this->ci->config->item('mqtt_server') ?? '') != '') {
$this->mh->wl_event('cat/'.$user_id, json_encode(array_merge($data,$eventdata)));
}
}
} else {
// Add a new record
@@ -87,7 +91,9 @@
$data['user_id'] = $user_id;
$data['operator'] = $operator;
$this->db->insert('cat', $data);
$this->mh->wl_event('cat/'.$user_id, json_encode(array_merge($data,$eventdata)));
if (($this->ci->config->item('mqtt_server') ?? '') != '') {
$this->mh->wl_event('cat/'.$user_id, json_encode(array_merge($data,$eventdata)));
}
}
unset($eventdata);
unset($h_user);