Skip to content

Commit

Permalink
Improve login in GroupsModel::execute for times we don't have a $resp…
Browse files Browse the repository at this point in the history
… object (think integrations running from the queue).
  • Loading branch information
mark-unwin committed Mar 6, 2024
1 parent 899e8b4 commit f9969d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/Models/GroupsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ public function execute(int $id = 0, object $user = null): array
$properties = implode(', ', $properties_new_array);
$sql = str_ireplace('SELECT DISTINCT(devices.id) FROM devices', "SELECT {$properties} FROM devices", $sql);
$filter = "devices.org_id IN ({$user->org_list})";
if (!empty($instance->resp->meta->requestor)) {
$filter = "devices.org_id IN ({$user->org_list}) AND devices.oae_manage = 'y'";
}
$sql = str_ireplace('WHERE @filter', "WHERE {$filter}", $sql);
$sql .= ' ' . $instance->resp->meta->groupby . ' ' .
$instance->resp->meta->sort;
if (!empty($instance->resp->meta->groupby)) {
$sql = $sql . ' ' . $instance->resp->meta->groupby;
}
if (!empty($instance->resp->meta->sort)) {
$sql = $sql . ' ' . $instance->resp->meta->sort;
}
if (!empty($instance->resp->meta->limit)) {
$sql .= ' LIMIT ' . $instance->resp->meta->limit;
$sql = $sql . ' LIMIT ' . $instance->resp->meta->limit;
}

$query = $this->db->query($sql);
Expand Down

0 comments on commit f9969d2

Please sign in to comment.