cloudlog/application/models/Sstv_model.php
Peter Goodhall b368cba876 Enforce write permissions for QSO modifications
Replaced checks for QSO accessibility with stricter write permission checks across controllers and models. Added a new check_qso_is_writable method to Logbook_model to ensure only authorized users can modify or delete QSOs, including shared logbook scenarios. Updated QSO, Qsl_model, and Sstv_model to use the new permission logic for all write operations.
2025-12-23 11:06:19 +00:00

110 lines
3.1 KiB
PHP

<?php
class Sstv_model extends CI_Model
{
function saveSstvImages($qsoid, $filename)
{
// Clean ID
$clean_id = $this->security->xss_clean($qsoid);
// be sure that QSO belongs to user and user has write permission
$CI = &get_instance();
$CI->load->model('logbook_model');
if (!$CI->logbook_model->check_qso_is_writable($clean_id)) {
return;
}
$data = array(
'qsoid' => $clean_id,
'filename' => $filename
);
$this->db->insert('sstv_images', $data);
return $this->db->insert_id();
}
function getSSTVFilename($id)
{
// Clean ID
$clean_id = $this->security->xss_clean($id);
// be sure that QSO belongs to user
$CI = &get_instance();
$CI->load->model('logbook_model');
$this->db->select('qsoid');
$this->db->from('sstv_images');
$this->db->where('id', $clean_id);
$qsoid = $this->db->get()->row()->qsoid;
if (!$CI->logbook_model->check_qso_is_accessible($qsoid)) {
return;
}
$this->db->select('filename');
$this->db->from('sstv_images');
$this->db->where('id', $clean_id);
return $this->db->get();
}
function deleteSstv($id)
{
// Clean ID
$clean_id = $this->security->xss_clean($id);
// be sure that QSO belongs to user and user has write permission
$CI = &get_instance();
$CI->load->model('logbook_model');
$this->db->select('qsoid');
$this->db->from('sstv_images');
$this->db->where('id', $clean_id);
$qsoid = $this->db->get()->row()->qsoid;
if (!$CI->logbook_model->check_qso_is_writable($qsoid)) {
return;
}
// Delete Mode
$this->db->delete('sstv_images', array('id' => $clean_id));
}
function getSstvForQsoId($id)
{
// Clean ID
$clean_id = $this->security->xss_clean($id);
// be sure that QSO belongs to user
$CI = &get_instance();
$CI->load->model('logbook_model');
if (!$CI->logbook_model->check_qso_is_accessible($clean_id)) {
return;
}
$this->db->select('*');
$this->db->from('sstv_images');
$this->db->where('qsoid', $clean_id);
return $this->db->get()->result();
}
function getQsoWithSstvImageList()
{
$CI = &get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (is_array($logbooks_locations_array) && !empty($logbooks_locations_array)) {
$this->db->select('*');
$this->db->from($this->config->item('table_name'));
$this->db->join('sstv_images', 'sstv_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key');
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by("id", "desc");
return $this->db->get();
} else {
return false;
}
}
}