- Controller system/Filters now extends CI_Controller

- Added private method _isAllowed to controller system/Filters
- The method _isAllowed is called in the controller constructor and checks if the caller has the permission to read data with this instance of the FilterWidget
- The permission is given as parameter when calling the FilterWidget, the parameter is called requiredPermissions
- Updated the view system/infocenter/infocenterData to give the infocenter permission to the FilterWidget
- Changed the logic into the FilterWidget to manage the requiredPermissions parameter
This commit is contained in:
Paolo
2018-03-29 16:53:38 +02:00
parent dda27c7d6e
commit 49e24b0431
3 changed files with 54 additions and 5 deletions
+35 -1
View File
@@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class Filters extends FHC_Controller
class Filters extends CI_Controller
{
const SESSION_NAME = 'FILTER';
@@ -25,9 +25,13 @@ class Filters extends FHC_Controller
// Load session library
$this->load->library('session');
// Load permission library
$this->load->library('PermissionLib');
$this->load->model('system/Filters_model', 'FiltersModel');
$this->load->model('person/Benutzer_model', 'BenutzerModel');
$this->_isAllowed();
}
/**
@@ -469,4 +473,34 @@ class Filters extends FHC_Controller
$this->output->set_content_type('application/json')->set_output(json_encode($json));
}
/**
* Cheks
*/
private function _isAllowed()
{
if (isset($_SESSION[self::SESSION_NAME]['requiredPermissions']))
{
$requiredPermissions = array(
'filters' => $_SESSION[self::SESSION_NAME]['requiredPermissions'].':rw'
);
if (!$this->permissionlib->isEntitled($requiredPermissions, 'filters'))
{
header('Content-Type: application/json');
echo json_encode('You are not allowed to access to this content');
exit(1);
}
}
else
{
header('Content-Type: application/json');
echo json_encode('You are not allowed to access to this content');
exit(1);
}
}
}