2017-07-11 19:17:44 +10:00
|
|
|
<?php namespace Backend\Controllers;
|
|
|
|
|
2017-07-13 19:29:50 +10:00
|
|
|
use View;
|
|
|
|
use Response;
|
2017-07-11 19:17:44 +10:00
|
|
|
use BackendMenu;
|
|
|
|
use Backend\Classes\Controller;
|
|
|
|
use System\Classes\SettingsManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Backend user groups controller
|
|
|
|
*
|
|
|
|
* @package october\backend
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class UserRoles extends Controller
|
|
|
|
{
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array Extensions implemented by this controller.
|
|
|
|
*/
|
2017-07-11 19:17:44 +10:00
|
|
|
public $implement = [
|
2017-07-27 17:35:14 +10:00
|
|
|
\Backend\Behaviors\FormController::class,
|
|
|
|
\Backend\Behaviors\ListController::class
|
2017-07-11 19:17:44 +10:00
|
|
|
];
|
|
|
|
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array `FormController` configuration.
|
|
|
|
*/
|
2017-07-11 19:17:44 +10:00
|
|
|
public $formConfig = 'config_form.yaml';
|
2017-07-27 17:35:14 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array `ListController` configuration.
|
|
|
|
*/
|
2017-07-11 19:17:44 +10:00
|
|
|
public $listConfig = 'config_list.yaml';
|
|
|
|
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* @var array Permissions required to view this page.
|
|
|
|
*/
|
2017-07-11 19:17:44 +10:00
|
|
|
public $requiredPermissions = ['backend.manage_users'];
|
|
|
|
|
2017-07-27 17:35:14 +10:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
2017-07-11 19:17:44 +10:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
BackendMenu::setContext('October.System', 'system', 'users');
|
|
|
|
SettingsManager::setContext('October.System', 'administrators');
|
2017-07-13 19:29:50 +10:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Only super users can access
|
|
|
|
*/
|
2019-07-18 22:50:37 +08:00
|
|
|
$this->bindEvent('page.beforeDisplay', function () {
|
2017-07-13 19:29:50 +10:00
|
|
|
if (!$this->user->isSuperUser()) {
|
|
|
|
return Response::make(View::make('backend::access_denied'), 403);
|
|
|
|
}
|
|
|
|
});
|
2017-07-11 19:17:44 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add available permission fields to the Role form.
|
|
|
|
*/
|
|
|
|
public function formExtendFields($form)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Add permissions tab
|
|
|
|
*/
|
|
|
|
$form->addTabFields($this->generatePermissionsField());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the permissions editor widget to the form.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function generatePermissionsField()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'permissions' => [
|
|
|
|
'tab' => 'backend::lang.user.permissions',
|
|
|
|
'type' => 'Backend\FormWidgets\PermissionEditor',
|
|
|
|
'mode' => 'checkbox'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|