Files

14 lines
419 B
PHP
Raw Permalink Normal View History

<?php
if (Auth::user()->hasGlobalRead()) {
2020-09-21 15:59:34 +02:00
$data['count'] = ['query' => 'SELECT COUNT(`toner_id`) FROM toner'];
} else {
2019-12-30 12:11:26 +01:00
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
2020-09-21 15:59:34 +02:00
$perms_sql = '`toner`.`device_id` IN ' . dbGenPlaceholders(count($device_ids));
2019-12-30 12:11:26 +01:00
2020-09-21 15:40:17 +02:00
$data['count'] = [
2019-12-30 12:11:26 +01:00
'query' => "SELECT COUNT(`toner_id`) FROM toner WHERE $perms_sql",
2020-09-21 15:40:17 +02:00
'params' => $device_ids,
];
}