- Added new constants SESSION_ENCRYPTED_COLUMNS and ENCRYPTED_COLUMNS to libraries/TableWidgetLib

- Changed libraries/TableWidgetLib->getDataset to accept the new parameter encryptedColumns
- Added new private method _encryptedColumns to widgets/TableWidget
- widgets/TableWidget now calls tablewidgetlib->getDataset now giving the encryptedColumns parameter
- widgets/TableWidget stores in the session the encryptedColumns parameter
This commit is contained in:
Paolo
2023-02-20 11:31:19 +01:00
parent 9b8a1ba096
commit 2729b60b39
2 changed files with 18 additions and 4 deletions
+4 -2
View File
@@ -33,6 +33,7 @@ class TableWidgetLib
const SESSION_FIELDS = 'fields';
const SESSION_COLUMNS_ALIASES = 'columnsAliases';
const SESSION_ADDITIONAL_COLUMNS = 'additionalColumns';
const SESSION_ENCRYPTED_COLUMNS = 'encryptedColumns';
const SESSION_CHECKBOXES = 'checkboxes';
const SESSION_METADATA = 'datasetMetadata';
const SESSION_ROW_NUMBER = 'rowNumber';
@@ -66,6 +67,7 @@ class TableWidgetLib
const ADDITIONAL_COLUMNS = 'additionalColumns';
const CHECKBOXES = 'checkboxes';
const COLUMNS_ALIASES = 'columnsAliases';
const ENCRYPTED_COLUMNS = 'encryptedColumns';
// ...to format/mark records of a dataset
const FORMAT_ROW = 'formatRow';
@@ -194,7 +196,7 @@ class TableWidgetLib
/**
* Retrieves the dataset from the DB
*/
public function getDataset($datasetQuery)
public function getDataset($datasetQuery, $encryptedColumns)
{
$dataset = null;
@@ -203,7 +205,7 @@ class TableWidgetLib
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
// Execute the given SQL statement suppressing error messages
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery);
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery, null, $encryptedColumns);
}
return $dataset;
+14 -2
View File
@@ -57,6 +57,8 @@ class TableWidget extends Widget
private $_sessionTimeout; // session expiring time
private $_encryptedColumns; // contains info about encrypted columns
private static $_TableWidgetInstance; // static property that contains the instance of itself
/**
@@ -144,6 +146,7 @@ class TableWidget extends Widget
$this->_datasetRepresentationOptions = null;
$this->_datasetRepFieldsDefs = null;
$this->_sessionTimeout = TableWidgetLib::SESSION_DEFAULT_TIMEOUT;
$this->_encryptedColumns = null;
// Retrieved the required permissions parameter if present
if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS]))
@@ -223,6 +226,14 @@ class TableWidget extends Widget
{
$this->_sessionTimeout = $args[TableWidgetLib::SESSION_TIMEOUT];
}
// Parameter is used to define the ecrypted columns
if (isset($args[TableWidgetLib::ENCRYPTED_COLUMNS])
&& is_array($args[TableWidgetLib::ENCRYPTED_COLUMNS])
&& count($args[TableWidgetLib::ENCRYPTED_COLUMNS]) > 0)
{
$this->_encryptedColumns = $args[TableWidgetLib::ENCRYPTED_COLUMNS];
}
}
/**
@@ -305,7 +316,7 @@ class TableWidget extends Widget
$datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query);
// Then retrieve dataset from DB
$dataset = $this->tablewidgetlib->getDataset($datasetQuery);
$dataset = $this->tablewidgetlib->getDataset($datasetQuery, $this->_encryptedColumns);
// Save changes into session if data are valid
if (!isError($dataset))
@@ -327,7 +338,7 @@ class TableWidget extends Widget
$datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query);
// Then retrieve dataset from DB
$dataset = $this->tablewidgetlib->getDataset($datasetQuery);
$dataset = $this->tablewidgetlib->getDataset($datasetQuery, $this->_encryptedColumns);
// Save changes into session if data are valid
if (!isError($dataset))
@@ -341,6 +352,7 @@ class TableWidget extends Widget
TableWidgetLib::SESSION_FIELDS => $this->tablewidgetlib->getExecutedQueryListFields(), // all the fields of the dataset
TableWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases
TableWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns
TableWidgetLib::SESSION_ENCRYPTED_COLUMNS => $this->_encryptedColumns, // encrypted columns
TableWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column
TableWidgetLib::SESSION_METADATA => $this->tablewidgetlib->getExecutedQueryMetaData(), // the metadata of the dataset
TableWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this table