fix: getting user power

This commit is contained in:
grandeljay 2023-08-30 15:00:29 +02:00
parent cf253bf8c0
commit 1fc8f31d38
4 changed files with 10 additions and 6 deletions

View file

@ -38,7 +38,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
$preview_create = true;
}
if ($preview_create && $user->power >= $page->power) {
if ($preview_create && $user->getPower() >= $page->power) {
file_put_contents($preview_filepath, $preview);
}
}

View file

@ -169,7 +169,7 @@ class Page
/**
* Power
*/
if (isset($user->power) && $user->power < $this->power && 0 !== $this->power) {
if ($user->getPower() < $this->power && 0 !== $this->power) {
redirect(Page::PAGE_POWER . '&required=' . $this->power);
}
@ -184,7 +184,7 @@ class Page
);
if ($options && $options->getOption('updateAvailable') && !in_array($this->name, $ignoreUpdateRedirect)) {
if (100 === $user->power) {
if (100 === $user->getPower()) {
redirect(Page::PAGE_UPDATE);
} else {
redirect(Page::PAGE_MAINTENANCE);
@ -485,7 +485,7 @@ class Page
'url' => Page::PAGE_PROFILE,
'icon' => 'user circle alternate',
);
if (100 === $user->power) {
if (100 === $user->getPower()) {
$pages[$account]['items'][] = array(
'text' => __('Login as'),
'url' => Page::PAGE_LOGIN_AS,
@ -522,7 +522,7 @@ class Page
);
}
if (isset($user->power) && 100 === $user->power) {
if (100 === $user->getPower()) {
$pages[$system]['items'][] = array(
'text' => __('Settings'),
'url' => Page::PAGE_SETTINGS,

View file

@ -464,4 +464,8 @@ class User
public function getPassword(): string {
return $this->password;
}
public function getPower(): int {
return $this->power;
}
}

View file

@ -22,7 +22,7 @@ $user = User::getCurrent();
<div class="ui segment">
<h2 class="ui header"><?= __('Restricted access') ?></h2>
<p><?= sprintf(__('You do not have enough power to view this page. You need %s to see this page, but only have %s.'), '<strong>' . $_GET['required'] . '</strong>', '<strong>' . $user->power . '</strong>') ?></p>
<p><?= sprintf(__('You do not have enough power to view this page. You need %s to see this page, but only have %s.'), '<strong>' . $_GET['required'] . '</strong>', '<strong>' . $user->getPower() . '</strong>') ?></p>
</div>
</div>
</main>