- Changed system/dbupdate_3.3.php to create table system.tbl_filters and what its needed

- Added model system/Filters_model to manage system.tbl_filters
- Removed method execQuery from model system/UDF_model
- Added property executedQueryMetaData to DB_Model
- Added property executedQueryListFields to DB_Model
- Added method getExecutedQueryListFields to DB_Model
- Added method getExecutedQueryMetaData to DB_Model
- Added method execReadOnlyQuery to DB_Model to execute read only queries from outside a model
- Changed DB_Model method _toPhp to store infos about an executed query into properties executedQueryMetaData and executedQueryListFields
- Updated library UDFLib to use execReadOnlyQuery
- Added widget FilterWidget to render and manage a filter into VileSci
- Added views widgets/filter/selectFields, widgets/filter/selectFilters and widgets/filter/tableDataset used by FilterWidget
This commit is contained in:
Paolo
2017-11-22 12:08:54 +01:00
parent 60a9afc4fb
commit ee3998f62e
10 changed files with 468 additions and 69 deletions
+34 -61
View File
@@ -6,10 +6,10 @@ class UDF_model extends DB_Model
const STRING_NULL = 'null';
const STRING_TRUE = 'true';
const STRING_FALSE = 'false';
const UDF_DROPDOWN_TYPE = 'dropdown';
const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown';
/**
* Constructor
*/
@@ -20,41 +20,14 @@ class UDF_model extends DB_Model
$this->pk = array('schema', 'table');
$this->hasSequence = false;
}
/**
* Override DB_Model method execQuery to allow only to perform queries to read data
*/
public function execQuery($query, $parametersArray = null)
{
//
if (
(
substr($query, 0, 6) == 'SELECT'
|| substr($query, 0, 4) == 'WITH'
)
&&
(
!stripos($query, 'INSERT')
&& !stripos($query, 'UPDATE')
&& !stripos($query, 'DELETE')
)
)
{
return parent::execQuery($query, $parametersArray);
}
else
{
return error('You are allowed to run only query for reading data');
}
}
/**
* Returns all the UDF for this table
*/
public function getUDFsDefinitions($schemaAndTable)
{
$st = $this->getSchemaAndTable($schemaAndTable);
$this->addSelect(UDFLib::COLUMN_JSON_DESCRIPTION);
$udfResults = $this->loadWhere(
array(
@@ -62,13 +35,13 @@ class UDF_model extends DB_Model
'table' => $st->table
)
);
return $udfResults;
}
// ------------------------------------------------------------------------------------
// These methods work only with the this version of FAS, not with the future versions
/**
* Methods to save data from FAS
*/
@@ -77,53 +50,53 @@ class UDF_model extends DB_Model
$result = error('No way man!');
$resultPerson = success('person');
$resultPrestudent = success('prestudent');
$person_id = $udfs['person_id'];
unset($udfs['person_id']);
$prestudent_id = $udfs['prestudent_id'];
unset($udfs['prestudent_id']);
$jsons = array();
//
//
if (isset($person_id))
{
// Load model Person_model
$this->load->model('person/Person_model', 'PersonModel');
$result = $this->load(array('public', 'tbl_person'));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
}
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
$resultPerson = $this->PersonModel->update($person_id, $udfs);
}
//
//
if (isset($prestudent_id))
{
// Load model Prestudent_model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->load(array('public', 'tbl_prestudent'));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
}
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
}
if (isSuccess($resultPerson) && isSuccess($resultPrestudent))
{
$result = success(array($resultPerson->retval, $resultPrestudent->retval));
@@ -136,17 +109,17 @@ class UDF_model extends DB_Model
{
$result = $resultPrestudent;
}
return $result;
}
/**
*
*
*/
private function _fillMissingChkboxUDF($udfs, $jsons)
{
$_fillMissingChkboxUDF = $udfs;
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE)
@@ -168,17 +141,17 @@ class UDF_model extends DB_Model
}
}
}
return $_fillMissingChkboxUDF;
}
/**
*
*
*/
private function _fillMissingDropdownUDF($udfs, $jsons)
{
$_fillMissingDropdownUDF = $udfs;
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE
@@ -194,17 +167,17 @@ class UDF_model extends DB_Model
}
}
}
return $_fillMissingDropdownUDF;
}
/**
*
*
*/
private function _fillMissingTextUDF($udfs, $jsons)
{
$_fillMissingTextUDF = $udfs;
foreach($jsons as $udfDescription)
{
if ($udfDescription->{UDFLib::TYPE} == 'textarea'
@@ -220,7 +193,7 @@ class UDF_model extends DB_Model
}
}
}
return $_fillMissingTextUDF;
}
}
}