Files
FHC-Core/application/helpers/hlp_message_helper.php
T
Paolo aefd210273 - Added new configuration file auth.php for authentication
- Added new configuration file ldap.php for LDAP connection
- Added new controller system/Login to manage logins
- Added new controller system/Logout to manage logout
- Added new core model LDAP_Model to manage LDAP connections
- Added new constants in config/constants for authentication
- Added new function getCode to hlp_message_helper
- Now core/Auth_Controller loads the AuthLib as first step
- Now PermissionLib does NOT load anymore the AuthLib
- Removed old logic from PermissionLib
- Now function getAuthUID (hlp_authentication_helper) does not load anymore the AuthLib
- Now REST_Controller loads hlp_message_helper and hlp_common_helper
- core/APIv1_Controller does NOT load anymore hlp_message_helper and hlp_common_helper
- Added new constants to AuthLib
- AuthLib constructor now accept a parameter to enable the authentication immediatly (default)
- AuthLib loads configuration file auth.php and Person_model by default
- Added public methods getAuthObj and logout to AuthLib
- Renamed CheckUserAuthByUsernamePassword to checkUserAuthByUsernamePassword, CheckUserAuthByCode to checkUserAuthByCode and CheckUserAuthByCodeEmail to checkUserAuthByCodeEmail in AuthLib
- Added private methods _createAuthObj, _isLogged, _showInvalidAuthentication, _showError, _checkBTAuthentication, _checkHBALDAPAuthentication, _checkLDAPAuthentication, _checkForeignAuthentication, _storeAuthObj and _authenticate to AuthLib
2019-03-12 11:33:01 +01:00

127 lines
2.4 KiB
PHP

<?php
/**
* FH-Complete
*
* @package FHC-Helper
* @author FHC-Team
* @copyright Copyright (c) 2016 fhcomplete.org
* @license GPLv3
* @since Version 1.0.0
*/
/**
* Message Helper
*
* @subpackage Helpers
* @category Helpers
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
// -------------------------------------------------------------------------------------------------------
// Collection of functions to handle successful and error messages that methods and functions can return
// -------------------------------------------------------------------------------------------------------
/**
* Success
*
* @return array
*/
function success($retval, $code = null, $msg_indx_prefix = 'fhc_')
{
$success = new stdClass();
$success->error = EXIT_SUCCESS;
$success->fhcCode = $code;
if (!is_null($code)) $success->msg = lang($msg_indx_prefix . $code);
$success->retval = $retval;
return $success;
}
/**
* Error
*
* @return array
*/
function error($retval = '', $code = null, $msg_indx_prefix = 'fhc_')
{
$error = new stdClass();
$error->error = EXIT_ERROR;
$error->fhcCode = $code;
if (!is_null($code)) $error->msg = lang($msg_indx_prefix . $code);
$error->retval = $retval;
return $error;
}
/**
* Checks if the result represents a success
*/
function isSuccess($result)
{
if (is_object($result) && isset($result->error) && $result->error == EXIT_SUCCESS)
{
return true;
}
return false;
}
/**
* Checks if the result represents an error
* Wrapper function of isSuccess, more readable code
* Bob Dylan: ...there's no success like failure. And that failure's no success at all.
*/
function isError($result)
{
return !isSuccess($result);
}
/**
* Checks if the result represents a success and also if it contains valid data
*/
function hasData($result)
{
if (isSuccess($result) && isset($result->retval)
&& (!isEmptyArray($result->retval)
|| !isEmptyString($result->retval)
|| is_numeric($result->retval)
|| is_object($result->retval)))
{
return true;
}
return false;
}
/**
* Returns the property retval if $result contains data, otherwise null
*/
function getData($result)
{
$data = null;
if (hasData($result))
{
$data = $result->retval;
}
return $data;
}
/**
* Returns the property fhcCode if present, otherwise null
*/
function getCode($result)
{
$code = null;
if (isset($result->fhcCode))
{
$code = $result->fhcCode;
}
return $code;
}