mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
Support manager scopes in Template v2 "can" directive
This commit is contained in:
parent
8d8380a366
commit
a2e5434aec
1 changed files with 8 additions and 4 deletions
|
|
@ -899,19 +899,23 @@ class Template
|
||||||
protected function _v2_checkCapability(int $check_type, $capability): bool
|
protected function _v2_checkCapability(int $check_type, $capability): bool
|
||||||
{
|
{
|
||||||
$grant = \Context::get('grant');
|
$grant = \Context::get('grant');
|
||||||
if ($check_type === 1)
|
if (!($grant instanceof \Rhymix\Modules\Module\Models\Permission))
|
||||||
{
|
{
|
||||||
return isset($grant->$capability) ? boolval($grant->$capability) : false;
|
return false;
|
||||||
|
}
|
||||||
|
elseif ($check_type === 1)
|
||||||
|
{
|
||||||
|
return $grant->can($capability);
|
||||||
}
|
}
|
||||||
elseif ($check_type === 2)
|
elseif ($check_type === 2)
|
||||||
{
|
{
|
||||||
return isset($grant->$capability) ? !boolval($grant->$capability) : true;
|
return !$grant->can($capability);
|
||||||
}
|
}
|
||||||
elseif (is_array($capability))
|
elseif (is_array($capability))
|
||||||
{
|
{
|
||||||
foreach ($capability as $cap)
|
foreach ($capability as $cap)
|
||||||
{
|
{
|
||||||
if (isset($grant->$cap) && $grant->$cap)
|
if ($grant->can($cap))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue