50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Beheer;
|
|
|
|
use App\Controllers\BaseController;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
|
|
class AuthorisationController extends BaseController
|
|
{
|
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
|
|
if (!defined('AUTHENTICATED') || AUTHENTICATED === false) {
|
|
die('NO ACCESS');
|
|
}
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// Default action
|
|
}
|
|
|
|
public function getRoleAuthorisations(): ResponseInterface
|
|
{
|
|
$roleAuthorisations = \Role::getPagesAccessByRole();
|
|
|
|
return $this->json($roleAuthorisations);
|
|
}
|
|
|
|
public function toggleAuhorisation(): ResponseInterface
|
|
{
|
|
$pageID = $this->cleanInput('pageID');
|
|
$roleLevel = $this->cleanInput('roleLevel');
|
|
$access = $this->cleanInput('access');
|
|
|
|
$page = \Page::find($pageID);
|
|
|
|
if ($access == 'F') {
|
|
$roleLevel = -$roleLevel;
|
|
}
|
|
|
|
$page->pagelevel = $page->pagelevel + $roleLevel;
|
|
|
|
$page->save();
|
|
|
|
return $this->json(['success' => true]);
|
|
}
|
|
}
|