mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
ff858a495d
- Added new webservicetyp_kurzbz "job" to table system.tbl_webservicetyp in system/dbupdate_3.3.php - Added new filter "All jobs viewer" - Added new __construct to LogLib to set properties - Added new public methods logInfoDB, logDebugDB, logWarningDB and logErrorDB to LogLib - Added new private method _logDB to LogLib - Renamed LogLib private method _format to _getPrefix - Added new private method _getDatabaseDescription to LogLib - Changed method _getCaller to use different levels of debug_backtrace - Added new properties and constants to LogLib to log to the database
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
/**
|
|
* REST_Controller takes care about authentication and it loads the AuthLib
|
|
*/
|
|
abstract class APIv1_Controller extends REST_Controller
|
|
{
|
|
private $_requiredPermissions;
|
|
|
|
/**
|
|
* Standard constructor for all the RESTful resources
|
|
*/
|
|
public function __construct($requiredPermissions)
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->_requiredPermissions = $requiredPermissions;
|
|
|
|
log_message('debug', 'Called API: '.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
|
|
}
|
|
|
|
/**
|
|
* This method is automatically called by CodeIgniter after the execution of the constructor is completed
|
|
* - Cheks if the AuthLib was loaded, if not it means that the authentication failed
|
|
* - Loads the permsission lib and calls permissionlib->isEntitled
|
|
* - Checks if the caller is allowed to access to this content with the given permissions
|
|
* if it is not allowed will set the HTTP header with code 401
|
|
* - Calls the parent (REST_Controller) _remap method to performs other checks
|
|
*/
|
|
public function _remap($object_called, $arguments)
|
|
{
|
|
if (isset($this->authlib)) // if set then the authentication is ok
|
|
{
|
|
// Loads permission lib
|
|
$this->load->library('PermissionLib');
|
|
|
|
// Cheks if the user has the permission to call a method
|
|
if (!$this->permissionlib->isEntitled($this->_requiredPermissions, $this->router->method))
|
|
{
|
|
// If not...
|
|
$this->response(error('You are not allowed to access to this content'), REST_Controller::HTTP_UNAUTHORIZED);
|
|
}
|
|
}
|
|
|
|
// Finally calls the parent _remap to perform other checks
|
|
parent::_remap($object_called, $arguments);
|
|
}
|
|
}
|