Skip to content

Commit

Permalink
fixed URLs, added user permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed Mar 23, 2016
1 parent c5317f5 commit 8f72e18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public function init()
if (\Yii::$app->hasModule('settings')) {
$routes = explode("\n", \Yii::$app->settings->get('pages.availableRoutes'));
foreach ($routes AS $route) {
$this->availableRoutes[$route] = $route;
$this->availableRoutes[trim($route)] = trim($route);
}

$views = explode("\n", \Yii::$app->settings->get('pages.availableViews'));
foreach ($views AS $view) {
$this->availableViews[$view] = $view;
$this->availableViews[trim($view)] = trim($view);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion models/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function createUrl($additionalParams = [])
*
* @return array
*/
public static function getMenuItems($rootName)
public static function getMenuItems($rootName, $checkUserPermissions = false)
{
// Get root node by name
$rootCondition['name_id'] = $rootName;
Expand Down Expand Up @@ -320,6 +320,9 @@ public static function getMenuItems($rootName)
'label' => ($page->icon) ? '<i class="'.$page->icon.'"></i> '.$page->name : $page->name,
'url' => $page->createUrl(),
'linkOptions' => $pageOptions,
'visible' => ($checkUserPermissions) ?
Yii::$app->user->can(substr(str_replace('/', '_', $page->route), 1), ['route' => true]) :
true,
];
$item = $itemTemplate;

Expand Down

0 comments on commit 8f72e18

Please sign in to comment.