mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-23 15:09:37 +00:00
- Removed permission system from DB_Model and FHC_Model
- Removed method _isEntitled from DB_Model - Removed method isEntitled from DHC_Model
This commit is contained in:
@@ -60,9 +60,6 @@ class DB_Model extends FHC_Model
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
|
||||
// Checks rights
|
||||
if (isError($ent = $this->_isEntitled(PermissionLib::INSERT_RIGHT))) return $ent;
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate;
|
||||
|
||||
@@ -110,9 +107,6 @@ class DB_Model extends FHC_Model
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
|
||||
// Checks rights
|
||||
if (isError($ent = $this->_isEntitled(PermissionLib::UPDATE_RIGHT))) return $ent;
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate;
|
||||
|
||||
@@ -156,9 +150,6 @@ class DB_Model extends FHC_Model
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
|
||||
// Checks rights
|
||||
if (isError($ent = $this->_isEntitled(PermissionLib::DELETE_RIGHT))) return $ent;
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
// Check for composite Primary Key
|
||||
@@ -197,9 +188,6 @@ class DB_Model extends FHC_Model
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
|
||||
// Checks rights
|
||||
if (isError($ent = $this->_isEntitled(PermissionLib::SELECT_RIGHT))) return $ent;
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
// Check for composite Primary Key
|
||||
@@ -236,9 +224,6 @@ class DB_Model extends FHC_Model
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
|
||||
// Checks rights
|
||||
if (isError($ent = $this->_isEntitled(PermissionLib::SELECT_RIGHT))) return $ent;
|
||||
|
||||
// Execute query
|
||||
if ($result = $this->db->get_where($this->dbTable, $where))
|
||||
{
|
||||
@@ -267,9 +252,6 @@ class DB_Model extends FHC_Model
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
|
||||
// Checks rights
|
||||
if (isError($ent = $this->_isEntitled(PermissionLib::SELECT_RIGHT))) return $ent;
|
||||
|
||||
// List of tables on which it will work
|
||||
$tables = array_merge(array($mainTable), $sideTables);
|
||||
// Array that will contain the number of columns of each table
|
||||
@@ -813,25 +795,6 @@ class DB_Model extends FHC_Model
|
||||
return array_combine($idexes, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the caller is entitled to perform this operation with this right
|
||||
*/
|
||||
private function _isEntitled($permission)
|
||||
{
|
||||
$ent = success(true);
|
||||
|
||||
$ent = $this->isEntitled($this->dbTable, $permission, FHC_NORIGHT, FHC_MODEL_ERROR);
|
||||
// If true is not returned, then an error has occurred
|
||||
if (isError($ent))
|
||||
{
|
||||
// Before returning the object containing the error, reset the build query
|
||||
// This is for preventing that other parts of the query will be built before of the next execution
|
||||
$this->resetQuery();
|
||||
}
|
||||
|
||||
return $ent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method for UDFLib->manageUDFs
|
||||
*/
|
||||
|
||||
@@ -19,40 +19,5 @@ class FHC_Model extends CI_Model
|
||||
|
||||
// Load return message helper
|
||||
$this->load->helper('message');
|
||||
|
||||
// Loads the permission library
|
||||
$this->load->library('PermissionLib');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is entitled to get access to a source with the given access type
|
||||
* This is a wrapper for the same method present in the PermissionLib
|
||||
*/
|
||||
public function isEntitled($sourceName, $accessType, $languageMessageCode, $msgErrorCode)
|
||||
{
|
||||
$isEntitled = success(true);
|
||||
|
||||
// If script is not called from Commandline
|
||||
// or the caller is _not_ a model _and_ tries to read data, then avoids to check permissions
|
||||
// Otherwise checks always the permissions
|
||||
if (!is_cli() ||
|
||||
($accessType == PermissionLib::SELECT_RIGHT
|
||||
&& substr(get_called_class(), -6) == DB_Model::MODEL_POSTFIX)
|
||||
|| $accessType != PermissionLib::SELECT_RIGHT)
|
||||
{
|
||||
if ($this->permissionlib->isEntitled($sourceName, $accessType) === false)
|
||||
{
|
||||
$retval = sprintf(
|
||||
'%s -> %s:%s',
|
||||
lang('fhc_'.$languageMessageCode),
|
||||
$this->permissionlib->getBerechtigungKurzbz($sourceName),
|
||||
$accessType
|
||||
);
|
||||
|
||||
$isEntitled = error($retval, $msgErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
return $isEntitled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user