From 140062e0b606495f90fd77b8f290987844c79cab Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 29 Apr 2022 17:38:00 +0200 Subject: [locations/remoteaccess] Add option to veto remoteaccess mode Remoteaccess mode can now be forced to be disabled for individual locations in locations module, either unconditionally, or whenever the openingtimes schedule says the room is open. A reboot will be triggered whenever the room opens/closes to force clients into the proper runmode. --- inc/util.inc.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'inc/util.inc.php') diff --git a/inc/util.inc.php b/inc/util.inc.php index 81c7d807..c3e70f89 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -590,11 +590,23 @@ SADFACE; { $regex = '/ ( - (?: [\x20-\xFF] ){1,100} # ignore lower non-printable range + [\x20-\xFF]{1,100} # ignore lower non-printable range ) | . # anything else /x'; return iconv('MS-ANSI', 'UTF-8', preg_replace($regex, '$1', $string)); } + /** + * Clamp given value into [min, max] range. + */ + public static function clamp(int &$value, int $min, int $max) + { + if ($value < $min) { + $value = $min; + } elseif ($value > $max) { + $value = $max; + } + } + } -- cgit v1.2.3-55-g7522