mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
- 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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,12 +137,13 @@
|
||||
)
|
||||
ORDER BY "LastAction" ASC
|
||||
',
|
||||
'hideHeader' => false,
|
||||
'hideSave' => false,
|
||||
'requiredPermissions' => 'infocenter',
|
||||
'checkboxes' => 'PersonId',
|
||||
'additionalColumns' => array('Details'),
|
||||
'columnsAliases' => array('PersonID','Vorname','Nachname','GebDatum','Letzte Aktion','Letzter Bearbeiter',
|
||||
'StSem','GesendetAm','NumAbgeschickt','Studiengänge','Sperrdatum','GesperrtVon'),
|
||||
'columnsAliases' => array(
|
||||
'PersonID','Vorname','Nachname','GebDatum','Letzte Aktion','Letzter Bearbeiter',
|
||||
'StSem','GesendetAm','NumAbgeschickt','Studiengänge','Sperrdatum','GesperrtVon'
|
||||
),
|
||||
'formatRaw' => function($datasetRaw) {
|
||||
|
||||
$datasetRaw->{'Details'} = sprintf(
|
||||
|
||||
@@ -18,6 +18,7 @@ class FilterWidget extends Widget
|
||||
const HIDE_HEADER = 'hideHeader';
|
||||
const HIDE_SAVE = 'hideSave';
|
||||
const COLUMNS_ALIASES = 'columnsAliases';
|
||||
const REQUIRED_PERMISSIONS = 'requiredPermissions';
|
||||
|
||||
const DATASET_PARAMETER = 'dataset';
|
||||
const METADATA_PARAMETER = 'metaData';
|
||||
@@ -78,6 +79,7 @@ class FilterWidget extends Widget
|
||||
private $checkboxes;
|
||||
private $columnsAliases;
|
||||
private $filterName;
|
||||
private $requiredPermissions;
|
||||
|
||||
private $dataset;
|
||||
private $metaData;
|
||||
@@ -164,6 +166,7 @@ class FilterWidget extends Widget
|
||||
|
||||
$filterSessionArray[self::COLUMNS_ALIASES] = $this->_getColumnAliasesFromPost();
|
||||
$filterSessionArray[self::CHECKBOXES] = $this->checkboxes;
|
||||
$filterSessionArray[self::REQUIRED_PERMISSIONS] = $this->requiredPermissions;
|
||||
|
||||
if ($this->app != null)
|
||||
{
|
||||
@@ -482,6 +485,11 @@ class FilterWidget extends Widget
|
||||
$filterSessionArray[self::DATASET_NAME_PARAMETER] = null;
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::REQUIRED_PERMISSIONS]))
|
||||
{
|
||||
$filterSessionArray[self::REQUIRED_PERMISSIONS] = null;
|
||||
}
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
}
|
||||
|
||||
@@ -503,6 +511,7 @@ class FilterWidget extends Widget
|
||||
$this->hideSave = false;
|
||||
$this->columnsAliases = null;
|
||||
$this->filterName = null;
|
||||
$this->requiredPermissions = null;
|
||||
|
||||
if (!is_array($args) || (is_array($args) && count($args) == 0))
|
||||
{
|
||||
@@ -589,6 +598,11 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$this->columnsAliases = $args[self::COLUMNS_ALIASES];
|
||||
}
|
||||
|
||||
if (isset($args[self::REQUIRED_PERMISSIONS]))
|
||||
{
|
||||
$this->requiredPermissions = $args[self::REQUIRED_PERMISSIONS];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user