From: Matthias Schmidt Date: Fri, 2 Jul 2021 08:37:30 +0000 (+0200) Subject: Support wildcard for category name in `AclFormField` (#4355) X-Git-Tag: 5.5.0_Alpha_1~584 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1ca6f2b10733ca8696ed1e0733eff91ec9880500;p=GitHub%2FWoltLab%2FWCF.git Support wildcard for category name in `AclFormField` (#4355) --- 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()}'."); }