28 lines
719 B
PHP
28 lines
719 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
function accountUrl(): string
|
||
|
|
{
|
||
|
|
$user = $_SESSION['user'] ?? [];
|
||
|
|
$uuid = (string) ($user['uuid'] ?? '');
|
||
|
|
return $uuid !== '' ? lurl('profile') : lurl('login');
|
||
|
|
}
|
||
|
|
|
||
|
|
function can(string $permissionKey): bool
|
||
|
|
{
|
||
|
|
$userId = (int) ($_SESSION['user']['id'] ?? 0);
|
||
|
|
if ($userId <= 0) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if (!class_exists('MintyPHP\\Service\\PermissionService')) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
$keys = \MintyPHP\Service\PermissionService::getCachedPermissions($userId);
|
||
|
|
if (!$keys) {
|
||
|
|
$keys = \MintyPHP\Service\PermissionService::getUserPermissions($userId);
|
||
|
|
if (!$keys) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return in_array($permissionKey, $keys, true);
|
||
|
|
}
|