Only delete users requests

This commit is contained in:
Andreas Kristiansen
2025-07-18 09:50:41 +02:00
parent e468d8f954
commit bc2e8ee567
2 changed files with 10 additions and 55 deletions

View File

@@ -1,49 +0,0 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
Move the global OQRS options to user options
*/
class Migration_move_oqrs_global_to_user extends CI_Migration {
public function up()
{
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value)
select users.user_id, 'oqrs', 'global_oqrs_text', 'text', options.option_value
from users
join options on options.option_name = 'global_oqrs_text'
where not exists (select 1 from user_options where user_id = users.user_id and option_key = 'global_oqrs_text');");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value)
select users.user_id, 'oqrs', 'oqrs_grouped_search', 'boolean', options.option_value
from users
join options on options.option_name = 'groupedSearch'
where not exists (select 1 from user_options where user_id = users.user_id and option_key = 'groupedSearch');");
$this->db->query("insert into user_options (user_id, option_type, option_name, option_key, option_value)
select users.user_id, 'oqrs', 'oqrs_grouped_search_show_station_name', 'boolean', options.option_value
from users
join options on options.option_name = 'groupedSearchShowStationName'
where not exists (select 1 from user_options where user_id = users.user_id and option_key = 'groupedSearchShowStationName');");
$this->db->query("delete from options where option_name = 'global_oqrs_text';");
$this->db->query("delete from options where option_name = 'groupedSearch';");
$this->db->query("delete from options where option_name = 'groupedSearchShowStationName';");
}
public function down()
{
// $this->db->query("insert into options (option_name, option_value)
// select option_name, option_value from user_options where option_type = 'oqrs' and option_name = 'global_oqrs_text';");
// $this->db->query("insert into options (option_name, option_value)
// select 'groupedSearch', option_value from user_options where option_type = 'oqrs' and option_name = 'oqrs_grouped_search';");
// $this->db->query("insert into options (option_name, option_value)
// select 'groupedSearchShowStationName', option_value from user_options where option_type = 'oqrs' and option_name = 'oqrs_grouped_search_show_station_name';");
$this->db->query("delete from user_options where option_type = 'oqrs' and option_name in ('global_oqrs_text', 'oqrs_grouped_search', 'oqrs_grouped_search_show_station_name');");
}
}

View File

@@ -192,16 +192,20 @@ class Oqrs_model extends CI_Model {
}
function delete_oqrs_line($id) {
$binding = [];
$sql = 'delete from oqrs where id = ?';
$binding[] = $id;
$binding = [$id, $this->session->userdata('user_id')];
$query = $this->db->query($sql, $binding);
$sql = '
DELETE oqrs
FROM oqrs
JOIN station_profile ON station_profile.station_id = oqrs.station_id
WHERE oqrs.id = ? AND station_profile.user_id = ?
';
return true;
$query = $this->db->query($sql, $binding);
return true;
}
// Status:
// 0 = open request
// 1 = not in log request