Finish switching to constants for ACL and settings.

This commit is contained in:
Buster Neece 2019-03-22 21:41:38 -05:00
parent 2a27fd160e
commit 40abdbcec4
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
10 changed files with 12 additions and 12 deletions

View File

@ -45,7 +45,7 @@ class IndexController
$view->sidebar = null;
// Synchronization statuses
if ($this->acl->userAllowed($user, 'administer all')) {
if ($this->acl->userAllowed($user, Acl::GLOBAL_ALL)) {
$view->sync_times = $this->sync->getSyncTimes();
}

View File

@ -117,7 +117,7 @@ class InternalController
/** @var Entity\User $user */
$user = $request->getAttribute(Request::ATTRIBUTE_USER);
if ($this->acl->userAllowed($user, 'view administration', $station->getId())) {
if ($this->acl->userAllowed($user, Acl::GLOBAL_VIEW, $station->getId())) {
return;
}

View File

@ -52,7 +52,7 @@ class AccountController
/** @var SettingsRepository $settings_repo */
$settings_repo = $this->em->getRepository(Settings::class);
if ($settings_repo->getSetting('setup_complete', 0) == 0) {
if ($settings_repo->getSetting(Settings::SETUP_COMPLETE, 0) == 0) {
$num_users = $this->em->createQuery('SELECT COUNT(u.id) FROM '.User::class.' u')->getSingleScalarResult();
if ($num_users == 0) {

View File

@ -79,7 +79,7 @@ class DashboardController
$stations = array_filter($stations, function($station) use ($user) {
/** @var Entity\Station $station */
return $station->isEnabled() &&
$this->acl->userAllowed($user, 'view station management', $station->getId());
$this->acl->userAllowed($user, Acl::STATION_VIEW, $station->getId());
});
if (empty($stations)) {
@ -137,7 +137,7 @@ class DashboardController
/** @var Entity\Repository\SettingsRepository $settings_repo */
$settings_repo = $this->em->getRepository(Entity\Settings::class);
$analytics_level = $settings_repo->getSetting('analytics', Entity\Analytics::LEVEL_ALL);
$analytics_level = $settings_repo->getSetting(Entity\Settings::LISTENER_ANALYTICS, Entity\Analytics::LEVEL_ALL);
if ($analytics_level === Entity\Analytics::LEVEL_NONE) {
$metrics = null;

View File

@ -28,7 +28,7 @@ class ListenersController
/** @var Entity\Repository\SettingsRepository $settings_repo */
$settings_repo = $this->em->getRepository(Entity\Settings::class);
$analytics_level = $settings_repo->getSetting('analytics', Entity\Analytics::LEVEL_ALL);
$analytics_level = $settings_repo->getSetting(Entity\Settings::LISTENER_ANALYTICS, Entity\Analytics::LEVEL_ALL);
if ($analytics_level !== Entity\Analytics::LEVEL_ALL) {
return $view->renderToResponse($response, 'stations/reports/restricted');

View File

@ -37,7 +37,7 @@ class OverviewController
/** @var Entity\Repository\SettingsRepository $settings_repo */
$settings_repo = $this->em->getRepository(Entity\Settings::class);
$analytics_level = $settings_repo->getSetting('analytics', Entity\Analytics::LEVEL_ALL);
$analytics_level = $settings_repo->getSetting(Entity\Settings::LISTENER_ANALYTICS, Entity\Analytics::LEVEL_ALL);
if ($analytics_level === Entity\Analytics::LEVEL_NONE) {
// The entirety of the dashboard can't be shown, so redirect user to the profile page.

View File

@ -67,7 +67,7 @@ class StreamersController
$settings_repo = $this->em->getRepository(Entity\Settings::class);
return $view->renderToResponse($response, 'stations/streamers/index', [
'server_url' => $settings_repo->getSetting('base_url', ''),
'server_url' => $settings_repo->getSetting(Entity\Settings::BASE_URL, ''),
'stream_port' => $backend->getStreamPort($station),
'streamers' => $station->getStreamers(),
'dj_mount_point' => $be_settings['dj_mount_point'] ?? '/',

View File

@ -59,7 +59,7 @@ class Manager implements EventSubscriberInterface
public function checkComposeVersion(GetNotifications $event)
{
// This notification is for full administrators only.
if (!$this->acl->userAllowed($event->getCurrentUser(), 'administer all')) {
if (!$this->acl->userAllowed($event->getCurrentUser(), Acl::GLOBAL_ALL)) {
return;
}
@ -81,7 +81,7 @@ class Manager implements EventSubscriberInterface
public function checkUpdates(GetNotifications $event)
{
// This notification is for full administrators only.
if (!$this->acl->userAllowed($event->getCurrentUser(), 'administer all')) {
if (!$this->acl->userAllowed($event->getCurrentUser(), Acl::GLOBAL_ALL)) {
return;
}

View File

@ -12,7 +12,7 @@ class HistoryCleanup extends AbstractTask
/** @var Entity\Repository\SettingsRepository $settings_repo */
$settings_repo = $this->em->getRepository(Entity\Settings::class);
$days_to_keep = (int)$settings_repo->getSetting('history_keep_days', Entity\SongHistory::DEFAULT_DAYS_TO_KEEP);
$days_to_keep = (int)$settings_repo->getSetting(Entity\Settings::HISTORY_KEEP_DAYS, Entity\SongHistory::DEFAULT_DAYS_TO_KEEP);
if ($days_to_keep !== 0) {
$threshold = (new Chronos())

View File

@ -65,7 +65,7 @@ echo $assets->js();
</a>
</li>
<li class="dropdown-divider">&nbsp;</li>
<?php if ($acl->userAllowed($user, 'view administration')): ?>
<?php if ($acl->userAllowed($user, \App\Acl::GLOBAL_VIEW)): ?>
<li>
<a class="dropdown-item" href="<?=$router->named('admin:index:index') ?>">
<i class="material-icons" aria-hidden="true">settings</i>