X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FACLFormatter.php;h=cd398fc280a419c314fe6b2e7a0a5af7ae299cf6;hb=e659a0314086dd700dbe5e754e383ab758725805;hp=0351b27a64a9cba0df7403d567481e633bbf0b04;hpb=6aa1dcfad371f34fea1f8e39b73de2cc3dd05784;p=friendica.git diff --git a/src/Util/ACLFormatter.php b/src/Util/ACLFormatter.php index 0351b27a64..cd398fc280 100644 --- a/src/Util/ACLFormatter.php +++ b/src/Util/ACLFormatter.php @@ -21,7 +21,7 @@ namespace Friendica\Util; -use Friendica\Model\Group; +use Friendica\Model\Circle; /** * Util class for ACL formatting @@ -29,13 +29,13 @@ use Friendica\Model\Group; final class ACLFormatter { /** - * Turn user/group ACLs stored as angle bracketed text into arrays + * Turn user/circle ACLs stored as angle bracketed text into arrays * * @param string|null $acl_string A angle-bracketed list of IDs * * @return array The array based on the IDs (empty in case there is no list) */ - public function expand(string $acl_string = null) + public function expand(string $acl_string = null): array { // In case there is no ID list, return empty array (=> no ACL set) if (empty($acl_string)) { @@ -44,7 +44,7 @@ final class ACLFormatter // turn string array of angle-bracketed elements into numeric array // e.g. "<1><2><3>" => array(1,2,3); - preg_match_all('/<(' . Group::FOLLOWERS . '|'. Group::MUTUALS . '|[0-9]+)>/', $acl_string, $matches, PREG_PATTERN_ORDER); + preg_match_all('/<(' . Circle::FOLLOWERS . '|'. Circle::MUTUALS . '|[0-9]+)>/', $acl_string, $matches, PREG_PATTERN_ORDER); return $matches[1]; } @@ -55,7 +55,7 @@ final class ACLFormatter * @param string|null $acl_string * @return string */ - public function sanitize(string $acl_string = null) + public function sanitize(string $acl_string = null): string { if (empty($acl_string)) { return ''; @@ -86,7 +86,7 @@ final class ACLFormatter if (intval($item)) { $item = '<' . intval($item) . '>'; // The item is a allowed ACL character - } elseif (in_array($item, [Group::FOLLOWERS, Group::MUTUALS])) { + } elseif (in_array($item, [Circle::FOLLOWERS, Circle::MUTUALS])) { $item = '<' . $item . '>'; // The item is already a ACL string } elseif (preg_match('/<\d+?>/', $item)) { @@ -107,10 +107,13 @@ final class ACLFormatter * * @return string */ - function toString($permissions) { + function toString($permissions): string + { $return = ''; if (is_array($permissions)) { $item = $permissions; + } elseif (empty($permissions)) { + return ''; } else { $item = explode(',', $permissions); }