mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Device group based access (#10568)
* Device group based access * Use Permissions class to resolve permissions Also give port access based on device access * Convert more pages to use Permissions class * shorten config setting name use Eloquent relationships in several places alphabetize config_definitions.json * Change Models and Permissions * Clean up ajax_search LIMIT sql * Convert more pages to use Permissions class Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$data['count'] = array('query' => "SELECT COUNT(`toner_id`) FROM toner");
|
||||
} else {
|
||||
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
|
||||
$perms_sql = "`toner`.`device_id` IN " .dbGenPlaceholders(count($device_ids));
|
||||
|
||||
$data['count'] = array(
|
||||
'query' => "SELECT COUNT(`toner_id`) FROM toner AS T, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND T.`device_id` = D.`device_id`",
|
||||
'params' => array(Auth::id()),
|
||||
'query' => "SELECT COUNT(`toner_id`) FROM toner WHERE $perms_sql",
|
||||
'params' => $device_ids
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user