mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
- Added the feature to the Infocenter controller to generate a unique identifier for each call of itself, and to keep using the identifier for the next calls in the same browser/tab
- Added the feature to the FilterWidget to use this identifier to create a different session for each FilterWidget
This commit is contained in:
@@ -29,7 +29,7 @@ class FilterWidget extends Widget
|
||||
const WIDGET_URL_SELECT_FILTERS = 'widgets/filter/selectFilters';
|
||||
const WIDGET_URL_SAVE_FILTER = 'widgets/filter/saveFilter';
|
||||
|
||||
const SESSION_NAME = 'FILTER';
|
||||
const SESSION_NAME = 'FHC_FILTER_WIDGET';
|
||||
|
||||
const ALL_SELECTED_FIELDS = 'allSelectedFields';
|
||||
const ALL_COLUMNS_ALIASES = 'allColumnsAliases';
|
||||
@@ -109,7 +109,7 @@ class FilterWidget extends Widget
|
||||
public function display($widgetData)
|
||||
{
|
||||
//
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
|
||||
//
|
||||
if ($this->filterId == null && isset($filterSessionArray[self::FILTER_ID]))
|
||||
@@ -144,7 +144,7 @@ class FilterWidget extends Widget
|
||||
|
||||
//
|
||||
$selectedFields = array();
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
if (isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
{
|
||||
$selectedFields = $filterSessionArray[self::SELECTED_FIELDS];
|
||||
@@ -195,6 +195,7 @@ class FilterWidget extends Widget
|
||||
$tmpDataset[] = $formattedResult;
|
||||
}
|
||||
}
|
||||
|
||||
$filterSessionArray[self::DATASET_PARAMETER] = $tmpDataset;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@@ -204,7 +205,7 @@ class FilterWidget extends Widget
|
||||
|
||||
$filterSessionArray[self::METADATA_PARAMETER] = $this->metaData;
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
$this->_writeSession($filterSessionArray);
|
||||
|
||||
//
|
||||
$this->loadViewFilters();
|
||||
@@ -422,9 +423,11 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$filterSessionArray = array();
|
||||
|
||||
if (isset($_SESSION[self::SESSION_NAME]))
|
||||
$session = $this->_readSession();
|
||||
|
||||
if (count($session) > 0)
|
||||
{
|
||||
$filterSessionArray = $_SESSION[self::SESSION_NAME];
|
||||
$filterSessionArray = $session;
|
||||
}
|
||||
|
||||
if (!isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
@@ -482,7 +485,7 @@ class FilterWidget extends Widget
|
||||
$filterSessionArray[self::DATASET_NAME_PARAMETER] = null;
|
||||
}
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
$this->_writeSession($filterSessionArray);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,6 +506,7 @@ class FilterWidget extends Widget
|
||||
$this->hideSave = false;
|
||||
$this->columnsAliases = null;
|
||||
$this->filterName = null;
|
||||
$this->fhc_controller_id = null;
|
||||
|
||||
if (!is_array($args) || (is_array($args) && count($args) == 0))
|
||||
{
|
||||
@@ -510,6 +514,15 @@ class FilterWidget extends Widget
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($args['fhc_controller_id']))
|
||||
{
|
||||
show_error('Dude you forgot the fhc_controller_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fhc_controller_id = $args['fhc_controller_id'];
|
||||
}
|
||||
|
||||
if ((
|
||||
!isset($args[self::APP_PARAMETER])
|
||||
&& !isset($args[self::DATASET_NAME_PARAMETER])
|
||||
@@ -704,7 +717,7 @@ class FilterWidget extends Widget
|
||||
self::DATASET_NAME_PARAMETER => $filter->retval[0]->dataset_name
|
||||
);
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
$this->_writeSession($filterSessionArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -719,7 +732,7 @@ class FilterWidget extends Widget
|
||||
self::DATASET_NAME_PARAMETER => null
|
||||
);
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
$this->_writeSession($filterSessionArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,7 +745,7 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$objToBeSaved = new stdClass();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
|
||||
if (isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
{
|
||||
@@ -828,7 +841,7 @@ class FilterWidget extends Widget
|
||||
// Selected fields
|
||||
$selectedFields = array();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
if (isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
{
|
||||
$selectedFields = $filterSessionArray[self::SELECTED_FIELDS];
|
||||
@@ -844,7 +857,7 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$app = $this->app;
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
if (isset($filterSessionArray[self::APP_PARAMETER]))
|
||||
{
|
||||
$app = $filterSessionArray[self::APP_PARAMETER];
|
||||
@@ -860,7 +873,7 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$datasetName = $this->datasetName;
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
if (isset($filterSessionArray[self::DATASET_NAME_PARAMETER]))
|
||||
{
|
||||
$datasetName = $filterSessionArray[self::DATASET_NAME_PARAMETER];
|
||||
@@ -877,7 +890,7 @@ class FilterWidget extends Widget
|
||||
$columnsAliases = $this->columnsAliases;
|
||||
$selectedFields = array();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
|
||||
if (isset($filterSessionArray[self::SELECTED_FIELDS]))
|
||||
{
|
||||
@@ -908,7 +921,7 @@ class FilterWidget extends Widget
|
||||
// Selected filters
|
||||
$selectedFilters = array();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
if (isset($filterSessionArray[self::SELECTED_FILTERS]))
|
||||
{
|
||||
$selectedFilters = $filterSessionArray[self::SELECTED_FILTERS];
|
||||
@@ -923,7 +936,7 @@ class FilterWidget extends Widget
|
||||
private function _setActiveFiltersFromPost(&$activeFilters, &$activeFiltersOperation, &$activeFiltersOption)
|
||||
{
|
||||
$selectedFilters = array();
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
|
||||
if (isset($filterSessionArray[self::ACTIVE_FILTERS]))
|
||||
{
|
||||
@@ -994,6 +1007,8 @@ class FilterWidget extends Widget
|
||||
*/
|
||||
private function _setSessionFilterData()
|
||||
{
|
||||
$session = $this->_readSession();
|
||||
|
||||
$filterSessionArray = array(
|
||||
self::SELECTED_FIELDS => $this->_getSelectedFieldsFromPost(),
|
||||
self::SELECTED_FILTERS => $this->_getSelectedFiltersFromPost(),
|
||||
@@ -1016,7 +1031,7 @@ class FilterWidget extends Widget
|
||||
$filterSessionArray[self::FILTER_ID] = $this->filterId;
|
||||
$filterSessionArray[self::FILTER_NAME] = $this->filterName;
|
||||
|
||||
$this->session->set_userdata(self::SESSION_NAME, $filterSessionArray);
|
||||
$this->_writeSession(array_merge($session, $filterSessionArray));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1030,7 +1045,7 @@ class FilterWidget extends Widget
|
||||
$activeFiltersOperation = array();
|
||||
$activeFiltersOption = array();
|
||||
|
||||
$filterSessionArray = $this->session->userdata(self::SESSION_NAME);
|
||||
$filterSessionArray = $this->_readSession();
|
||||
|
||||
if (isset($filterSessionArray[self::ACTIVE_FILTERS]))
|
||||
{
|
||||
@@ -1143,4 +1158,29 @@ class FilterWidget extends Widget
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _readSession()
|
||||
{
|
||||
if (isset($_SESSION[self::SESSION_NAME]) && isset($_SESSION[self::SESSION_NAME][$this->fhc_controller_id]))
|
||||
return $_SESSION[self::SESSION_NAME][$this->fhc_controller_id];
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _writeSession($data)
|
||||
{
|
||||
if (!isset($_SESSION[self::SESSION_NAME])
|
||||
|| (isset($_SESSION[self::SESSION_NAME]) && !is_array($_SESSION[self::SESSION_NAME])))
|
||||
{
|
||||
$_SESSION[self::SESSION_NAME] = array();
|
||||
}
|
||||
|
||||
$_SESSION[self::SESSION_NAME][$this->fhc_controller_id] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user