mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-02 20:59:28 +00:00
fbed4b2261
- Added method isEntitled to FCH_Model - Cleaned the controllers by moving the database related code in the models or libraries
71 lines
1.4 KiB
PHP
71 lines
1.4 KiB
PHP
<?php
|
|
|
|
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
|
|
|
class FHC_Model extends CI_Model
|
|
{
|
|
protected $acl;
|
|
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->lang->load("fhc_model");
|
|
$this->lang->load("fhcomplete");
|
|
|
|
$this->load->helper("language");
|
|
$this->load->helper("Message");
|
|
$this->load->helper("fhcauth");
|
|
|
|
$this->load->library("FHC_DB_ACL");
|
|
|
|
$this->acl = $this->config->item("fhc_acl");
|
|
}
|
|
|
|
/** ---------------------------------------------------------------
|
|
* Success
|
|
*
|
|
* @param mixed $retval
|
|
* @return array
|
|
*/
|
|
protected function _success($retval, $message = null)
|
|
{
|
|
return success($retval, $message);
|
|
}
|
|
|
|
/** ---------------------------------------------------------------
|
|
* General Error
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function _error($retval, $message = null)
|
|
{
|
|
return error($retval, $message);
|
|
}
|
|
|
|
protected function getBerechtigungKurzbz($sourceName)
|
|
{
|
|
if (isset($this->acl[$sourceName]))
|
|
{
|
|
return $this->acl[$sourceName];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
protected function isEntitled($sourceName, $accessType, $languageMessageCode, $msgErrorCode)
|
|
{
|
|
$fhc_acl = $this->getBerechtigungKurzbz($sourceName);
|
|
|
|
if (! $this->fhc_db_acl->isBerechtigt($fhc_acl, $accessType))
|
|
{
|
|
return $this->_error(lang("fhc_" . $languageMessageCode)." -> " . $fhc_acl . ":" . $accessType, $msgErrorCode);
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
} |