diff --git a/application/migrations/249_move_oqrs_global_to_user.php b/application/migrations/249_move_oqrs_global_to_user.php deleted file mode 100644 index 7776c6e7b..000000000 --- a/application/migrations/249_move_oqrs_global_to_user.php +++ /dev/null @@ -1,49 +0,0 @@ -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');"); - } -} diff --git a/application/models/Oqrs_model.php b/application/models/Oqrs_model.php index 0077f2c48..f101bddac 100644 --- a/application/models/Oqrs_model.php +++ b/application/models/Oqrs_model.php @@ -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