Skip to content

Commit

Permalink
Merge pull request #2116 from LuckyCyborg/4.0
Browse files Browse the repository at this point in the history
Improve the Platform module
  • Loading branch information
LuckyCyborg authored Sep 21, 2018
2 parents 2869678 + a984416 commit f05e8d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Platform/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Define The Application Version
//--------------------------------------------------------------------------

define('VERSION', '4.0.93');
define('VERSION', '4.0.94');

//--------------------------------------------------------------------------
// Set PHP Error Reporting Options
Expand Down
27 changes: 22 additions & 5 deletions modules/Platform/Support/EventedMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Nova\Support\Arr;
use Nova\Support\Str;

use LogicException;


class EventedMenu
{
Expand Down Expand Up @@ -124,15 +126,30 @@ protected function userIsAllowed(array $item, UserInterface $user, GateInterface
}

// The abilities entry was specified.
else if (is_string($abilities = $item['can'])) {
else if (! is_array($abilities = $item['can'])) {
$abilities = explode('|', $abilities);
}

foreach ($abilities as $ability) {
list ($ability, $parameters) = array_pad(explode(':', $ability, 2), 2, array());
foreach ($abilities as $value) {
if (! is_array($value)) {
list ($ability, $parameters) = array_pad(explode(':', $value, 2), 2, array());

if (is_string($parameters)) {
$parameters = explode(',', $parameters);
}

// The information is given as an array.
} else if (! is_null($ability = Arr::get($value, 'ability'))) {
$parameters = Arr::get($value, 'arguments', array());

if (! is_array($parameters)) {
$parameters = array($parameters);
}
}

if (is_string($parameters)) {
$parameters = explode(',', $parameters);
// Invalid ability format specified.
else {
throw new LogicException('Invalid user ability.');
}

if (call_user_func(array($gate, 'allows'), $ability, $parameters)) {
Expand Down

0 comments on commit f05e8d8

Please sign in to comment.