mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
- Renamed public method system/Filters_model->getFiltersByAppDatasetName to getFiltersByAppDatasetNamePersonId
- Added new parameter person_id to method getFiltersByAppDatasetNamePersonId - Changed query inside getFiltersByAppDatasetNamePersonId to get global and personal filters - Adapted FilterWidgetLib to use the new method getFiltersByAppDatasetNamePersonId
This commit is contained in:
@@ -211,7 +211,7 @@ class Filters extends FHC_Controller
|
||||
public function setNavigationMenu()
|
||||
{
|
||||
// Generates the filters structure array
|
||||
$filterMenu = $this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE));
|
||||
$this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE));
|
||||
|
||||
$this->outputJsonSuccess('Success');
|
||||
}
|
||||
@@ -271,3 +271,4 @@ class Filters extends FHC_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,7 @@ class FilterWidgetLib
|
||||
$whereParameters = array(
|
||||
'app' => $app,
|
||||
'dataset_name' => $datasetName,
|
||||
'person_id' => null,
|
||||
'default_filter' => true
|
||||
);
|
||||
|
||||
@@ -738,8 +739,10 @@ class FilterWidgetLib
|
||||
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
// Loads all the filters related to this page (same dataset_name and same app name)
|
||||
$filters = $this->_ci->FiltersModel->getFiltersByAppDatasetName(
|
||||
$session[self::APP], $session[self::DATASET_NAME]
|
||||
$filters = $this->_ci->FiltersModel->getFiltersByAppDatasetNamePersonId(
|
||||
$session[self::APP],
|
||||
$session[self::DATASET_NAME],
|
||||
getAuthPersonId()
|
||||
);
|
||||
|
||||
// If filters were loaded
|
||||
@@ -813,9 +816,6 @@ class FilterWidgetLib
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Return an unique string that identify this filter widget
|
||||
* NOTE: The default value is the URI where the FilterWidget is called
|
||||
@@ -857,6 +857,9 @@ class FilterWidgetLib
|
||||
$this->_filterUniqueId = $filterUniqueId;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Generates a condition for a SQL where clause using the given applied filter definition.
|
||||
* By default an empty string is returned.
|
||||
@@ -972,3 +975,4 @@ class FilterWidgetLib
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,19 +57,34 @@ class Filters_model extends DB_Model
|
||||
/**
|
||||
* Loads all filters by their app and dataset_name
|
||||
*/
|
||||
public function getFiltersByAppDatasetName($app, $dataset_name)
|
||||
public function getFiltersByAppDatasetNamePersonId($app, $dataset_name, $person_id)
|
||||
{
|
||||
$this->resetQuery(); // reset any previous built query
|
||||
$query = '
|
||||
(
|
||||
-- Global filters
|
||||
SELECT gs.filter_id,
|
||||
gs.person_id,
|
||||
gs.description
|
||||
FROM system.tbl_filters gs
|
||||
WHERE gs.app = ?
|
||||
AND gs.dataset_name = ?
|
||||
AND gs.person_id IS NULL
|
||||
ORDER BY gs.person_id DESC, gs.sort ASC
|
||||
)
|
||||
UNION ALL
|
||||
(
|
||||
-- Personal filters
|
||||
SELECT ps.filter_id,
|
||||
ps.person_id,
|
||||
ps.description
|
||||
FROM system.tbl_filters ps
|
||||
WHERE ps.app = ?
|
||||
AND ps.dataset_name = ?
|
||||
AND ps.person_id = ?
|
||||
ORDER BY ps.person_id DESC, ps.sort ASC
|
||||
)';
|
||||
|
||||
$this->addSelect('filter_id, person_id, description');
|
||||
$this->addOrder('person_id', 'DESC'); // sort descending on column person_id
|
||||
$this->addOrder('sort', 'ASC'); // sort on column sort
|
||||
|
||||
$filterParametersArray = array(
|
||||
'app' => $app,
|
||||
'dataset_name' => $dataset_name
|
||||
);
|
||||
|
||||
return $this->loadWhere($filterParametersArray);
|
||||
return $this->execQuery($query, array($app, $dataset_name, $app, $dataset_name, $person_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user