Skip to content

Commit

Permalink
Fixes for Integrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Apr 17, 2024
1 parent 5d2e0df commit fccc272
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/Controllers/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function start()
$this->devicesModel = new \App\Models\DevicesModel();
$this->discoveriesModel = new \App\Models\DiscoveriesModel();
$this->discoveryLogModel = new \App\Models\DiscoveryLogModel();
#$this->integrationsModel = new \App\Models\IntegrationsModel();
$this->integrationsModel = new \App\Models\IntegrationsModel();
$this->locationsModel = new \App\Models\LocationsModel();
$this->networksModel = new \App\Models\NetworksModel();
$this->orgsModel = new \App\Models\OrgsModel();
Expand All @@ -54,7 +54,7 @@ public function start()
helper('components');
helper('device');
helper('discoveries');
#helper('integrations_nmis');
helper('integrations_nmis');
helper('mac_model');
helper('network');
helper('security');
Expand Down
2 changes: 1 addition & 1 deletion app/Helpers/integrations_nmis_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function generate_token()
$message = 'One of the auth methods must be set to token for NMIS integrations to work without a username and password.';
log_message('error', $message);
}
$files = array(APPPATH . '/../other/generate_auth_token.pl', $bin.'generate_auth_token.exe', $bin.'generate_auth_token.pl');
$files = array(ROOTPATH . 'other/generate_auth_token.pl', $bin.'generate_auth_token.exe', $bin.'generate_auth_token.pl');
foreach ($files as $file) {
if (file_exists($file)) {
log_message('debug', 'Using ' . $file . ' to generate token.');
Expand Down
2 changes: 1 addition & 1 deletion app/Models/IntegrationsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ public function getLocalDevices($integration)
}
// Select by Query
if ($integration->attributes->select_internal_type === 'query') {
$devices = $queriesModel->execute($integration->attributes->select_internal_attribute, $instance->user);
$devices = $queriesModel->execute(intval($integration->attributes->select_internal_attribute), $instance->user);
$dev_ids = array();
foreach ($devices as $device) {
if (!empty($device->attributes->{'devices.id'})) {
Expand Down
5 changes: 3 additions & 2 deletions app/Models/QueriesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ public function execute(int $id = 0, object $user = null): array
if (!empty($instance->config->feature_queries_advanced) and $instance->config->feature_queries_advanced === 'y' and !empty($query->advanced) and $query->advanced === 'y') {
$sql = str_ireplace('@orgs', "({$user->org_list})", $sql);
}

$sql .= ' LIMIT ' . $instance->resp->meta->limit;
if (!empty($instance->resp->meta->limit) and is_int($instance->resp->meta->limit)) {
$sql .= ' LIMIT ' . $instance->resp->meta->limit;
}
$query = $this->db->query($sql);
// log_message('debug', str_replace("\n", " ", (string)$this->db->getLastQuery()));
if ($this->sqlError($this->db->error())) {
Expand Down

0 comments on commit fccc272

Please sign in to comment.