From 1ca6f2b10733ca8696ed1e0733eff91ec9880500 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 2 Jul 2021 10:37:30 +0200 Subject: [PATCH] Support wildcard for category name in `AclFormField` (#4355) --- .../system/form/builder/field/acl/AclFormField.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php index 3a6e4bea3c..5f3337a485 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php @@ -57,6 +57,9 @@ class AclFormField extends AbstractFormField implements IObjectTypeFormNode * Sets the name of/filter for the name(s) of the shown acl option categories and * returns this field. * + * The category name supports a `.*` suffix for filtering by multiple categories, + * so that `user.*` matches all acl option categories beginning with `user.`, for example. + * * @param string $categoryName name of/filter for the acl option categories * @return static $this this field * @@ -64,7 +67,10 @@ class AclFormField extends AbstractFormField implements IObjectTypeFormNode */ public function categoryName($categoryName) { - if (!\is_string($categoryName) || !\preg_match('~^[A-z0-9\-\_]+(\.[A-z0-9\-\_]+)+$~', $categoryName)) { + if ( + !\is_string($categoryName) + || !\preg_match('~^[A-z0-9\-\_]+((\.[A-z0-9\-\_]+)+|(\.[A-z0-9\-\_]+)*?\.\*)$~', $categoryName) + ) { throw new \InvalidArgumentException("Invalid category name given for field '{$this->getId()}'."); } -- 2.20.1