From d2653ecd1761d0e9781fa2dfdd46d76c5485c0c3 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Mon, 22 Apr 2024 14:44:14 +1000 Subject: [PATCH] Fix discoveries type. --- app/Models/DiscoveriesModel.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Models/DiscoveriesModel.php b/app/Models/DiscoveriesModel.php index bf9c43c54..19efdfd27 100644 --- a/app/Models/DiscoveriesModel.php +++ b/app/Models/DiscoveriesModel.php @@ -40,6 +40,10 @@ public function collection(object $resp): array $this->builder->{$filter->function}($filter->name, $filter->value); } } + $instance = & get_instance(); + if ($instance->config->product !== 'enterprise') { + $this->builder->where('discoveries.type !=', 'seed'); + } $this->builder->orderBy($resp->meta->sort); $this->builder->limit($resp->meta->limit, $resp->meta->offset); $query = $this->builder->get(); @@ -61,7 +65,6 @@ public function create($data = null): ?int { $instance = & get_instance(); $instance->networksModel = new \App\Models\NetworksModel(); - if (empty($data)) { return null; } @@ -75,6 +78,9 @@ public function create($data = null): ?int \Config\Services::session()->setFlashdata('error', 'Invalid type provided to Discoveries::Create.'); return null; } + if ($instance->config->product !== 'enterprise' and $data->type === 'seed') { + return null; + } if (empty($instance->config->discovery_default_scan_option)) { $instance->config->discovery_default_scan_option = 1; } @@ -775,6 +781,10 @@ public function listUser($where = array(), $orgs = array()): array $this->builder->join('orgs', 'discoveries.org_id = orgs.id', 'left'); $this->builder->whereIn('orgs.id', $orgs); $this->builder->where($where); + $instance = & get_instance(); + if ($instance->config->product !== 'enterprise') { + $this->builder->where('discoveries.type !=', 'seed'); + } $query = $this->builder->get(); if ($this->sqlError($this->db->error())) { return array();