mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Fixes: code quality checks
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use \stdClass as stdClass;
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
@@ -120,7 +122,8 @@ class DB_Model extends CI_Model
|
||||
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable))) return $validate;
|
||||
$validate = $this->_prepareUDFsWrite($data, $this->dbTable);
|
||||
if (isError($validate)) return $validate;
|
||||
|
||||
// Add the pgp_sym_eccrypt postgresql function to the set clause if needed
|
||||
$this->_addEncrypt($encryptedColumns, $data);
|
||||
@@ -174,7 +177,8 @@ class DB_Model extends CI_Model
|
||||
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id))) return $validate;
|
||||
$validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id);
|
||||
if (isError($validate)) return $validate;
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
@@ -341,7 +345,8 @@ class DB_Model extends CI_Model
|
||||
// NOTE: $this->db->list_fields($tables[$t]) doesn't work if there are two tables with
|
||||
// the same name in two different schemas, use this workaround
|
||||
$fields = array();
|
||||
if (isSuccess($lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table)))
|
||||
$lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table);
|
||||
if (isSuccess($lstColumns))
|
||||
{
|
||||
$fields = $lstColumns->retval;
|
||||
}
|
||||
@@ -419,7 +424,8 @@ class DB_Model extends CI_Model
|
||||
$tmpFilteredArray = array_filter(get_object_vars($sideTableObj));
|
||||
if (isset($tmpFilteredArray) && count($tmpFilteredArray) > 0)
|
||||
{
|
||||
if (($k = $this->_findMainTable($mainTableObj, $returnArray)) === false)
|
||||
$k = $this->_findMainTable($mainTableObj, $returnArray);
|
||||
if ($k === false)
|
||||
{
|
||||
$mainTableObj->{$sideTableProperty} = array($sideTableObj);
|
||||
$returnArray[$returnArrayCounter++] = $mainTableObj;
|
||||
@@ -802,8 +808,7 @@ class DB_Model extends CI_Model
|
||||
$cleanedQuery = trim(preg_replace('/\t|\n|\r|;/', '', $query)); //
|
||||
|
||||
//
|
||||
if (
|
||||
(stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
|
||||
if ((stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
|
||||
&& (stripos($cleanedQuery, 'UPDATE') > 0 || stripos($cleanedQuery, 'UPDATE') == false)
|
||||
&& (stripos($cleanedQuery, 'CREATE') > 0 || stripos($cleanedQuery, 'CREATE') == false)
|
||||
&& (stripos($cleanedQuery, 'DELETE') > 0 || stripos($cleanedQuery, 'DELETE') == false)
|
||||
@@ -881,7 +886,8 @@ class DB_Model extends CI_Model
|
||||
$result->schema = DB_Model::DEFAULT_SCHEMA;
|
||||
|
||||
// If a schema is specified
|
||||
if (($pos = strpos($schemaAndTable, '.')) !== false)
|
||||
$pos = strpos($schemaAndTable, '.');
|
||||
if ($pos !== false)
|
||||
{
|
||||
$result->schema = substr($schemaAndTable, 0, $pos);
|
||||
$result->table = substr($schemaAndTable, $pos + 1);
|
||||
@@ -911,9 +917,8 @@ class DB_Model extends CI_Model
|
||||
&& array_key_exists(self::CRYPT_PASSWORD_NAME, $encryptedColumns[$column]))
|
||||
{
|
||||
// Password to encrypt data
|
||||
$encryptionPassword = $this->config->item(self::CRYPT_CONF_PASSWORDS)[
|
||||
$encryptedColumns[$column][self::CRYPT_PASSWORD_NAME]
|
||||
];
|
||||
$cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS);
|
||||
$encryptionPassword = $cryptConfPasswords[$encryptedColumns[$column][self::CRYPT_PASSWORD_NAME]];
|
||||
|
||||
// Add the encrypted column to the set clause without escaping
|
||||
$this->db->set(
|
||||
@@ -952,15 +957,11 @@ class DB_Model extends CI_Model
|
||||
&& array_key_exists(self::CRYPT_PASSWORD_NAME, $definition))
|
||||
{
|
||||
// And if exists the wanted password to decrypt in the configs
|
||||
if (array_key_exists(
|
||||
$definition[self::CRYPT_PASSWORD_NAME],
|
||||
$this->config->item(self::CRYPT_CONF_PASSWORDS))
|
||||
)
|
||||
if (array_key_exists($definition[self::CRYPT_PASSWORD_NAME], $this->config->item(self::CRYPT_CONF_PASSWORDS)))
|
||||
{
|
||||
// Password to decrypt data
|
||||
$decryptionPassword = $this->config->item(self::CRYPT_CONF_PASSWORDS)[
|
||||
$definition[self::CRYPT_PASSWORD_NAME]
|
||||
];
|
||||
$cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS);
|
||||
$decryptionPassword = $cryptConfPasswords[$definition[self::CRYPT_PASSWORD_NAME]];
|
||||
|
||||
// Find and replace all the occurrences of the provided encrypted columns
|
||||
// with the postgresql decryption function
|
||||
@@ -997,15 +998,11 @@ class DB_Model extends CI_Model
|
||||
&& array_key_exists(self::CRYPT_PASSWORD_NAME, $definition))
|
||||
{
|
||||
// And if exists the wanted password to decrypt in the configs
|
||||
if (array_key_exists(
|
||||
$definition[self::CRYPT_PASSWORD_NAME],
|
||||
$this->config->item(self::CRYPT_CONF_PASSWORDS))
|
||||
)
|
||||
if (array_key_exists($definition[self::CRYPT_PASSWORD_NAME], $this->config->item(self::CRYPT_CONF_PASSWORDS)))
|
||||
{
|
||||
// Password to decrypt data
|
||||
$decryptionPassword = $this->config->item(self::CRYPT_CONF_PASSWORDS)[
|
||||
$definition[self::CRYPT_PASSWORD_NAME]
|
||||
];
|
||||
$cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS);
|
||||
$decryptionPassword = $cryptConfPasswords[$definition[self::CRYPT_PASSWORD_NAME]];
|
||||
|
||||
// -----------------------------------------
|
||||
// SELECT
|
||||
@@ -1063,14 +1060,12 @@ class DB_Model extends CI_Model
|
||||
)
|
||||
{
|
||||
// Then rename the column using the postgresql decryption function
|
||||
$tmpWhere[
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
).$operator
|
||||
] = $condition;
|
||||
$tmpWhere[sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
).$operator] = $condition;
|
||||
}
|
||||
else // otherwise copy the column as it is
|
||||
{
|
||||
@@ -1127,11 +1122,11 @@ class DB_Model extends CI_Model
|
||||
{
|
||||
if ($id != null)
|
||||
{
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable, $this->_getUDFsNoPerms($id));
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $schemaAndTable, $this->_getUDFsNoPerms($id));
|
||||
}
|
||||
else
|
||||
{
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable);
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $schemaAndTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -510,8 +510,10 @@ class FilterCmptLib
|
||||
|
||||
if ($saveCustomFilter === true)
|
||||
{
|
||||
$this->_setSessionElement(FilterCmptLib::SESSION_SIDE_MENU,
|
||||
$this->_generateFilterMenu($this->_app, $this->_datasetName));
|
||||
$this->_setSessionElement(
|
||||
FilterCmptLib::SESSION_SIDE_MENU,
|
||||
$this->_generateFilterMenu($this->_app, $this->_datasetName)
|
||||
);
|
||||
}
|
||||
|
||||
return $saveCustomFilter;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \stdClass as stdClass;
|
||||
|
||||
/**
|
||||
* FilterWidget logic
|
||||
*/
|
||||
@@ -139,7 +141,7 @@ class FilterWidgetLib
|
||||
/**
|
||||
* Gets the CI instance and loads message helper
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
}
|
||||
@@ -409,7 +411,7 @@ class FilterWidgetLib
|
||||
public function getFilterName($filterJson)
|
||||
{
|
||||
$filterName = $filterJson->name; // always present, used as default
|
||||
$trimedname = (isset($filterJson->namePhrase)?trim($filterJson->namePhrase):'');
|
||||
|
||||
// Filter name from phrases system
|
||||
if (isset($filterJson->namePhrase) && !isEmptyString($filterJson->namePhrase))
|
||||
{
|
||||
@@ -470,7 +472,8 @@ class FilterWidgetLib
|
||||
if (in_array($selectedField, $fields))
|
||||
{
|
||||
// If the selected field is present in the list of the selected fields by the current filter
|
||||
if (($pos = array_search($selectedField, $selectedFields)) !== false)
|
||||
$pos = array_search($selectedField, $selectedFields);
|
||||
if ($pos !== false)
|
||||
{
|
||||
// Then remove it and shift the rest of elements by one if needed
|
||||
array_splice($selectedFields, $pos, 1);
|
||||
@@ -769,7 +772,6 @@ class FilterWidgetLib
|
||||
$this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage));
|
||||
|
||||
$filterMenu = null;
|
||||
$currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session
|
||||
|
||||
$session = $this->getSession(); // The filter currently stored in session (the one that is currently used)
|
||||
if ($session != null)
|
||||
|
||||
@@ -93,7 +93,7 @@ class TableWidgetLib
|
||||
/**
|
||||
* Gets the CI instance and loads message helper
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class Person_model extends DB_Model
|
||||
if (isset($person['svnr']) && $person['svnr'] != '')
|
||||
{
|
||||
$this->PersonModel->addOrder('svnr', 'DESC');
|
||||
$result = $this->PersonModel->loadWhere(array(
|
||||
$result = $this->PersonModel->loadWhere(array(
|
||||
'person_id != ' => $person['person_id'],
|
||||
'SUBSTRING(svnr FROM 1 FOR 10) = ' => $person['svnr'])
|
||||
);
|
||||
@@ -156,7 +156,8 @@ class Person_model extends DB_Model
|
||||
'lower(nachname) like '.$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(vorname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(nachname || ' ' || vorname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%'));
|
||||
OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%')
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -170,8 +171,12 @@ class Person_model extends DB_Model
|
||||
*/
|
||||
public function getPersonStammdaten($person_id, $zustellung_only = false)
|
||||
{
|
||||
$this->addSelect('public.tbl_person.*, tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code, tbl_person.geburtsnation AS geburtsnation_code,
|
||||
s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation');
|
||||
$this->addSelect('public.tbl_person.*,
|
||||
tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code,
|
||||
tbl_person.geburtsnation AS geburtsnation_code,
|
||||
s.kurztext as staatsbuergerschaft,
|
||||
g.kurztext as geburtsnation'
|
||||
);
|
||||
$this->addJoin('bis.tbl_nation s', 'public.tbl_person.staatsbuergerschaft = s.nation_code', 'LEFT');
|
||||
$this->addJoin('bis.tbl_nation g', 'public.tbl_person.geburtsnation = g.nation_code', 'LEFT');
|
||||
|
||||
@@ -276,7 +281,8 @@ class Person_model extends DB_Model
|
||||
*/
|
||||
public function getFullName($uid)
|
||||
{
|
||||
if (!$result = getData($this->getByUid($uid))[0])
|
||||
$result = getData($this->getByUid($uid))[0];
|
||||
if (!$result)
|
||||
{
|
||||
show_error('Failed loading person');
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ class FilterWidget extends Widget
|
||||
private function _setFilterMenu()
|
||||
{
|
||||
// Generates the filters structure array
|
||||
$filterMenu = $this->filterwidgetlib->generateFilterMenu(
|
||||
$this->filterwidgetlib->generateFilterMenu(
|
||||
$this->router->directory.$this->router->class.'/'.$this->router->method
|
||||
);
|
||||
}
|
||||
@@ -633,7 +633,7 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$columnsNames = array();
|
||||
|
||||
foreach ($columns as $key => $obj)
|
||||
foreach ($columns as $obj)
|
||||
{
|
||||
if (isset($obj->name))
|
||||
{
|
||||
|
||||
@@ -440,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
|
||||
*/
|
||||
@@ -467,3 +449,4 @@ class TableWidget extends Widget
|
||||
$ci->load->view($viewName, $parameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user