mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Added private method _fillMissingChkboxUDF to UDF_model.
It checks if UDF checkboxes are NOT posted and sets theirs values to false
This commit is contained in:
@@ -36,6 +36,7 @@ class DB_Model extends FHC_Model
|
||||
const UDF_MAX_LENGTH = 'max-length';
|
||||
const UDF_MIN_LENGTH = 'min-length';
|
||||
|
||||
// String values of booleans
|
||||
const STRING_TRUE = 'true';
|
||||
const STRING_FALSE = 'false';
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ class UDF_model extends DB_Model
|
||||
// Load model Person_model
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
$udfs = $this->_fillMissingChkboxUDF($udfs, 'public', 'tbl_person');
|
||||
|
||||
$resultPerson = $this->PersonModel->update($person_id, $udfs);
|
||||
}
|
||||
|
||||
@@ -70,6 +72,8 @@ class UDF_model extends DB_Model
|
||||
// Load model Prestudent_model
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$udfs = $this->_fillMissingChkboxUDF($udfs, 'public', 'tbl_prestudent');
|
||||
|
||||
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
|
||||
}
|
||||
|
||||
@@ -88,4 +92,31 @@ class UDF_model extends DB_Model
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _fillMissingChkboxUDF($udfs, $schema, $table)
|
||||
{
|
||||
$_fillMissingChkboxUDF = $udfs;
|
||||
|
||||
$result = $this->load(array($schema, $table));
|
||||
if (isSuccess($result) && count($result->retval) == 1)
|
||||
{
|
||||
$jsons = json_decode($result->retval[0]->jsons);
|
||||
|
||||
foreach($jsons as $udfDescription)
|
||||
{
|
||||
if ($udfDescription->{DB_Model::UDF_TYPE_NAME} == DB_Model::UDF_CHKBOX_TYPE)
|
||||
{
|
||||
if (!isset($_fillMissingChkboxUDF[$udfDescription->{DB_Model::UDF_ATTRIBUTE_NAME}]))
|
||||
{
|
||||
$_fillMissingChkboxUDF[$udfDescription->{DB_Model::UDF_ATTRIBUTE_NAME}] = DB_Model::STRING_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $_fillMissingChkboxUDF;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user