mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
api: Add ability to return all device info for get_devices_by_group() (#5971)
* Changed GetDevicesFromGroup to output all columns if is defined in url
This commit is contained in:
@@ -188,11 +188,16 @@ function QueryDevicesFromGroup($group_id)
|
||||
* Get an array of all the device ids belonging to this group_id
|
||||
* @param $group_id
|
||||
* @param bool $nested Return an array of arrays containing 'device_id'. (for API compatibility)
|
||||
* @param bool $full Return all fields from devices_id
|
||||
* @return array
|
||||
*/
|
||||
function GetDevicesFromGroup($group_id, $nested = false)
|
||||
function GetDevicesFromGroup($group_id, $nested = false, $full = false)
|
||||
{
|
||||
$query = 'SELECT `device_id` FROM `device_group_device` WHERE `device_group_id`=?';
|
||||
if ($full) {
|
||||
$query = 'SELECT `device_groups`.`name`, `devices`.* FROM `device_groups` INNER JOIN `device_group_device` ON `device_groups`.`id` = `device_group_device`.`device_group_id` INNER JOIN `devices` ON `device_group_device`.`device_id` = `devices`.`device_id` WHERE `device_groups`.`id`=?';
|
||||
} else {
|
||||
$query = 'SELECT `device_id` FROM `device_group_device` WHERE `device_group_id`=?';
|
||||
}
|
||||
if ($nested) {
|
||||
return dbFetchRows($query, array($group_id));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user