diff --git a/src/Providers/EventsServiceProvider.php b/src/Providers/EventsServiceProvider.php index b0aaab8..86021f8 100644 --- a/src/Providers/EventsServiceProvider.php +++ b/src/Providers/EventsServiceProvider.php @@ -45,8 +45,8 @@ public function boot(DispatcherContract $events) }); $events->listen('view.page.edit', function ($page) { - if (acl_check('widgets.index') and $page->hasLayout()) { - echo view('widgets::widgets.page.iframe')->with('page', $page)->render(); + if (acl_check('widgets::list') and $page->hasLayout()) { + echo view('widgets::widgets.page.iframe', compact('page'))->render(); } }); @@ -58,7 +58,7 @@ public function boot(DispatcherContract $events) echo view('widgets::widgets.partials.renderable', compact('widget', 'commentKeys', 'snippets'))->render(); } - if ($widget->isCacheable() and acl_check('widgets.cache')) { + if ($widget->isCacheable() and acl_check('widget_settings::cache')) { echo view('widgets::widgets.partials.cacheable', compact('widget'))->render(); } }); @@ -71,7 +71,7 @@ public function boot(DispatcherContract $events) echo view('widgets::widgets.partials.renderable_buttons', compact('widget', 'commentKeys', 'snippets', 'assetsPackages', 'widgetList'))->render(); } - if (acl_check('widgets.roles') and ! $widget->isHandler()) { + if (acl_check('widget_settings::roles') and ! $widget->isHandler()) { $usersRoles = Role::pluck('name', 'id')->all(); echo view('widgets::widgets.partials.permissions', compact('widget', 'usersRoles'))->render(); } diff --git a/src/Providers/ModuleServiceProvider.php b/src/Providers/ModuleServiceProvider.php index 00737b0..a1302ae 100644 --- a/src/Providers/ModuleServiceProvider.php +++ b/src/Providers/ModuleServiceProvider.php @@ -3,6 +3,7 @@ namespace KodiCMS\Widgets\Providers; use KodiCMS\Support\ServiceProvider; +use KodiCMS\Users\Model\Permission; use KodiCMS\Widgets\Contracts\WidgetManager; use KodiCMS\Widgets\Manager\WidgetManagerDatabase; @@ -15,7 +16,6 @@ public function boot() }); $this->app->alias('widget.manager', WidgetManager::class); - $this->app['view']->addNamespace('snippets', snippets_path()); } @@ -25,6 +25,27 @@ public function register() BladeServiceProvider::class, EventsServiceProvider::class, ]); + + Permission::register('widgets', 'widget', [ + 'list', + 'add', + 'delete', + 'edit', + ]); + + Permission::register('widgets', 'widget_settings', [ + 'cache', + 'roles', + 'location', + ]); + + Permission::register('widgets', 'snippet', [ + 'add', + 'edit', + 'list', + 'view', + 'delete' + ]); } public function contextBackend() @@ -35,7 +56,7 @@ public function contextBackend() 'id' => 'snippets', 'title' => 'widgets::snippet.title.list', 'url' => route('backend.snippet.list'), - 'permissions' => 'snippet.index', + 'permissions' => 'snippet::list', 'priority' => 200, 'icon' => 'cutlery', ], @@ -43,7 +64,7 @@ public function contextBackend() 'id' => 'widgets', 'title' => 'widgets::core.title.list', 'url' => route('backend.widget.list'), - 'permissions' => 'widgets.index', + 'permissions' => 'widget::list', 'priority' => 300, 'icon' => 'cubes', ], diff --git a/src/resources/lang/ru/permissions.php b/src/resources/lang/ru/permissions.php new file mode 100644 index 0000000..3f33d93 --- /dev/null +++ b/src/resources/lang/ru/permissions.php @@ -0,0 +1,28 @@ + [ + 'module' => 'Виджеты', + 'widget' => '', + 'snippet' => 'Сниппеты', + 'widget_settings' => 'Настройки виджета', + ], + 'widget' => [ + 'list' => 'Просмотр списка', + 'add' => 'Создание', + 'delete' => 'Удаление', + 'edit' => 'Редактирование', + ], + 'snippet' => [ + 'list' => 'Просмотр списка', + 'add' => 'Создание', + 'delete' => 'Удаление', + 'edit' => 'Редактирование', + 'view' => 'Просмотр кода', + ], + 'widget_settings' => [ + 'cache' => 'Кеш', + 'roles' => 'Роли', + 'location' => 'Размещение', + ], +]; \ No newline at end of file diff --git a/src/resources/views/snippet/form.blade.php b/src/resources/views/snippet/form.blade.php index 9fbff7a..0d3315d 100644 --- a/src/resources/views/snippet/form.blade.php +++ b/src/resources/views/snippet/form.blade.php @@ -11,7 +11,7 @@ -@if (!$snippet->isReadOnly() or $snippet->isNew()) +@if ((!$snippet->isReadOnly() or $snippet->isNew()) and acl_check('snippet::edit'))