Merge branch 'master' into feature-25999/C4_ma0594dev

This commit is contained in:
SimonGschnell
2024-02-15 15:16:07 +01:00
175 changed files with 15086 additions and 1346 deletions
+32 -20
View File
@@ -1,5 +1,22 @@
<?php
/**
* Copyright (C) 2023 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* To display a table that shows data retriev by a SQL statement
*/
@@ -40,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
/**
@@ -127,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]))
@@ -206,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];
}
}
/**
@@ -288,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))
@@ -310,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))
@@ -324,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
@@ -411,24 +440,6 @@ class TableWidget extends Widget
return !isset($class) ? '' : $class;
}
/**
* Utility method that retrieves the name of the columns present in a table JSON definition
*/
private function _getColumnsNames($columns)
{
$columnsNames = array();
foreach ($columns as $key => $obj)
{
if (isset($obj->name))
{
$columnsNames[] = $obj->name;
}
}
return $columnsNames;
}
/**
* Loads a view using the given viewName and eventually other parameters
*/
@@ -438,3 +449,4 @@ class TableWidget extends Widget
$ci->load->view($viewName, $parameters);
}
}