Merge branch 'ent-6158-mejoras-a-servicios-dinamicos-expresiones-regulares-y-varios-custom-field' into 'develop'

Definition matching Entity

See merge request artica/pandorafms!3648
This commit is contained in:
Daniel Rodriguez 2021-01-27 14:40:40 +01:00
commit 0b661add35
3 changed files with 15 additions and 8 deletions

View File

@ -4096,13 +4096,17 @@ function ui_get_url_refresh($params=false, $relative=true, $add_post=true)
function ui_forced_public_url() function ui_forced_public_url()
{ {
global $config; global $config;
$exclusions = preg_split("/[\n\s,]+/", io_safe_output($config['public_url_exclusions']));
$exclusions = [];
if (empty($config['public_url_exclusions']) === false) {
$exclusions = preg_split("/[\n\s,]+/", io_safe_output($config['public_url_exclusions']));
}
if (in_array($_SERVER['REMOTE_ADDR'], $exclusions)) { if (in_array($_SERVER['REMOTE_ADDR'], $exclusions)) {
return false; return false;
} }
return (bool) $config['force_public_url']; return isset($config['force_public_url']) && (bool) $config['force_public_url'];
} }

View File

@ -61,12 +61,12 @@ abstract class Entity
/** /**
* Instances a new object using array definition. * Instances a new object using array definition.
* *
* @param string $class_str Class name.
* @param array $data Fields data. * @param array $data Fields data.
* @param string $class_str Class name.
* *
* @return object With current definition. * @return object With current definition.
*/ */
public static function build(string $class_str, array $data=[]) public static function build(array $data=[], string $class_str=__CLASS__)
{ {
$obj = new $class_str(); $obj = new $class_str();
// Set values. // Set values.

View File

@ -136,13 +136,16 @@ class Module extends Entity
/** /**
* Creates a module object from given data. Avoid query duplication. * Creates a module object from given data. Avoid query duplication.
* *
* @param array $data Module information. * @param array $data Module information.
* @param string $class_str Class type.
* *
* @return PandoraFMS\Module Object. * @return PandoraFMS\Module Object.
*/ */
public static function build(array $data=[]) public static function build(
{ array $data=[],
$obj = new Module(); string $class_str='\PandoraFMS\Module'
) {
$obj = new $class_str();
// Set values. // Set values.
foreach ($data as $k => $v) { foreach ($data as $k => $v) {