ci =& get_instance();
// Loads the library to manage the rights system
//$this->ci->load->library('FHC_DB_ACL');
// Loads the auth helper
$this->ci->load->helper('fhcauth');
// Loads the array of resources
$this->acl = $this->ci->config->item('fhc_acl');
if (!is_cli())
{
// API Caller rights initialization
self::$bb = new benutzerberechtigung();
self::$bb->getBerechtigungen(getAuthUID());
}
}
/**
* Check if the user is entitled to get access to a source with the given access type
*
* @return bool true if a user has the right to access to the specified
* resource with a specified permission type, false otherwise
*/
public function isEntitled($sourceName, $permissionType)
{
$isEntitled = false;
if(!is_cli())
{
// If the resource exists
if (isset($this->acl[$sourceName]))
{
// Checks permission
$isEntitled = $this->_isBerechtigt($this->acl[$sourceName], $permissionType);
}
}
else
{
$isEntitled = true;
}
return $isEntitled;
}
/**
* Get a permission by a given source
*/
public function getBerechtigungKurzbz($sourceName)
{
$returnValue = null;
if (isset($this->acl[$sourceName]))
{
$returnValue = $this->acl[$sourceName];
}
return $returnValue;
}
/**
* Checks user's (API caller) rights
*/
private function _isBerechtigt($berechtigung_kurzbz, $art = null, $oe_kurzbz = null, $kostenstelle_id = null)
{
$isBerechtigt = false;
if (!is_null($berechtigung_kurzbz))
{
if (self::$bb->isBerechtigt($berechtigung_kurzbz, $oe_kurzbz, $art, $kostenstelle_id))
{
$isBerechtigt = true;
}
}
return $isBerechtigt;
}
}